04-18-2018 04:08 AM
Hi,
I have a small application that I am running on a cRIO-9063 that has multiple RS232 and RS422 ports processing NMEA sentences. I have written all the code in C++ (with the NI Eclipse/GCC tools) and it all works well for the RS232 ports on the 9870 but for the RS422 ports on the 9871 I am getting no receive of characters, the transmit to 9871 RS422 is fine. As a test I have used NI MAX and through the VISA Test Panel I have been able to receive strings OK. I am using the standard Linux termios function calls. I have a suspicion that maybe the module is trying to operate in an RS485 Mode? Are there ioctl functions to set the mode? Has anybody experienced this issue? If it didn't work for RS232 I would be more suspicious of my code. Is there anyway of calling the VISA libraries from the processor on the 9063 instead of the Linux ones? Are there any "interesting" values that you need to used in the termios structures that are passed to the serial port for RS422?
Solved! Go to Solution.
04-19-2018 04:37 AM
More information...
If I use Max to access the port through the "Open VISA Test Panel" just once it will set the port into a mode where the read will start to work on my application from then on... I suppose one hack is to try and emulate the max behavior before I run up my application... certainly points to some missing Initialization... Just what is it?
04-23-2018 07:51 PM
OK -- sorted it so posting how to do it for anybody else who wants to use Linux on the RIO with RS422. It seems that the RTS line controls the Receive Enable somewhere in the bowels of the module. This can be done with:
int rts_bits = TIOCM_RTS;
int err = ioctl(m_file_descriptor, TIOCMBIC, &rts_bits);
05-02-2018 03:48 AM
I was a bit overly confident about the success there!
The RTS line seems to affect the read enable/write enable functionality of the port. Found a document that seems to suggest that it is the DTR line that does this... which dosen't seem to be true... well not as far as I can tell anyway. It seems to also be fixed in a half duplex mode... My rather annoying and somewhat brutal fix is to make one channel read and and use another serial port for write... really disappointing but I have wasted so much time on this that it will have to do!
Really nice hardware but...