NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Linux Serial Port Issues with RS422 on NI-9871

Solved!
Go to solution

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?

0 Kudos
Message 1 of 4
(3,349 Views)

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?

0 Kudos
Message 2 of 4
(3,327 Views)
Solution
Accepted by topic author forbin

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);

0 Kudos
Message 3 of 4
(3,305 Views)

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...

0 Kudos
Message 4 of 4
(3,270 Views)