LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use ethernet port on sbRIO to communicate with another device

Solved!
Go to solution
Solution
Accepted by XM43

I have no idea what the device you are communicating with expects in terms of its commands but one thing that could be an issue is that you are using the end-of-line constant and that will return the platform specific EOL. On Linux this will be a single line feed ('\n') and on Windows it will be a carriage return line feed ('\r\n'). Your device may be looking for a carriage return/line feed combination and since it is not seeing it is not responding to the request. Another issue may be the IP address of your device. It looks like a Microsoft's Automatic Private IP address (169.254.x.x) and depending on how your sbRIO is configured and your general network topology you may not have a route to your device. The standard TCP VIs work perfectly fine on a sbRIO. I have a distributed system that runs 24/7/365 that is communicating with multiple devices over the network. In general, I don't see anything fundamentally wrong with your code. It should work if you have the correct IP addresses and the properly formatted commands.

 

Depending on your device's protocol you will want to modify how you read data. If it is using a protocol that uses a termination character you shoudl use that for completing your reads. Hopefully it uses a carriage return/line feed because the TCP Read has a mode for that. If your protocol uses a different termination character you will need to handle your reads a little differently. If you have random sized responses with no termination characters you need to use a different approach for reading data. A method I hav eused quite extensively is to have a TCP Read to read a single character with desired timeout. Once a character is read I read large blocks of data (size would be dependent on the largest size response you could receive) with a small timeout. I generally use 50 ms. Here you would read and concatenate your data until you get a timeout (error code 56). Clear that error because this is expected. Any other error gets passed on. Return the block of data you received as your response for processing.

 

Without knowing your specific device's protocol there isn't much else I can say.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 11 of 13
(715 Views)

Hi,

 

Marks analysis also is true for your VISA implementation and confirms my suspicion that your problems arise from the differences between Windows and Linux.

 

Telnets uses \r\n as its termination character(s), so that is the reason where your current code fails (see Marks reply).

 

Regards, Jens

Kudos are welcome...
Message 12 of 13
(705 Views)

Hi Mark,

 

Thank you for responding to my post.


On Linux this will be a single line feed ('\n') and on Windows it will be a carriage return line feed ('\r\n'). Your device may be looking for a carriage return/line feed combination and since it is not seeing it is not responding to the request.

This was the main issue as JensG69 also suspected. Now the drive is responding as expected. Also, yes, TCP/IP VI works on RT as GerdW indicated.

 

Your suggestion on read end condition also works the best in my case.

 

Once again, thanks a lot. All of you actually.

 

Best Regards

0 Kudos
Message 13 of 13
(692 Views)