Skip to content

drivers: nhs_ser: do not force CRTSCTS (breaks CDC-ACM and 3-wire ser…#3511

Draft
jpastoreli wants to merge 1 commit into
networkupstools:masterfrom
jpastoreli:patch-1
Draft

drivers: nhs_ser: do not force CRTSCTS (breaks CDC-ACM and 3-wire ser…#3511
jpastoreli wants to merge 1 commit into
networkupstools:masterfrom
jpastoreli:patch-1

Conversation

@jpastoreli

Copy link
Copy Markdown

Disables the hardcoded CRTSCTS in nhs_ser openfd(), which blocks
communication on NHS UPSes with no RTS/CTS lines (USB/CDC-ACM and the
official 3-wire serial cable).

Full diagnosis, raw packet captures and device details: Refs #3510

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit 58af3b7 is temporarily available: NUT-tarballs-PR-3511.zip.

…ial)

Forcing CRTSCTS in openfd() blocks communication on NHS UPSes whose port
     has no hardware flow-control lines: USB/CDC-ACM virtual ports (e.g.
     /dev/ttyACM0) and the official NHS 3-wire RS-232 cable (DB9 pins 2/3/5
     only, no RTS/CTS). The driver opens the port but never assembles a packet.
     Disabling CRTSCTS restores communication.

Signed-off-by: Jonas Pastoreli <100150319+jpastoreli@users.noreply.github.com>
@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.4900-master completed (commit 24cb2b67bf by @jpastoreli)

@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.4901-master completed (commit d41946991b by @jpastoreli)

@jimklimov jimklimov added bug serial port Connection stability issues Issues about driver<->device and/or networked connections (upsd<->upsmon...) going AWOL over time impacts-release-2.8.5 Issues reported against NUT release 2.8.5 (maybe vanilla or with minor packaging tweaks) labels Jun 29, 2026
@jimklimov jimklimov added this to the 2.8.6 milestone Jun 29, 2026
@jimklimov

Copy link
Copy Markdown
Member

Generally looks reasonable; deferring to @Challado as original author per #2692 to make sure it works with the model it was originally posted for too.

The PR would benefit from also a note in NEWS.adoc about the driver update, and a DRIVER_VERSION number bump.

@Challado

Copy link
Copy Markdown

Generally looks reasonable; deferring to @Challado as original author per #2692 to make sure it works with the model it was originally posted for too.

The PR would benefit from also a note in NEWS.adoc about the driver update, and a DRIVER_VERSION number bump.

As expected, testing on 3 units that I know the problem appears fail on communication.

@Challado

Challado commented Jul 2, 2026

Copy link
Copy Markdown

Re-tested with other 2 units, same problem @jimklimov. I'll see that I can make something about these code and commit a more elegant solution.

@Challado

Challado commented Jul 3, 2026

Copy link
Copy Markdown

@jimklimov
Quick update: I reworked the proposed fix into a more general nhs_ser change instead of just removing CRTSCTS unconditionally.

The current implementation keeps the existing driver behavior as the default, but makes the relevant serial communication settings configurable from ups.conf.

Default behavior is intentionally preserved:

  • baud = 2400
  • serial_data_bits = 8
  • serial_parity = none
  • serial_stop_bits = 1
  • serial_flow_control = hardware
  • serial_read_timeout_ms = 100
  • serial_send_pace_us = 0

So existing installations should continue to behave as before, including the historical RTS/CTS default.

For the NHS Mini Gamer / CDC-ACM case described in this issue, the fix is now simply:

serial_flow_control = none

I also changed the implementation to use the standard NUT serial helpers instead of keeping direct serial I/O paths in the driver:

  • TYPE_FD_SER
  • ser_open_nf()
  • ser_set_speed_nf()
  • ser_close()
  • ser_get_char()
  • ser_send_buf()
  • ser_send_buf_pace()
  • ser_flush_io()

The driver now only keeps local termios handling for the settings not covered directly by those helpers: data bits, parity, stop bits and flow control.

I deliberately reduced the scope after testing the first approach. The earlier version exposed too many low-level termios and Linux-specific details, so I removed those and kept only conventional serial-port options which are useful for this driver:

  • baud rate
  • data bits
  • parity
  • stop bits
  • flow control
  • per-byte read timeout
  • optional transmit pacing

I also removed the Linux-specific TIOCGSERIAL / TIOCSSERIAL handling from the proposed change. That does not help CDC-ACM devices and seemed unnecessary for solving this issue.

All new options are registered with addvar(VAR_VALUE, ...) and validated through getval() during driver initialization. Invalid values fail early with a clear configuration error instead of being silently accepted.

The NHS packet protocol handling itself is unchanged: DATA/HWINFO framing, checksums, packet decoding, status handling and reconnect logic remain the same.

I have built the updated driver successfully. My next step is to test it on the affected NHS Mini Gamer device with:

serial_flow_control = none

and also verify that the default configuration still behaves the same on devices which worked with the previous hardcoded RTS/CTS behavior.

@jimklimov
jimklimov marked this pull request as draft July 17, 2026 15:36
@jimklimov

Copy link
Copy Markdown
Member

@Challado @jpastoreli : was the updated fix pushed anywhere and posted as a PR?

@Challado

Challado commented Jul 18, 2026 via email

Copy link
Copy Markdown

@jimklimov

Copy link
Copy Markdown
Member

Thanks, i'll take a look - and gave a good vacation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Connection stability issues Issues about driver<->device and/or networked connections (upsd<->upsmon...) going AWOL over time impacts-release-2.8.5 Issues reported against NUT release 2.8.5 (maybe vanilla or with minor packaging tweaks) serial port

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants