LabVIEW

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for Search instead for Did you mean:

Basic Serial Write and Read

Basic Serial Write and Read

‎02-06-2012 04:21 PM

I'm trying to send a simple command via serial and receive the response in the form using Basic Serial Write and Read. My command receives the expected response in Putty. The LabVIEW Basic Serial Write and Read works fine on the first try when the external device is freshly powered up, but running it a second time and so on I get no response from the issued command i.e. the string returned is empty.

Also, on the first try which succesfully reads, I receive an "UART1 Assert Error." at the end of my string, which is NOT returned when using Putty.

The goal of this program is eventually to perform a write/read every few seconds and parse the read string, but I probably can't begin until I can get this write/read operation to work.

Any help would be greatly appreciated.

Message 1 of 10 (7,352 Views)

Re: Basic Serial Write and Read

Trusted Enthusiast

‎02-06-2012 04:24 PM

Can you post your code?

I would expect that you are not closing or are closing a reference that need to stay open or need to be closed. Posting your code would allow for easier troubleshooting.

Message 2 of 10 (7,351 Views)

Re: Basic Serial Write and Read

‎02-06-2012 04:31 PM

I will attach the .vi, but it it can also be found in the LabVIEW examples as "Basic Serial Write and Read.vi" The vi does close the session to the port, and I understand that if I was attempting a sequence of write/read operations I most likely wouldn't want to close it after every write/read operation, but as of now when I stop the program and then re-start it I can not duplicate the results from the first try.

I am under the assumption that each time I start the program the port is re-opened?

Message 3 of 10 (7,349 Views)

Re: Basic Serial Write and Read

‎02-06-2012 05:43 PM

Ok, I figured it out. Seems there was a line feed and return character after my command in the code view, looks like those two commands in a row were being taken as instantaneous commands? Bogging down the UART in the external device.

Message 4 of 10 (7,338 Views)

Re: Basic Serial Write and Read

‎10-21-2015 09:47 AM

Hi Put While loop after visa configure vi from before close vi ,and but stop switch in the whille loop,then give different commands while running condinious vi,after complite your test commands then use stop switch for stop vi.

Message 5 of 10 (6,874 Views)

Re: Basic Serial Write and Read

‎10-27-2016 05:12 PM

We have developed a package on the LabVIEW Tools Network to automate serial port interactions. You can use it to replicate what you manually do using Putty in LabVIEW for serial devices such as responding to login prompts , entering commands, waiting for a response and returning it. You can find out more about it and download a 30-day free trial at: http://sine.ni.com/nips/cds/view/p/lang/en/nid/214248

Certified LabVIEW Architect (CLA) Message 6 of 10 (6,683 Views)

Re: Basic Serial Write and Read

‎08-14-2021 05:16 AM

I want to send $PASHS,NME,POS,1 command to GPS module and read the corresponding respose from it. How an I do it? I attached the code that I have done. But I didnt get respose. What is the mistake? Plz help?

Message 7 of 10 (5,281 Views)

Re: Basic Serial Write and Read

Knight of NI

rolfk

Knight of NI

‎08-14-2021 02:42 PM - edited ‎08-14-2021 02:48 PM

Well, a simple typo.

You set the string constant to show backslash codes and likely wanted to send " $PASHS,NME,POS,1\n" but what you are actually sending is "$PASHS,NME,POS,1/n".

That's quite a difference. The first sends the new line character (since the constant is set to display backslash codes), the second simple sends the two characters '/' and 'n', which makes the device think "Huuuh. "

And please forget the Bytes at Serial Port property node. It is in 99.99% of the cases the wrong thing to use, and in this case very certainly, since your messages use a termination character and the Serial Port Init already enables this termination character handling. Simply wire a Character to Read constant to the VISA Read that is longer than the longest expected string and then you can also remove the Delay node completely.