LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing serial data that includes null characters

Data from a PIC18F6722 microcontroller is sent using the RS-232 interface to a LabWindows routine.  The data are represented as a series of ASCII numeric values separated by commas and spaces.  Unfortunately, the routines used in the PIC18F6722 to write the data also insert several null characters, 0x00, in the stream.  These cause the viScanf parsing routine in LabWindows to stop on each null, and the data are not recovered.
 
Any way to include the null character in the format string to avoid this, or some other trick? 
0 Kudos
Message 1 of 3
(3,220 Views)
I frequently connect to devices that transmit 16-bit measures coded in two bytes. In this environment NUL values are expected on either of two bytes transmitted or even on both of them. A scanf instruction terminates on the first NUL character read, but if I address individual array elements one by one I can read their value and build back the measure transmitted with meas = (array[i] << 😎 + array[i+1]


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 3
(3,207 Views)
Depending on how the PIC terminates the data stream you could replace the null bytes with another value in the input stream in a comcallback routine, or post process the data to remove or replace the null bytes.
0 Kudos
Message 3 of 3
(3,173 Views)