U_Houston Posted April 8, 2009 Share Posted April 8, 2009 Has anyone had luck logging from a device that responds in multiple lines? I can't seem to be able to parse the response. An example of my protocol is below: private string dataout = "DAFxx0001" + chr(13) private string datain if (!LockPort()) ErrorMessage("Unable to lock port") return(NULL) endif try Purge() Write(dataout) DataIn = ReadUntil(13) if (IsEmpty(DataIn)) ErrorMessage("Device Timeout") UnlockPort() return(NULL) endif UnlockPort() delay(0.15) return (StrToDouble(Mid(Datain,0,5))) catch() UnlockPort() endcatch return(NULL) Here is the response from the instrument if I don't have the device config com monitor start a new line on CR/LF: Tx (23:21:31.937): DAFxx000113 Rx (23:21:31.952): OK131068.851310 If I let it start a new line this is what I see: Tx (23:21:03.905): DAFxx000113 Rx (23:21:03.921): OK1310 68.851310 So far I am only getting NaNs. The data I need to parse is 68.85. Thanks for any ideas!! Link to comment Share on other sites More sharing options...
AzeoTech Posted April 9, 2009 Share Posted April 9, 2009 Just do readuntil() twice. Also readuntil(10) not (13) since you have a CRLF pair, not just a CR. You can throw away the result of the first readuntil() call. Link to comment Share on other sites More sharing options...
U_Houston Posted April 9, 2009 Author Share Posted April 9, 2009 Thanks Azeotech, you always come through for us!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.