11-20-2019 07:00 AM
Hello guys,
I need some help. I have a thermometer with two modules, each module has two channels ( four channels total). When i want temperature i have to give him comand (ASCII) but it only work for one module so if i want temperature from both moudels i have to give two diffrent commands. So my problem is that i have to read two diffrent answers. One answer contains two temperatures from one module. (example from one module A01 #04 263 262) A01= first module, #04 = command for temperature of all channles from module, 263 262 = temperatures. In attachment is my failed attempt.
Thank you very much for help.
Jacob
Solved! Go to Solution.
11-20-2019 07:07 AM - edited 11-20-2019 07:15 AM
DON'T USE BYTES AT PORT! It is the wrong thing to use 99% of the time.
The other problem in your VI is that you immediately check bytes at port following the Write. You probably haven't given the device a number time to respond to your message.
Your serial configuration is set for no termination character. Is that true? That makes it harder to know when a message ends. Double check the manual for the communication protocol.
If it used a termination character (such as carriage return or line feed), then set it and read a large number of bytes.
If it does not, does it always send the same number of bytes in a reply? If so, wire that constant in.
If it does not, does it prepend the message with the number of bytes that will follow in the message? If so, read the first bytes, decode the number, and read that many more bytes.
Rather than Write 2 commands in a row, you should write the first command, read it, write the second command, read that.
11-20-2019 07:28 AM
Yes i just checked it there is no termination character in manual.
Okey thank you i will try that.
11-20-2019 08:12 AM
@RavensFan
I triend write the fisrt comand and read then write second comand and read. But it give me Error.
11-20-2019 10:17 AM
@kostijak wrote:
@RavensFan
I triend write the fisrt comand and read then write second comand and read. But it give me Error.
Punchline to a joke: "If it hurts when you do that, then don't do that!" Don't use that node to do your matching. You are parsing binary code, and it's highly likely that you'll encounter null characters.