From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send command to external device

Solved!
Go to solution

Hi all,

The goal is to communicate with "external device" which is a TV decoder.
I have commands to send and I want him to answer me so the difficulty is that when I send a comment for example FLASH_Read CIE_SN as it is indicated in the capture.it displays me in Visa read the same expression i.e. it sends me FLASH_Read CIE_SN out that I want it to give me the value of CIE_SN.

Pleaase I need your help.

regards,

 

 

Download All
0 Kudos
Message 1 of 7
(2,608 Views)

This could be anything from "the device is echoing as expected" to "you've made a loop back in the HW".

 

Are you sure the echo is coming from the device? If you still get the echo when the device is turn off or disconnected, you'd narrowed down the problem.

 

If the device sends the echo, it's a problem in the device, and that would probably mean you need to read the manual 2-12 times.

 

BTW: remove those waits from the code. Use the build in time outs of the functions instead. Drivers that wait idly are a pain to use on higher level. You want them to be as fast as possible.

0 Kudos
Message 2 of 7
(2,602 Views)

Hi wiebe@CARYA,

when the device is disconnected I can't even execute the code.

The problem is how to send a command to an external device get answer .I think I have a mistake in read buffer??

it considered the command as string that's why it displyas like that.

0 Kudos
Message 3 of 7
(2,582 Views)

@fez123456  ha scritto:

Hi wiebe@CARYA,

when the device is disconnected I can't even execute the code.

Why? Obviously you can, of course getting errors.

Does the serial is RS232 or RS485? If it's RS485, it may be normal to receive the echo. Try to read two times.

However, you should remove the wait and the Bytes at Port node. Wire a large number to byte count (bigger that the length of the answer you expect).

You current code is anyway flawed, because you are reading the number of bytes present in the receive buffer 5 seconds before reading.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 7
(2,570 Views)
Solution
Accepted by topic author fez123456

@pincpanter wrote:

@fez123456  ha scritto:

Hi wiebe@CARYA,

when the device is disconnected I can't even execute the code.

Why? Obviously you can, of course getting errors.

Does the serial is RS232 or RS485? If it's RS485, it may be normal to receive the echo. Try to read two times.

However, you should remove the wait and the Bytes at Port node. Wire a large number to byte count (bigger that the length of the answer you expect).

You current code is anyway flawed, because you are reading the number of bytes present in the receive buffer 5 seconds before reading.


One should not read bytes at port at all. If there's no absolute requirement (there almost never is), don't use it.

 

In your situation, it seems all communication is line end terminated. At least, that's how you're setting things up. That means, read more bytes then needed, make the time out large enough, and don't wait before reading. Let the read do the work for you.

 

If the device is echoing, it's probably a feature. It might even be optional. Or a sign of an error. Read the manual. And indeed reading the port twice after a write sounds like something to try.

0 Kudos
Message 5 of 7
(2,565 Views)

Hi @pincpanter

Thank you very much

 

0 Kudos
Message 6 of 7
(2,532 Views)

If you explain what was wrong, it could be useful to others having the same trouble

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 7 of 7
(2,523 Views)