11-18-2010 07:13 AM
I am collecting data from a number of devices using RS485.
Data collection is initiated by a request message sent from the PC to the device and a message is returned.
I need to "divorce" the data collection from the processing, and to this end I have tried using multithreading.
This works to some extent, but the context switching seems to take too long.
Data rate is 115kBaud, messages are ~8 bytes for the request and ~30 bytes for the reply.
There are up to 32 devices and I need to acquire from each 5 times per second.
(That equates to 5 * 32 * (8 + 30) = 6080 bytes or 60800 bits every second.
This is achievable at a baud rate of 115k baud, with approximately 53% utilisation of the communications channel.)
To get this to work properly, I need to be able to "hook in" to the interrupts generated by the device drivers for both transmit and receive so that the changeover from send to receive can be achieved with minimal latency.
Servicing the data for both transmit and receive would not take too long even if done on individual characters.
Is this possible without needing to write a device driver?
If so how please.
Solved! Go to Solution.
11-18-2010 04:22 PM
I have not programmed anything in RS485, but have you tried the function for InstallComCallback? There you can set different callbacks for different characters received.
11-19-2010 03:16 AM
Many thanks,
That looks as though it will do precisely what I want.
Highlights the usual problem - if you don't know what you are looking for, you can't find it!
11-19-2010 07:36 AM
Derek:
CVI ships with example programs covering many topics, including serial communication. You can use the NI Example Finder (on the startup screen and under Help) to search for serial. One of the serial examples uses InstallComCallback, as Ngay suggested.
NI's example programs can be a good way to start exploring new topics in CVI programming.