This project has moved and is read-only. For the latest updates, please go here.

XBeeParseException while receiving from a sensor

Oct 14, 2012 at 10:59 AM
Edited Oct 14, 2012 at 11:00 AM

Hi,

I am trying to read data sent from a sensor and I get the following exception in "private XBeeResponse ParsePacket()" method in "PacketParser.cs":

A first chance exception of type 'NETMF.OpenSource.XBee.Api.XBeeParseException' occurred in XBee.PC.dll
I am able to connect to coordinator and discover the nodes without issue:
        private void DoWork(object arg)
        {
            api = new XBeeApi(new SerialConnection("COM6", 9600));
            
            api.DataReceived += api_DataReceived;
            api.StatusChanged += api_StatusChanged;

            api.Open();
            api.EnableModemStatusEvent();

            api.DiscoverNodes(OnNodeDiscovered);
        }

Oct 14, 2012 at 1:12 PM

Problem solved.

There is a problem in "protected override void ParseFramePayload(IPacketParser parser)" in "IoSampleResponse.cs"

 

for (var pin = Pin.A0; pin <= Pin.A3; pin++)
{
    if (!IsAnalogEnabled(pin))
        continue;

    Analog[(byte)pin] = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
}

 

You have forgotten the "=" in "pin <= Pin.A3", therefore you are missing out some data which is then creating an exception.

Oct 15, 2012 at 9:19 AM

Thank you for reporting the problem and suggesting the solution! Your fix has been pushed to the repo. Please let me know of any other problems you encounter. Maybe you would like to post a sample source code that uses this library. Out codeplex site could use it!