View topic - Reading serial port at a 200 Hz rate

Reading serial port at a 200 Hz rate

Discussion about the general applications that run on QNX6

Reading serial port at a 200 Hz rate

Postby FreshDevOne » Tue Oct 19, 2010 6:27 pm

Issue: I have a device connected to my computers’ serial port (RS-232). The device is broadcasting 50 byte messages at a 200 Hz rate. I am using the devc-ser8250 driver with FIFO turned on. I have created an application that reads the messages from the serial port, but it is not optimum.

Question: What is the most efficient way to setup the interrupt to notify my application that there is data on the serial port ready to be read and then reset that process?
InterruptAttachEvent()/InterruptWait()/InterruptUnmask()
SIGEV_PULSE_INIT()/ionotify()/MsgSendPulse()/etc.
tcischars()…

Quote - I don't remember the source of this:
{InterruptAttachEvent()} This approach has a major advantage over using a pulse. A pulse is delivered as a message to the resource manager, which means that if the resource manager's message-handling threads are busy processing requests, the pulse will be queued until a thread does a MsgReceive().

Thank you for your replies!
FD
FreshDevOne
New Member
 
Posts: 6
Joined: Fri Dec 19, 2008 8:13 pm

RE: Reading serial port at a 200 Hz rate

Postby maschoen » Wed Oct 20, 2010 7:03 am

Why notify the application of the interrupt? Create a thread that is always reading the port. It would be less efficient to read char by char, but you can. read_cond() provides a number of parameters to control how you get chunks of data in a timely manner. How you get the data to your main thread is up to you. Send a message or a pulse, load a buffer and use a cond_var, raise a signal. Whatever works best for your application.
maschoen
QNX Master
 
Posts: 2720
Joined: Wed Jun 25, 2003 5:18 pm

RE: Reading serial port at a 200 Hz rate

Postby mario » Wed Oct 20, 2010 12:45 pm

OK use io_notify()/select() to be informed when there is data in the buffer
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am


Return to QNX6 - Applications

Who is online

Users browsing this forum: No registered users and 1 guest