RS232 Listener Implementation | Telit Cinterion IoT Developer Community
March 26, 2015 - 12:57am, 2846 views
I am looking at implementing an RS232 Listener.
I would appreciate any help in locating an example or documentation for its implementation. This will include initially ensuring I am listening on the required port, ASC0 or ASC1 on the EHS6T.
On the system I am looking at designing there will also be a ATCommand Listener. Since I need to be able to respond to either Listener, which operate asynchronously with other, and not lose data. Will that mean I will need to create a protocol so that the transmitting end will effectively poll the GSM device until one of the Listeners respond, before I start transmitting data. I am initially assuming the device will not be fast enough to service the code associated with both Listeners simultaneously, due to the delay with threads trying to time-slice between the two threads?
For listening on RS232 port ASC0 or ASC1 I usually just create a separate thread, which listens for traffic on RS232. In my protocol I normally finish RS232 data transfer with 03 ascii char. Here is example if it’s any help to you.
http://pastebin.com/6u66k1hQ
Thank you for your reply.
On your example code on the link, I can't see how you are able to differentiate between picking up data from ASC0 or ASC1. One of my main conerns is - will using a thread be too slow to read a serial stream, 250Kbaud, if when I start receiving data I am currently already using a thread for receiving data via the GSM port.
If you want to listen to both ASC0 and ASC1 at the same time, then you would need to have seperate thread for each of the COM ports.
You can only try it. When I was testing GPIO listeners, they where faster if each one was in it one thread, so maybe if you would have thread for each of the COM ports it would be fast enough. You could also set thread to *** priority if that would change anything.
Regards,
Jure
Hello,
Threading of course has some overhead. But you can have many threads in your application and you probably will.
With ATCommandListener you can listen to events from the module like URC's.
You just need to implement the ATEvent() method and it will be called whenever the URC comes. The code inside callback ATEvent() method should be short and the execution should be fast or the separate thread should be started if long processing is needed.
Regards,
Bartłomiej