mkgrier5 Posted June 28, 2011 Share Posted June 28, 2011 I have this data comng in: Rx: &&1310010511062813100106181234131001087992.0131001107992.01310012385.013100124 5.01310011393.71310!!1310 Rx: &&1310010511062813100106181236131001087992.2131001107992.21310012385.013100124 4.01310011393.71310!!1310 Rx: &&1310010511062813100106181238131001087992.2131001107992.21310012385.013100124 5.01310011393.71310!!1310 Rx: &&1310010511062813100106181240131001087992.3131001107992.31310012385.013100124 5.01310011393.71310!!1310 Rx: &&1310010511062813100106181242131001087992.4131001107992.41310012385.013100124 5.01310011393.71310!!1310 I'm trying to read it with this sequence, but it only inputs my data some of the time and then only one at a time. How can I get it to read every line and return the data? global string datain global data while(1) try datain = device.WITS.ReadUntil(10) data = strtodouble(mid(datain,4,10)) switch Case (left(datain,4) == "0110") WITSDepth.AddValue(data) Case (left(datain,4) == "0108") WITSBitDepth.AddValue(data) Case (left(datain,4) == "0113") WITSROP.AddValue(data) Case (left(datain,4) == "0115") WITSHookLoad.AddValue(data) Case (left(datain,4) == "0117") WITSWeightOnBit.AddValue(data) Case (left(datain,4) == "0120") WITSRPM.AddValue(data) Case (left(datain,4) == "0121") WITSPumpPressure.AddValue(data) Case (left(datain,4) == "0123") WITSPump1.AddValue(data) Case (left(datain,4) == "0124") WITSPump2.AddValue(data) endcase device.WITS.write("&&" + chr(13) + chr(10)) device.WITS.write("0140" + format("%04.1f",Gas(0)) + chr(13) + chr(10)) device.WITS.write("0139" + format("%04.1f",Lag_Depth(0)) + chr(13) + chr(10)) device.WITS.write("!!" + chr(13) + chr(10)) catch() endcatch delay(2) endwhile Link to comment Share on other sites More sharing options...
AzeoTech Posted June 29, 2011 Share Posted June 29, 2011 I'm sorry, but the browser strips the backslashes so I can't tell exactly what is ASCII data and what is CRLF's. Can you take a screenshot of the monitor and post that instead of a copy/paste? Link to comment Share on other sites More sharing options...
mkgrier5 Posted June 29, 2011 Author Share Posted June 29, 2011 Here's the screenshot. Thank you for your help. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 29, 2011 Share Posted June 29, 2011 The problem is that you have the CRLF 9 times in a single line and you are outputting each iteration. You need something more like this: global string datain global data while(1) device.WITS.purge() device.WITS.write("&&" + chr(13) + chr(10)) device.WITS.write("0140" + format("%04.1f",Gas(0)) + chr(13) + chr(10)) device.WITS.write("0139" + format("%04.1f",Lag_Depth(0)) + chr(13) + chr(10)) device.WITS.write("!!" + chr(13) + chr(10)) for (private i = 0, i < 9, i++) try datain = device.WITS.ReadUntil(10) data = strtodouble(mid(datain,4,10)) switch Case (left(datain,4) == "0110") WITSDepth.AddValue(data) Case (left(datain,4) == "0108") WITSBitDepth.AddValue(data) Case (left(datain,4) == "0113") WITSROP.AddValue(data) Case (left(datain,4) == "0115") WITSHookLoad.AddValue(data) Case (left(datain,4) == "0117") WITSWeightOnBit.AddValue(data) Case (left(datain,4) == "0120") WITSRPM.AddValue(data) Case (left(datain,4) == "0121") WITSPumpPressure.AddValue(data) Case (left(datain,4) == "0123") WITSPump1.AddValue(data) Case (left(datain,4) == "0124") WITSPump2.AddValue(data) endcase endfor catch() ? strLastError endcatch delay(2) endwhile Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.