LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP communication with Omega embedded ethernet controller -- sending a command to read

Solved!
Go to solution

I am trying to write a program that reads data from my Omega controller (CNiS16D22-C4EI), graphs it, and saves the data in a file. The controller is measuring displacement from a position sensor and I connected it through TCP/IP communications to my computer. I have a working Python program that sends a command to the controller to read data, and reads the data that the device responds with. I'll copy the Python program at the end of this post. 

 

I created a Labview program to read the data I need. However, instead of reading the data, it is showing an error message "Serial Time Out" in the TCP read output. When I run this on Python, I get data and I don't get the error message "Serial Time out." I'm using the same port, IP address, and sending the exact same command on both programs, so does anyone have any idea why I am getting a different output? Is there a specific format that the TCP Write command has to be in? Currently, as you can see in the picture, the command I am sending is "*01X01\r" which is the raw read command that works on the Python program.  Please let me know if I can clarify anything.

 

 

Screenshot of block diagram and front panelScreenshot of block diagram and front panel

Python program:

import socket

iSeriesIP = "172.16.99.100"
iSeriesPORT = 1000
command="*01X01\r"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(3) # 3 second timeout on commands
s.connect((iSeriesIP, iSeriesPORT))
s.sendall(command)

data = s.recv(100) 
print "received message: "+ data

s.close()

0 Kudos
Message 1 of 3
(2,963 Views)
Solution
Accepted by topic author sofiafernandez

It may be the line feed - LabVIEW escapes the '\r' with an additional '\'. Right click on the command input, and select 'Codes Display' and you will see an extra '\' may have been inserted in the string. Remove it, or remove the line feed from the command string all together, and append it on the code if every message has one at the end of the command.

Message 2 of 3
(2,943 Views)

Thank you so much, this was the problem. I switched to Code Display and it is working now!

0 Kudos
Message 3 of 3
(2,938 Views)