キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Basic Serial Write and Read

Hi,

 

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.

Thanks

0 件の賞賛
メッセージ1/10
10,352件の閲覧回数

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.

Tim
GHSP
0 件の賞賛
メッセージ2/10
10,351件の閲覧回数

Hi,

 

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?

0 件の賞賛
メッセージ3/10
10,349件の閲覧回数

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.

0 件の賞賛
メッセージ4/10
10,338件の閲覧回数

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.

0 件の賞賛
メッセージ5/10
9,874件の閲覧回数

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: https://www.ni.com/en-us/shop/product/autoserial-toolkit.html

Certified LabVIEW Architect (CLA)
0 件の賞賛
メッセージ6/10
9,683件の閲覧回数

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?

0 件の賞賛
メッセージ7/10
8,281件の閲覧回数

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.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 件の賞賛
メッセージ8/10
8,271件の閲覧回数

Since this subject keeps coming up I am going to keep posting this link:

 

VIWeek 2020/Proper way to communicate over serial

========================
=== Engineer Ambiguously ===
========================
メッセージ9/10
8,216件の閲覧回数

Can we just retire the "Simple Serial" example?  It's not simple and it's just a poor example of serial communication.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
メッセージ10/10
8,209件の閲覧回数