Per topic, I'm trying to capture the output of AT commands sent to an LTE modem attached to an OpenWrt 18.06.2 router to log signal data that uqmi doesn't provide. For example, this is the response I get if I issue the command "at!gstatus?" to the modem using screen or minicom.
however, when I script that same command as below, the output is very inconsistent. Sometimes it works, often it's just partial. The output is never incorrect/incomplete/inconsistent when I enter the command directly, only when I script it through chat.
I typically use Python (3) for this kind of thing, with multi-threading. One typically needs an “independent” reader and writer for robust operation. Python isn’t small. You probably would need the lite and serial packages.
Unfortunately I know next to nothing about Python. Would seem I should be able to script this simply with minicom or something designed for this, but I'm striking out.
minicom would seem to just need something like:
minicom -D /dev/ttyUSB2 -S scriptname -C capture
but for the life of me the script won't run that way, I just get a normal interactive minicom console, and my script doesn't appear to have run at all.
While minicom, screen, or the like works OK for interactive input, you need to feed it from and have it feed a script. There might be some way to do it with redirecting both STDIN and STDOUT, but I've never tried to tackle that.
In my case I think I just need the simple functionality of a capture file, I'm not really doing anything interactive. I'm dumping a single command to the local modem device and I just want to capture the output, which is exactly the scenario -S and -C in minicom seem ideal for.
Just this one-liner (and then exit) and log the output for massaging into a csv log of the signal info.
If cat or tail don't work, then try reading character by character, checking that the IOCTLs are set up properly, and the like. ttys can be very fickle