I am porting my Domotica windows service application from a net book to the Cobra.
Until now I succeeded to overcome the big thinking into them small thinking for NETMF. So I have a X10 power line I/F, tcp/ip webcam support taking pictures in case of alarm from a door sensor or PIR sensor, control of lights, heating, curtains, sun screens, a c# alike scripting parser and a scheduler and mail service. The Cobra is a tcp server and I have a windows client for configuration and remote control. So far so good but for the RF 434 communication, receiving Oregon weather sensors, X10 RF… I have an USB RFXCOM receiver. Inside the receiver is an FTDI USB chip and this is recognized by the FEZ.
For reading I start a Thread with HandleUSBComm. The RFXCOM is sending blocks of binary data and the first byte is the length. No protocol.
When I do this on my Domino it works fine but on the Cobra I am missing data starting with eg 220240 hex and I start receiving package of 8 bytes with 3810 3820 coming from no ware ( fyi start with 60 and 50 is an Oregon weather station)
605A6D008B34216045A3C15ECB
605A6D008B34216045A3C15ECB
3810000000000000
501A2D1060312210662CEE
501A2D1060312210662CEE
3820000000000000
3800010000000000
3808000000000000
3802000000000000
3800080000000000
3802000000000000
3808000000000000
3802000000000000
3800020000000000
38FE000000000000
38007E0000000000
3800010000000000
3820000000000000
38007E0000000000
3840000000000000
501A2D1060312220662DD1
First thought was it is recognizes 2202 as an escape sequence or something but why?
Does anyone have an idea?
private void HandleUSBComm()
{
try
{
// Event for receiving data
int erc = 0;
int bytesRead = 0;
byte[] buffer = new byte[256];
while (true)
{
bytesRead = m_SerialUSB.Read(buffer, 0, 256);
if (bytesRead == 0)
{
Thread.Sleep(500);
}
else
{
Debug.Print(buffer.ByteToHex(bytesRead));
for (int i = 0; i < bytesRead; i++)
{
erc = ProcessReceivedChar(buffer[i]);
}
// Checksum error or conversion error
//if (erc == 2 || erc == 3)
//{
// // Clear buffer
// break;
//}
}
}
}
catch (Exception ex)
{
TraceLog.WriteLine(m_Tag, ex);
DisconnectUSB();
}
}