Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bicker serial driver #2448

Merged
merged 23 commits into from
May 24, 2024
Merged

Add Bicker serial driver #2448

merged 23 commits into from
May 24, 2024

Commits on May 21, 2024

  1. bicker_ser: Bicker UPSes based on PSZ-1063

    Add a new driver for Bicker DC UPS systems based on the PSZ-1063
    extension module. This includes UPSIC-1205, UPSIC-2403 and
    DC2412-UPS(LD) models.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    a56281b View commit details
    Browse the repository at this point in the history
  2. bicker_ser: add shutdown support

    The protocol supports shutdown after a custom delay settable between 0
    and 255 seconds. Unfortunately the real device (UPSIC-2403D) seems to
    always enforce a 2 seconds delay.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    021472d View commit details
    Browse the repository at this point in the history
  3. data/driver.list.in: add bicker_ser based UPSes

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    3ae6b50 View commit details
    Browse the repository at this point in the history
  4. bicker_ser: add big-endian platform support

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    0b53475 View commit details
    Browse the repository at this point in the history
  5. bicker_ser: use length macros to increase expressiveness

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    6538f2f View commit details
    Browse the repository at this point in the history
  6. bicker_ser: add manpage

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    67ffe25 View commit details
    Browse the repository at this point in the history
  7. NEWS.adoc: announce bicker_ser driver [networkupstools#2318]

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    ffd42d1 View commit details
    Browse the repository at this point in the history
  8. bicker_ser: update protocol documentation

    Bicker told me to refer to the UPS Gen software's user manual for more
    details on their protocol, and in fact that manual contains much more
    info. Added a summary of available commands to the comments, as a quick
    reference for feature implementation.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    d5e7ce5 View commit details
    Browse the repository at this point in the history
  9. bicker_ser: explicitly pass the command index

    In the previous implementation the command index was always '\x03', as
    stated by the UPSIC manual. After new evidence has been found (UPS-Gen2
    software user manual), it came out there are much more commands grouped
    in different indexes.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    162e39e View commit details
    Browse the repository at this point in the history
  10. bicker_ser: refactor to allow more complex packet handling

    I'm planning to add functions for reading strings, i.e. without knowing
    beforehand the size of the response packets. This required some
    refactoring of the receiving functions.
    
    Also, while at it, added docblocks to many Bicker functions, hopefully
    easing the maintenance in the future.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    8abde1a View commit details
    Browse the repository at this point in the history
  11. bicker_ser: add more state variables

    Identification fields are now queried from the device. Also
    "battery.charge" is now set properly.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    eaddb34 View commit details
    Browse the repository at this point in the history
  12. bicker_ser: use variable for low battery limit

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    c659e31 View commit details
    Browse the repository at this point in the history
  13. bicker_ser: add parameter support

    Added the needed infrastructure for getting and setting parameters.
    Actually the only parameter that is surely working is "ups.delay.start".
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 21, 2024
    Configuration menu
    Copy the full SHA
    a4c3767 View commit details
    Browse the repository at this point in the history

Commits on May 22, 2024

  1. bicker_ser: differentiate between error and unsupported

    When a command is unsupported, the "\x01\x03\xEE\x07\x04" response
    packet is returned. This is different from a response packet with a
    wrong command index.
    
    WARNING: the "unsupported" packet has been found sperimentally and it is
    an undocumented feature.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    Configuration menu
    Copy the full SHA
    ee71353 View commit details
    Browse the repository at this point in the history
  2. bicker_ser: fix string dstate setting

    User provided strings could contain printf special sequences and as such
    they should never be used in the format argument of dstate_setinfo().
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    Configuration menu
    Copy the full SHA
    c9fed62 View commit details
    Browse the repository at this point in the history
  3. bicker_ser: fix alignment and endianness problems

    Accessing an uint16_t on odd addresses is not portable. Avoid having to
    deal with that issue by always constructing words mathematically from
    single bytes. This also solves any endianness difference.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    1 Configuration menu
    Copy the full SHA
    c9ba796 View commit details
    Browse the repository at this point in the history
  4. bicker_ser: cosmetic fixes

    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    Configuration menu
    Copy the full SHA
    beb26a6 View commit details
    Browse the repository at this point in the history
  5. bicker_ser: use uint8_t for bytes instead of char

    `char` is by default signed and (as the name implies) designed to access
    string characters. For accessing bytes, the `uint8_t` type is more
    appropriate.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    Configuration menu
    Copy the full SHA
    0c80ece View commit details
    Browse the repository at this point in the history
  6. bicker_ser: use proper format modifiers in logs

    Ensure the format string in logging messages is the correct one without
    subcasting. Furthermore, due to the promotion rules of the C language
    (where any given type, even unsigned, is promoted to int when possible),
    explicitly cast to unsigned where required.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    Configuration menu
    Copy the full SHA
    4a33b3a View commit details
    Browse the repository at this point in the history
  7. bicker_ser: refactor to clarify packet manipulation

    Change BICKER_PACKET from a constant value to a macro that depends on
    the data length. This should make clear that the packet size depends
    directly from the data size.
    
    Refactored some code here and there trying to minimize the presence of
    magic numbers and clarify the intentions.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 22, 2024
    Configuration menu
    Copy the full SHA
    c78524c View commit details
    Browse the repository at this point in the history

Commits on May 23, 2024

  1. bicker_ser: make parameter handling less error prone

    Using an in/out struct and making some specific field mandatory is
    cumbersome and error prone. Now the data needed for setting or getting
    parameters is explicitly required by the arguments.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 23, 2024
    Configuration menu
    Copy the full SHA
    27bdc87 View commit details
    Browse the repository at this point in the history
  2. bicker_ser: add sanity checks to bicker_set

    These devices seem to be picky on what you use to set parameters.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 23, 2024
    Configuration menu
    Copy the full SHA
    fca9957 View commit details
    Browse the repository at this point in the history
  3. bicker_ser: expose mappable parameters

    Every Bicker parameter that has a correspondence in nut-names.txt has
    been mapped. If the parameter is disabled on the device, no NUT variable
    is created. If the NUT variable is set to an empty string, the parameter
    is reset and disabled on the device and that NUT variable is removed.
    
    Signed-off-by: Nicola Fontana <[email protected]>
    ntd committed May 23, 2024
    Configuration menu
    Copy the full SHA
    4cbe12d View commit details
    Browse the repository at this point in the history