LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Transmit Work but Can't Receive

Hello All,


I am trying to setup a serial connection in Labview. Having little experience with Labview (I just installed version 6.1), my first instinct was to try out one of the examples. I am using “LabVIEW <-> Serial.vi”, which some of you may already have. Upon request, I can post this VI if necessary. The VI is simple; it configures the serial port, transmits a string specified by the user, receives a specified number of bytes and closes the connection.


I was able to get the transmit part working without any problem. Since I can already communicate with the instrument with HyperTerminal, this was easy to verify. I can write to a register on the instrument using Labview and read it back using HyperTerminal to verify that the data was written correctly. At this point I am assuming that I have the serial connection configured correctly in Labview.


After transmitting the string, the program enters a while loop that checks how many received bytes are available at the port. For some reason, the received bytes never appear (i.e. the output from “Instr – Bytes at Port” is always zero). I have tried playing with the configuration (and even eliminating this loop from the program), but can’t seem to get this to work. The next step in the program is to actually read the bytes from the port, but of course I never get that far because it gets stuck in the loop.


Does anyone have an idea why I can transmit bytes but not receive them? It is probably something really simple that I am missing. I am certain that there should be data received because the device responds to any command that you send to it, even if the command is invalid. I’ve verified this with HyperTerminal; there is always a response.

 


Thanks in advance for any help!

 


-Clint

0 Kudos
Message 1 of 3
(3,101 Views)
Are you termininating the transmit string with a end of line constant?  Maybe the device is still waiting for the transmission to end before responding.  That is what end of line signifies.  To add end of line, concatenate the newline constant (found in strings palette) to the end of the string, or just set the string display to \codes and type in \r\n at the end of the string.  You could also set the display to hex codes and type 0D0A at the end.
- tbob

Inventor of the WORM Global
Message 2 of 3
(3,093 Views)
Problem solved! Thank you so much for your help. I was actually terminating the string with the just \n (0x0A); this was in the configuration for the serial connection. I didn't realize that the complete temination string is \r\n (0X0D0A). After I added the \r everything starting working as expected.

Thanks again!

-Clint
0 Kudos
Message 3 of 3
(3,085 Views)