Hmm, started messing with the cellular module driver, and soon realized that the sophistication required to ensure that expected results are delivered from the module in a timely manner is more difficult than first ancipated.
I have Googling and looking into codeshare for inspiration without being able to find anything usable.
The serial communication in the cellular module is running in its own thread, receiving stuff from the module, and only printing it, and checking for know errors in the return values, but not being able to get back on a specific request. Basically it does not relate calls and return values.
This works in test setup, but as I am moving on, I need to improve this significantly.
How about passing a structure with all required data for the request and a callback delegate. As soon as the request is done the callback can be used to report back. Similar to how it is done in .Net
Yeah, for each command the module returns with a copy of the command (in some case, and if command-echo is on) and a return value. Which often is OK but also can be values, timestamps, signal-strength and more.
In the above example there is a few places where it would be VERY relevant to check for return values, but I had no imperatives to do it, so thats the reason for this question.
According to @ John this issue is on the list of stuff to do on the cellular driver, I assume he might have an idea about how to solve this.
Seems very simple to me, unless I’ve missed something.
Start with reading from the serial port where you do need the result. Then parse the string to get the data.
There is a SendLine function that sends a message and waits for the return message. It only blocks the thread that calls it. (there is a message queue that tracks command/responses) It has survived some good random testing with multiple threads flooding the serial port with messages.