Skip to content

Conversation

@systemcrash
Copy link

@systemcrash systemcrash commented Jan 12, 2026

  • Did not "blindly assume" default integer type sizes and value ranges...

This aligns -h output e.g.:

Acceptable values for -x or ups.conf in this driver:

             subdriver=<value>	Serial-over-USB subdriver selection
                vendor=<value>	Regular expression to match UPS Manufacturer string
               product=<value>	Regular expression to match UPS Product string
                serial=<value>	Regular expression to match UPS Serial number
              vendorid=<value>	Regular expression to match UPS Manufacturer numerical ID (4 digits hexadecimal)
             productid=<value>	Regular expression to match UPS Product numerical ID (4 digits hexadecimal)
                   bus=<value>	Regular expression to match USB bus name
                device=<value>	Regular expression to match USB device name
               busport=<value>	Regular expression to match USB bus port name
      allow_duplicates        	If you have several UPS devices which may not be uniquely identified by options above, allow each driver instance with this option to take the first match if available, or try another (association of driver to device may vary between runs)
  usb_set_altinterface=<value>	Force redundant call to usb_set_altinterface() (value=bAlternateSetting; default=0)
      usb_config_index=<value>	Deeper tuning of USB communications for complex devices
     usb_hid_rep_index=<value>	Deeper tuning of USB communications for complex devices
    usb_hid_desc_index=<value>	Deeper tuning of USB communications for complex devices
         usb_hid_ep_in=<value>	Deeper tuning of USB communications for complex devices
        usb_hid_ep_out=<value>	Deeper tuning of USB communications for complex devices
            langid_fix=<value>	Apply the language ID workaround to the krauler subdriver (0x409 or 0x4095)
               ondelay=<value>	Delay before UPS startup (minutes)
              offdelay=<value>	Delay before UPS shutdown (seconds)
            runtimecal=<value>	Parameters used for runtime calculation
            chargetime=<value>	Nominal charge time for UPS battery
              idleload=<value>	Minimum load to be used for runtime calculation
              norating        	Skip reading rating information from UPS
              novendor        	Skip reading vendor information from UPS
              protocol=<value>	Preselect communication protocol (skip autodetection)

Acceptable values for 'subdriver' via -x or ups.conf in this driver:
  cypress
  phoenix
    ippon
  krauler

and

Acceptable values for -x or ups.conf in this driver:

                                   lowbatt=<value>	Set low battery level, in % (default=30)
                                  offdelay=<value>	Set shutdown delay, in seconds (default=20, or 60 for CPS devices)
                                   ondelay=<value>	Set startup delay, in seconds (default=30, or 120 for CPS devices)
                                  pollfreq=<value>	Set polling frequency, in seconds, to reduce data flow (default=30, or 12 for CPS devices)
                                  pollonly        	Don't use interrupt pipe, only use polling (recommended for CPS devices)
        interrupt_pipe_no_events_tolerance=<value>	How many times in a row do we tolerate "Got 0 HID objects" from USB interrupts?
                           onlinedischarge        	Set to treat discharging while online as being offline/on-battery (DEPRECATED, use onlinedischarge_onbattery)
                 onlinedischarge_onbattery        	Set to treat discharging while online as being offline/on-battery
               onlinedischarge_calibration        	Set to treat discharging while online as doing calibration
          onlinedischarge_log_throttle_sec=<value>	Set to throttle log messages about discharging while online (only so often)
  onlinedischarge_log_throttle_hovercharge=<value>	Set to throttle log messages about discharging while online (only if battery.charge is under this value)
                        lbrb_log_delay_sec=<value>	Set to delay status-setting (and log messages) about device in LB or LB+RB state
        lbrb_log_delay_without_calibrating        	Set to apply lbrb_log_delay_sec even if device is not calibrating
                   disable_fix_report_desc        	Set to disable fix-ups for broken USB encoding, etc. which we apply by default on certain vendors/products
        powercom_sdcmd_byte_order_fallback        	Set to use legacy byte order for Powercom HID shutdown commands. Either it was wrong forever, or some older devices/firmwares had it the other way around
             powercom_sdcmd_discrete_delay        	Set to use discrete timing table for Powercom HID shutdown commands (Raptor and Smart KING Pro series)
                                 subdriver=<value>	Explicit USB HID subdriver selection
                                    vendor=<value>	Regular expression to match UPS Manufacturer string
                                   product=<value>	Regular expression to match UPS Product string
                                    serial=<value>	Regular expression to match UPS Serial number
                                  vendorid=<value>	Regular expression to match UPS Manufacturer numerical ID (4 digits hexadecimal)
                                 productid=<value>	Regular expression to match UPS Product numerical ID (4 digits hexadecimal)
                                       bus=<value>	Regular expression to match USB bus name
                                    device=<value>	Regular expression to match USB device name
                                   busport=<value>	Regular expression to match USB bus port name
                          allow_duplicates        	If you have several UPS devices which may not be uniquely identified by options above, allow each driver instance with this option to take the first match if available, or try another (association of driver to device may vary between runs)
                      usb_set_altinterface=<value>	Force redundant call to usb_set_altinterface() (value=bAlternateSetting; default=0)
                          usb_config_index=<value>	Deeper tuning of USB communications for complex devices
                         usb_hid_rep_index=<value>	Deeper tuning of USB communications for complex devices
                        usb_hid_desc_index=<value>	Deeper tuning of USB communications for complex devices
                             usb_hid_ep_in=<value>	Deeper tuning of USB communications for complex devices
                            usb_hid_ep_out=<value>	Deeper tuning of USB communications for complex devices
                                   explore        	Diagnostic matching of unsupported UPS
                                 maxreport        	Activate tweak for buggy APC Back-UPS firmware
                             interruptonly        	Don't use polling, only use interrupt pipe
                             interruptsize=<value>	Number of bytes to read from interrupt pipe
                       waitbeforereconnect=<value>	Seconds to wait before trying to reconnect

Acceptable values for 'subdriver' via -x or ups.conf in this driver (exact names here, case-insensitive sub-strings may be used, as well as regular expressions):
	"EXPLORE HID 0.2"
	"MGE HID 1.57"
	"APC HID 0.101"
	"Arduino HID 0.21"
	"Belkin/Liebert HID 0.22"
	"CyberPower HID 0.84"
	"Delta UPS HID 0.6"
	"EcoFlow HID 0.01"
	"Ever HID 0.10"
	"iDowell HID 0.2"
	"Legrand HID 0.2"
	"Phoenixtec/Liebert HID 0.41"
	"openUPS HID 0.50"
	"PowerCOM HID 0.72"
	"Powervar HID 0.20"
	"Salicru HID 0.4"
	"TrippLite HID 0.85"

print the self describing parameter name first, then the descriptive
text. Otherwise it's a wall of text where one has to search for the
parameter, because it's unaligned.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
instead of

Acceptable values...: blah, blah

print:

Acceptable values...:
	blah1
	blah2
	...

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
@AppVeyorBot
Copy link

@jimklimov
Copy link
Member

Thanks, that does look rather neat. The original design aimed for descriptions to be under 40 chars, so they would also align prettily, but this was not closely followed.

For PR benefits' comparison, here's how such help looked before (in current master branch) for e.g. usbhid-ups:

Acceptable values for -x or ups.conf in this driver:

Set low battery level, in % (default=30) : -x lowbatt=<value>
Set shutdown delay, in seconds (default=20, or 60 for CPS devices) : -x offdelay=<value>
Set startup delay, in seconds (default=30, or 120 for CPS devices) : -x ondelay=<value>
Set polling frequency, in seconds, to reduce data flow (default=30, or 12 for CPS devices) : -x pollfreq=<value>
Don't use interrupt pipe, only use polling (recommended for CPS devices) : -x pollonly
How many times in a row do we tolerate "Got 0 HID objects" from USB interrupts? : -x interrupt_pipe_no_events_tolerance=<value>
Set to treat discharging while online as being offline/on-battery (DEPRECATED, use onlinedischarge_onbattery) : -x onlinedischarge
Set to treat discharging while online as being offline/on-battery : -x onlinedischarge_onbattery
Set to treat discharging while online as doing calibration : -x onlinedischarge_calibration
Set to throttle log messages about discharging while online (only so often) : -x onlinedischarge_log_throttle_sec=<value>
Set to throttle log messages about discharging while online (only if battery.charge is under this value) : -x onlinedischarge_log_throttle_hovercharge=<value>
Set to delay status-setting (and log messages) about device in LB or LB+RB state : -x lbrb_log_delay_sec=<value>
Set to apply lbrb_log_delay_sec even if device is not calibrating : -x lbrb_log_delay_without_calibrating
Set to disable fix-ups for broken USB encoding, etc. which we apply by default on certain vendors/products : -x disable_fix_report_desc
Set to use legacy byte order for Powercom HID shutdown commands. Either it was wrong forever, or some older devices/firmwares had it the other way around : -x powercom_sdcmd_byte_order_fallback
Set to use discrete timing table for Powercom HID shutdown commands (Raptor and Smart KING Pro series) : -x powercom_sdcmd_discrete_delay
    Explicit USB HID subdriver selection : -x subdriver=<value>
Regular expression to match UPS Manufacturer string : -x vendor=<value>
Regular expression to match UPS Product string : -x product=<value>
Regular expression to match UPS Serial number : -x serial=<value>
Regular expression to match UPS Manufacturer numerical ID (4 digits hexadecimal) : -x vendorid=<value>
Regular expression to match UPS Product numerical ID (4 digits hexadecimal) : -x productid=<value>
Regular expression to match USB bus name : -x bus=<value>
Regular expression to match USB device name : -x device=<value>
Regular expression to match USB bus port name : -x busport=<value>
If you have several UPS devices which may not be uniquely identified by options above, allow each driver instance with this option to take the first match if available, or try another (association of driver to device may vary between runs) : -x allow_duplicates
Force redundant call to usb_set_altinterface() (value=bAlternateSetting; default=0) : -x usb_set_altinterface=<value>
Deeper tuning of USB communications for complex devices : -x usb_config_index=<value>
Deeper tuning of USB communications for complex devices : -x usb_hid_rep_index=<value>
Deeper tuning of USB communications for complex devices : -x usb_hid_desc_index=<value>
Deeper tuning of USB communications for complex devices : -x usb_hid_ep_in=<value>
Deeper tuning of USB communications for complex devices : -x usb_hid_ep_out=<value>
  Diagnostic matching of unsupported UPS : -x explore
Activate tweak for buggy APC Back-UPS firmware : -x maxreport
Don't use polling, only use interrupt pipe : -x interruptonly
Number of bytes to read from interrupt pipe : -x interruptsize=<value>
Seconds to wait before trying to reconnect : -x waitbeforereconnect=<value>

Acceptable values for 'subdriver' via -x or ups.conf in this driver (exact names here, case-insensitive sub-strings may be used, as well as regular expressions): "EXPLORE HID 0.2", "MGE HID 1.57", "APC HID 0.101", "Arduino HID 0.21", "Belkin/Liebert HID 0.22", "CyberPower HID 0.84", "Delta UPS HID 0.6", "EcoFlow HID 0.01", "Ever HID 0.10", "iDowell HID 0.2", "Legrand HID 0.2", "Phoenixtec/Liebert HID 0.41", "openUPS HID 0.50", "PowerCOM HID 0.72", "Powervar HID 0.20", "Salicru HID 0.4", "TrippLite HID 0.85"

@systemcrash : did you check any other drivers with complex outputs, if they need any custom fixes like you had for a couple of non-main.c sources here?

@jimklimov
Copy link
Member

@systemcrash : check CI complaints, something mismatched with nutdrv_qx.c...

@jimklimov jimklimov added this to the 2.8.5 milestone Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants