LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using TCP Send Commands similar to Hyperterminal

Hey everyone,

 

I am making my first program that deals with wireless communication. I am having some issues in understanding how data is transmitted.

 

Here's what I am currently able to do. I can open hyperterminal, directly connect to my device using the IP Address and Port number. Once connected, I see my 'Hello' confirming that I am connected. After being connected, I can send out characters one by one using Hyperterminal. This is perfectly ok for testing, but I want to use LV to make a GUI so that I won't mix up what button commands what.

 

I have attached my VI and I feel like I'm doing something fundamentally wrong. When using Telnet, if I send a '1' I can see its value on the Rx port of my device using an oscilloscope. With my VI, I don't see anything from the oscilloscope until I stop it.

 

I think I am just missing something small. I really appreciate the help.

 

Thanks,

Seth

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

You have a race condition. How do you know whether the read or write happens first? LabVIEW does not execute code top to bottom.

 

You also have not specified any bytes to read.

 

Do you need to append a carriage return to the contents of "data write". Hyperterminal does that for you. When you program the communication yourself, then you are responsible for that.

0 Kudos
Message 2 of 4
(3,173 Views)

Thank you for the quick feedback.

 

Here are the edits that I made. I am now seeing data from the oscilloscope, but it's not what I'm expecting. With how my code is set up, would it send whatever command is in the box every 50ms? Is the delay even necessary? I am really just trying to learn how to send a single character. Once I'm able to do that, I can take it from there.

 

Again, I really appreciate the help!

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

You are performing the read before the write. Please review the concept of dataflow programming in the LabVIEW Help and in the LabVIEW tutorials.

 

Also, you are not appending a carriage return. You are appending the characters "\" and "r". That's not the same as the escaped character of "\r", which means carriage return. If you set the string control to "\" Code Display mode you will see this. When you set the string control to that mode, remove one of the "\" characters and that will give you an escaped "r".

 

If you're going to have a delay it would be between the write and read, right? As you have it right now, the loop is simply executing whatever is inside on every multiple of 50 msec. That's not the same thing. To insert a delay between the write and read you can use the Time Delay function, which has error I/O clusters, allowing you to enforce execution order by way of data dependency.

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