12-13-2021 09:21 AM
Hi guys, I want to read an integrated sensor that communicates via I2C protocol with my pc. Before that, just to see if my sensor works properly, I am sending a 'test command' (0x01, 0x05, 0x00, 0x31) according to the datasheet. The sensor should respond with the message (0x01, 0x05, 0x02, 0x55, 0xAA , 0x7D). I have a while loop where i constantly read six bytes from the serial and an event case triggered by a boolean button in order to write the 'test command'. It works, but the problem is that i have to wait almost 10 seconds after my writing command to actually see the sensor response. I tried with coolterm as a serial terminal and the sensor responds immediatly. I hope that you can help me with that. Thank you very much.
12-13-2021 09:44 AM
Without knowing anything about the sensor we can only guess. But, I have a high success rate guessing 😀
It sounds like the device is timing out on its read side because it is expecting some message termination. RTM or use NI SPY to see what cool term is adding and you aren't.
12-13-2021 10:03 AM
That wait time is the default time out.
You can lower the time out, but that doesn't change the fact that you don't know what's going on.
If you get that data, and then press stop, the loop is in it's 2nd iteration, waiting for that time out. The Boolean is already read, so the next (3rd) iteration the loop will stop.