LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication problem, TermChar Enable to False and ASRL End In to None does not stop 0x0A termination character

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(3,878 Views)

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.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 2 of 7
(3,866 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 7
(3,847 Views)

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

 

 

 

0 Kudos
Message 4 of 7
(3,765 Views)
Solution
Accepted by topic author kevyn5

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(3,759 Views)

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

 

0 Kudos
Message 6 of 7
(3,738 Views)

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

0 Kudos
Message 7 of 7
(3,569 Views)