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.
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.
03-21-2019 03:01 AM
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,
Solved! Go to Solution.
03-21-2019 03:33 AM
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.
03-21-2019 04:30 AM
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.
03-21-2019 05:06 AM - edited 03-21-2019 05:07 AM
@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.
03-21-2019 05:16 AM
@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.
03-22-2019 04:08 AM
03-22-2019 05:01 AM
If you explain what was wrong, it could be useful to others having the same trouble