I spoke too soon about my problems being resolved. Now since I can actually send/receive data from the device, I've got a problem receiving data. Got more sample code which works fine in XP, yet on CE the device is getting confused and throwing back error codes saying it didn't understand what it got.
I've tried running DiscardInBuffer() and DiscardOutBuffer() before sending my next command, yet the device still comes back saying it didn't a understand AND then the data I'm after. Sample code:
static public Int32 TemperatureFahrenheit()
{
String data;
Int32 temp = 32;
try
{
Thread.Sleep( SLEEPTIME );
_port.DiscardInBuffer();
_port.DiscardOutBuffer();
_port.WriteLine( THERM_HEADER + "R" + THERM_A_CHN );
data = Read();
if ( data.Length > 0 )
data = data.Replace( THERM_HEADER.ToString(), "" ); //Strip off returned header
temp = Int32.Parse( data );
}
catch (Exception ex)
{
Log.Add( ex.Message );
}
return temp;
}
The Weedtech board uses simple ASCII commands to get/send data. Here is its [url=http://www.weedtech.com/wttci-m.pdf]data sheet[/url]. Anyways, to read a thermocouple you issue a string containing the device's header, R (to READ) and then the channel (i.e. ERA).
Using the code from above, gives the following output below. Notice the
A? is the first thing returned, which means the device didn't understand something on the A header. Yet, I never issued any command to it! The thermocouple board obviously got the proper command, because next is
E85, the data I'm after.
Only way I think it could've gotten a command to the A header is that part of the previous command (ERA) contained an A and somehow the buffers chopped it up sending? But how could that happen since I cleared both in/out buffers before sending my command. Reading through the [url=http://www.weedtech.com/an200.pdf]Host Programming Guidelines[/url], I see each data character cannot have more than 833uS between each. I'm thinking maybe the WinCE emulator is violating this.
[img]http://home.comcast.net/~bsod2600/wttci_1.png[/img]