[SOLVED] - General-purpose read from modem serial

I'm wondering if there is any way to read the modem serial interface, similar to how cellular.command provides a generalized way to write to it.

@BDub, in this earlier thread, you seem to indicate that there is no way currently, or was no way as of this writing:

My particular issue: I'd like to be able to read serial data received with the modem in direct link mode. No trouble sending, because I can pour data through cellular.command. But can't think of any way to get a direct link response. Can't even trick the callback function, because with the modem out of command mode there are no callbacks.

Any way to read UART3 directly?

Marking this solved because I added my own method locally.

Can you please elaborate on how you solved this issue?

@Rainer, I modified the firmware locally so that I have a method to read the serial pipe directly.

I hasten to say up front that by many measures I’m an inept engineer (I have no formal training and this is the first time I’ve written/compiled c++), but examining the firmware, it looks like this to me:

  1. the modem writes to a USART ring buffer of 64 bytes. I wired up a method so that the app can directly access characters from this ring buffer. (I ended up not using it in the end, but it let me introspect what was going on.)
  2. The ring buffer is piped to a user-defined buffer. This pipe is accessed by the existing read methods, but via AT commands, which were my proximate problem, since I had the modem in direct link mode. So basically, I created a method to skip the parsing function that accesses the pipe and go to it directly.
  3. There’s really nothing to this from a coding perspective, but various files need to be modified to expose the method to the app layer. For a relatively ignorant person, this required a bit of diligence and persistence to pull the thread all the way through and understand how the code is structured.
  4. Final note: the USART interface is set to 115200 baud, which is fast enough for my current purposes, but my guess (from cursory reading) is that it could be set higher if need be.

Of course all of this stuff requires building the firmware locally, which, for that relatively ignorant person mentioned above, was a very painful learning process. But once set up, it works extremely easily. Very liberating to be unchained entirely from the web interface. (Also, flashing via USB after downloading from the web interface had become very cumbersome for me: required that I put the device into safe mode, then put it into app flash mode three times (?) before it would finally take. No more of that. The firmware flashing is very reliable.)

2 Likes