Linux Wemos D1 Mini ch34x, ch341

This is not a PIO problem rather a plea for help from Linux gurus.
Plugging in any Wemos D1 Mini (running a blinky type program) into my PC running Mint 18 is fine for say 30-40 seconds.
I can ioctl /dev/ttyUSBx and see the messages from Serial.printf as expected with cat < /dev/ttyUSBx (or PIO monitor).

Then the led starts blinking erratically and comms stops for a while. This behaviour stops any uploading or monitoring within PIO obviously.

If I plug the Wemos into a Raspberry PI (ch341 driver) this crazy behaviour does not happen. It all works perfectly. Forever.

Putting a scope on the Wemos Rx pin, the difference is that the PC sends all kinds of stuff to the Wemos when you plug it in whereas the Rpi doesn’t. Debugging the PC driver (ch34x) shows something is periodically trying to probe /dev/ttyUSBx, changing baud rate then sending single characters.

What is doing this? It’s not the usual suspects (ModemManager or brltty) and nothing shows up as holding /dev/ttyUSBx open. So I’m thinking it must be a daemon process somewhere. How to find it?

What is really annoying is that I did tons of development on the PC 3 years ago and it never exhibited this behaviour.
Any ideas gratefully rx’d!

I’ve seen people having massive problems with serial ports when the Braille TTY “BRLTTY” program was installed – apparently it tries to take over these serial ports or probes them by itself.

See e.g.

Removing it with

sudo apt-get remove --auto-remove brltty 

instantly got rid of the problem for these users.

Oh, okay. Then it can’t be that.

When this happens, is there anything interesting in the kernel log? sudo dmesg -w?

Many thanks, sadly I removed brltty a few weeks ago to no effect.
Am currently, in utter desperation, looking at “agetty”, but that is only run on /dev/tty1 on my system.

Got it!
The culprit was pwrstatd. (Uninterruptable Power Supply thing - that’s what was installed since I was last using PIO. )
Wretched thing just sits there trying to commandeer ttyUSB0; no please or thank you. No hint in dmesg or syslog.

Fix: sudo systemctl stop pwrstatd
(There are some pwrstatd config files somewhere which would probably be a better long term fix though.)

Thanks for supporting me @maxgerhardt - much appreciated.

1 Like