I have an Arduino Uno attached over USB, using the cdc_acm driver. It is available at /dev/ttyACM0.

The convention for the Arduino's serial interface is for the DTR signal to be used for a reset signal—when using the integrated serial-to-USB adapter, the DTR/RTS/DSR/CTS signal; or, when using an RS-232 cable, pins 4 or 5 (and possibly 6 or 8) are wired to the RESET pin.

This reset avenue has the important advantage of being, if not truly out-of-band, at least very near-failsafe (due to being implemented via the always-out-of-band serial controller in conjunction with the not-normally-user-controllable watchdog circuit), and while it can be physically disabled (via wiring either a capacitor or a resistor, depending on the model, to the RESET pin), to do so completely ruins this important killswitch and all associated utility.

Unfortunately, it seems that, currently, Linux absolutely always sends this signal when any program attaches to an ACM device for any reason, and (unlike Windows,) provides no even-vaguely-known-reliable way to prevent this.

(Currently both -hupcl, "send a hangup signal when the last process closes the tty" and -clocal, "disable modem control signals" do not prevent this signal from being sent every time the device is opened.)

tl;dr: What do I need to do to access /dev/ttyACM0 without sending it a DTR/RTS/DSR/CTS signal (short of blocking the signal on the hardware level)?

  • and I guess this question applies to ALL serial drivers, not just cdc_acm. But first things first, and the once-in-a-blue-moon that onboard RS-232 chips are used, even then probably nobody cares about being unable to control this. But with Arduinos, there's a clear and pressing concern. (In BOTH CASES, though, it's highly concerning that Windows has us so handily beat; I'd have expected this situation to be the other way around) – JamesTheAwesomeDude Sep 25 '18 at 22:12
  • I hope that I'm mistaken, but you'll probably have to modify the driver; I had to do the same with with the pl2303 driver in order to prevent it from pulling dtr/rts high on reset so I could use those (otherwise useless) signals separately from the serial port via the TIOCMSET ioctl. – mosvy Sep 25 '18 at 22:37
  • If you can recompile the cdc-acm.ko kernel module, you can try commenting out this line from drivers/usb/class/cdc-acm.c. – mosvy Sep 25 '18 at 23:50
  • Removing that line would entirely break control over that feature, right? (Which would make it so you couldn't program an Arduino, for instance) – JamesTheAwesomeDude Sep 28 '18 at 19:18
  • No. Have you read my comment? I'm setting dtr/rts fine with ioctl(TIOCMSET). Removing it will only prevent the kernel from raising dtr/rts on opening the tty and lowering them on closing it. – mosvy Sep 28 '18 at 19:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.