dle Posted July 27, 2017 Share Posted July 27, 2017 Hi, I can't make this to work ParseDataIn = Parse(DataIn, -1, Chr(13)) Link to comment Share on other sites More sharing options...
AzeoTech Posted August 1, 2017 Share Posted August 1, 2017 You'll need to be more detailed. What is ParseDataIn? What is DataIn? Assuming Datain is a string variable, what does it contain and are you sure? What does work? Link to comment Share on other sites More sharing options...
dle Posted August 2, 2017 Author Share Posted August 2, 2017 Sorry for the short question. DF receiving several string of text separated by \013 and coming continuously (about 100 bytes each second) into the COM port. For example 123, 023, 486\013865, 424, 486\013x\y\z\013.... If I use readuntil(chr(13)), such as, Private String DataIn = Device.UART.ReadUntil(Chr(13)) ? DataIn I encounter a problem because some of data is hidden thus, ? DataIn does not show the correct value that I seen on the COM monitor. For example, on the COM monitor show 123, 23, 486\013 985, 0, 328\013 .... but the ? DataIn show on the command/alert 123, 23, 486 123, 23, 486 .... If I purge the COM port then I see those value updated. I tried Private String DataIn = Device.UART.Read(0) DataIn = ShowHidden(DataIn) ? DataIn Then ? DataIn show on the command/alert reflect the values I seen on the COM monitor and of course the \013 is included in the string. I tried Private String ParseDataIn = Parse(DataIn, -1, Chr(13)) to separate those packet packets, but it wouldn't work. Link to comment Share on other sites More sharing options...
AzeoTech Posted August 8, 2017 Share Posted August 8, 2017 OK, you have to remember that DAQFactory maintains a reasonable sized buffer on the input that only gets cleared out when it fills or you do purge(). If you don't do purge and your device is continuously streaming traffic, then as soon as the port is initialized (i.e. DAQFactory starts), the buffer will start filling. When you do readuntil() its going to start at the oldest point in the buffer and read forward until it hits a 13 and remove that from the buffer. The next readuntil() does that again. Depending on your script, DAQFactory can probably catch up, but really you don't want old data anyway. Instead its best to do this: device.myDevice.purge() device.myDevice.readuntil(13) // read potential partial packet while(1) try private string datain = device.myDevice.readuntil(13) // do stuff with datain catch() ? strLastError endcatch delay(0.01) endwhile So here I purge the port of all that old data, then I read one line and discard it just in case its a partial line. This would occur if the purge() happened to clear the buffer part way through the device sending the data. Then I get in a loop that constantly reads the buffer. At this point DAQFactory will run faster than the device streams and the buffer will only have the last packet and thus the most recent data. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.