06-26-2006 11:57 AM
06-26-2006 12:45 PM
This is all simple, basic stuff you want to do here. You basically have two main options, either use the functions in the RS-232 library or the functions in the VISA library. I personally prefer the VISA library because I often deal with instruments that may have multiple interfaces and VISA allows me to write code that works across multiple interface types without having to use a different library and with only minor changes in the initial setup based on the actual interface type in use.
If using the RS-232 library, the basic function call sequence is like this (I am not providing parameters, you will need to look up how to use the functions)::
OpenComConfig() ComWrt() ComRd() ComClose()
If using the VISA library, you will need to do the following:
viOpenDefaultRM() viOpen() // For the serial port viSetAttribute() // For each attribute you need such as baud rate, etc. viWrite() viRead() viClose()
While the VISA approach may require a few more calls to do the basic setup, it is more flexible and the programming model is much more consistent across interfaces. It is worth looking into, it is definitely a more modern approach to doing this sort of thing.
And just for the record, it is indeed possible to actually receive and transmit data simultaneously on a serial port, it's called full-duplex mode and the hardware helps you do that by providing a FIFO buffer for the received data and one for the transmit data. As long as you can service both buffers fast enough with your program (not an issue on modern PCs at most, if not all baud rates), you can communicate in full-duplex mode with no loss of data.
06-26-2006 04:38 PM
06-26-2006 04:42 PM
Good points there Roberto.
I've been doing this stuff for so long I don't even think about those little details anymore, it's all second nature to me now.
06-26-2006 05:50 PM