LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ComRdTerm with multiple termination bytes

Solved!
Go to solution

Hi,

I need an UART read function that should read the stream and return when at least two specific characters are received. ComRdTerm has only one termination character. Is there maybe a workaround or method that will get it right?

 

Example:

TermChar: 0x0C 0x0A (in the same order)
Stream: 0x01 0x02 0x0A 0x0B 0x0C 0x0D 0x0F 0x0C 0x0A
                  -no-      -no-                -end-

 

 

0 Kudos
Message 1 of 4
(4,104 Views)

As you can read in the help for the command:

 

If the termination character is a carriage return (CR or decimal 13) or a linefeed (LF or decimal 10), the function handles it as follows:

  • If terminationByte = CR, and if the character immediately following CR is LF, ComRdTerm discards the LF in addition to the CR.
  • If terminationByte = LF, and if the character immediately following LF is CR, ComRdTerm discards the CR in addition to the LF.

 

Does it satisfy your needs?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(4,102 Views)

The stream I receive is not ready when "CR" or "LF" character are received, only "CR + LF".

Example:

0x01 0x00 0x00 0x00 0x0C <- dont stop here 0x00 0x00 0x0A <- dont stop here also 0x00 0x00 0x0C 0x0A <-stop here

ComRdTerm will stop at 0x0C. But its not what I need.

0 Kudos
Message 3 of 4
(4,093 Views)
Solution
Accepted by topic author ts3_SK

In this case ComRdTerm is not your solution: you must read periodically, accumulate in a buffer and handle the buffer. You can read wither with a Com callback triggered for any byte received or with a periodic task such a timer or so.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 4
(4,087 Views)