0

I've been having to come back to a modem I have and sending AT commands to it, and I need to do this programmatically. Sending AT commands works fine if using Minicom, but when using any kind of programatic method it's just super unreliable. I've tried echos and redirection with bash, the atinout program, and the pyserial module in Python, but no matter what sending and receiving commands is iffy at best. It is very rare that I attempt to run the same AT command twice and get consistent output back. I'll get the complete response one time, but then a partial response the next, or maybe no response.

Admittedly I don't know much about serial, so maybe it's my hardware, or maybe the protocol for reading and writing to serial is just unreliable. Can someone please explain how, in general, reading and writing output over a serial port may be unreliable, and any good techniques or libraries to help guarantee a stable flow of reading and writing?

DeepDeadpool
  • 1,441
  • 12
  • 36
  • "*Admittedly I don't know much about serial, so maybe ...*" it's your bad code? After all "*sending AT commands works fine if using Minicom*", so you trying to blame the the hardware or the protocol makes no sense. – sawdust Nov 04 '22 at 04:54
  • Does this answer your question? [What is a proper way to send AT commands?](https://stackoverflow.com/questions/73254324/what-is-a-proper-way-to-send-at-commands) – sawdust Nov 04 '22 at 04:59
  • It does not because that is one of the methods I've tried. It's not my code because I'm not using my own code; I'm using existing programs or libraries like atinout, echo with redirects, or the python3 serial library which have all proven quite unreliable even in their most basic use-cases. At this point I'm trying to understand the serial protocol better. Maybe I need to throw in delays, or do something to flush the device or something – DeepDeadpool Nov 04 '22 at 14:51
  • I'll add some code examples to show what I'm talking about. – DeepDeadpool Nov 04 '22 at 15:11

1 Answers1

2

There was another service on my system called ModemManager that was consuming the serial device at the same time I was running through my commands. Once that was disabled all of my programmatic efforts started producing reliable IO to the device.

DeepDeadpool
  • 1,441
  • 12
  • 36