CraigTerris Posted May 2, 2011 Share Posted May 2, 2011 Null serial data is streaming through the Com. Monitor as below. I need to display the variable values Dn={everything up to the next comma}, Sm={up to the comma} and Sx={up to the comma} as three different values Dn=wind direction, Sm=Nominal wind speed, Sx=Maximum wind speed, all from a Vaisala wind instrument. There are a few examples I have read, but I still can't quite get my head around it. These values will be displayed individually and Sx= will trigger an email alert can you give me a few pointers please. Rx: 0R5,Th=15.3C,Vh=0.0#,Vs=14.1V,Vr=3.504V130010 Rx: 0R1,Dn=255D,Dm=255D,Dx=255D,Sn=4.6N,Sm=4.8N,Sx=5.0N130010 Rx: 0R1,Dn=254D,Dm=255D,Dx=255D,Sn=4.7N,Sm=4.8N,Sx=4.9N130010 Rx: 0R1,Dn=253D,Dm=254D,Dx=255D,Sn=4.5N,Sm=4.7N,Sx=4.9N130010 Rx: 0R5,Th=15.2C,Vh=0.0#,Vs=14.0V,Vr=3.506V130010 Rx: 0R1,Dn=251D,Dm=252D,Dx=253D,Sn=4.4N,Sm=4.7N,Sx=4.9N130010 Rx: 0R1,Dn=250D,Dm=251D,Dx=252D,Sn=4.5N,Sm=4.6N,Sx=4.8N130010 Rx: 0R5,Th=15.7C,Vh=0.0#,Vs=14.0V,Vr=3.506V130010 Link to comment Share on other sites More sharing options...
AzeoTech Posted May 3, 2011 Share Posted May 3, 2011 First, there isn't any "null" serial data. Its actually just an ASCII stream. But that's just semantics I'm not sure where you are getting stuck. I'm assuming in the parsing. The easiest way to parse things of the general "x=9999" nature is to parse on the equal sign then let the strtodouble() function strip the units off. So, assuming you have a string variable named "datain" with the Rx string, you'd do something like: private string parsedData = parse(datain, -1, "=") With -1 it will return an array of strings. So, if datain had: 0R1,Dn=254D,Dm=255D,Dx=255D,Sn=4.7N,Sm=4.8N,Sx=4.9N you'd get: {"0R1,Dn", "254D,Dm", "255D,Dx", "255D,Sn", "4.7N,Sm", "4.8N,Sx", "4.9N130010"} So, parseData[1] = "245D,Dm" which is the Dn value, so Dn = strToDouble(parseData[1]) Then you can just use addvalue() on a channel to add the result: Dn.AddValue(strToDouble(parseData[1])) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.