05-03-2016 09:55 AM
Hello ,
I have been communicating ok using VISA serial write/read with a patient monitor and have almost completed getting all the parameters in need from the monitor; however I am now stuck and missing one value that is coded 0x0A.
I googled and found that this is probably the message terminating after this character, also yes I am recieving the first 6 or so bytes.
I subsequently set TermChar Enable to False and ASRL End In to None on the property node for read however it is still missing the extra bytes (after the 0x0A) that I need to calculate the needed pararmeter.
The image attached shows the VISA serial configuration before the outside/before of the first major loop, and then an inner loop where the read occurs. It seems that although I think I am setting the correct parts of the property node, I can not stop the termination character from reading.
Any help here would be appreciated.
Thanks
Solved! Go to Solution.
05-03-2016 10:25 AM
0x0A is a linefeed. Are you sure the message is just truncated? The output, if read normally, would look like two lines, and your code may not be aware of the second line. Try putting an indicator on the output of your read and set the display to hex and see what you get.
And you only have to set those porperties once. No need to set them inside the loop as well. But at that point, I suspect you were just trying to slay the dragon any way you could. 😉
05-03-2016 11:25 AM
There is no need to write to those property nodes at all. You are already disabling the termination character with the Configure Searial Port.
But Bill does have a good point. Make sure you are looking at multiple lines on the output data. That can often mess with certain parts of code.
If you want any more help, you will need to explain the message protocol a lot better and share more of your code.
05-04-2016 05:26 AM
Thanks for the reply!
I will show some code here because I had previously used the false on the termination character and it had worked just fine no lost data, but now I am stumped
The protocol works by sending a command message that initiates a stream of both patient waves (like ECG (EKG) etc) and numeric (like Heart Rate in beat per minute) these are calculated numbers.
When I look at this stream using Realterm in hex I do see everything each line is 0.01 msec (100 Hz).
B5083B2E40114B5C746E - this is a B5 (wave and data message), 08 bytes following, containing 4 waves samples ..3B2E (wave #1), 4011 (wave #2), 4B5C (wave#3), 46 (wave#4), CRC at End (1byte)
B5083B2540114B5C7279 .
B5083B2340114B5C6E7F .
B50D3B2240114B5C6E020000000178 - every 100 samples this is a timing packet.
B50A3B1C40114B5C6A0B611C - this message has the 4 waveforms plus the additional numeric data (sp02 after the 0B symbol), I do recieve these ok (it is 0A length this confuses me because I get all the correct data)
B50B3B1740104B5C6A0A00453E - however I am not recieving this one and although I am recieving the first part of the message (the wave part), I am never seeing the data after the 0A at the end.
B5083B1240114B5C6618
B5083B0D40114B5C6221
B5083B0C40114B5C6222
Attached is my loop that takes the first 2 bytes and looks for B5 it then checks the next byte(ie 08, 0A, 0B) to calculate how many bytes it should grab to select the rest of the message. The loop exits when the message is greater than 3 bytes and the message (sample) is then seperated for each wave or numeric.
Maybe it is on the next line and the extra couple of bytes are waiting to be read, but because the 0A is a read ok prior for one message and not for the next I am confused.
thanks
05-04-2016 07:00 AM - edited 05-04-2016 07:00 AM
I would recommend a setup like this. The idea is to read a byte at a time until the sync byte is found. Then you read the next byte to get the length and then read that many bytes. I recommend using a queue to send the data to another loop for processing.
05-04-2016 06:31 PM
Ok great I will try this and let you know if it works.
I wasnt aware that you could call the serial read multiple times at any point once connected, this is very helpful indeed!
All the best
06-14-2016 05:37 AM
Thank you krossrulz and billko, sorry for the delay in replying but I have another project that took over priority, plus I had never programmed with queues before. I was able to use the producer/consumer loop with your example and it is working well. Cheers again