jefffhaynes/XBee

I'm a beginner, please help

Closed this issue · 10 comments

Hi, I just started with this library. I was running the Tester example using 2 S2C modules with ZigBee firmware. I found the first character of my serial message was always missing. Then I checked the addresses in dataFrame, it looks like the first byte (00) of high part of the 64-bit address is not taken and the first byte of the 16-bit address is added as the last byte of the 64-bit address. Similarly, probably the first character of the serial message is actually used for the field before data, i.e. Receive options? How should I fix this or did I do anything wrong? Thank you for your help.

private static void Main(string[] args)
{
MainAsync();
Console.ReadKey();
_xbee.Dispose();
}
private static async void MainAsync()
{
_xbee = new XBeeController("COM6", 9600);
await _xbee.OpenAsync("COM6", 9600);
_xbee.DataReceived += (sender, eventArgs) => Console.WriteLine("Received {0} bytes", eventArgs.Data.Length);
}

Hi, thanks for the reply. Coordinator is in API mode 1, end device is in transparent mode.

Hm, everything looks correct. Is COM6 a normal serial port? Any chance there's something screwy going on with the driver?

COM6 is the com for the coordinator. Using the same com I can get complete messagen in xctu.

Can you please add this code and see what you get? Depending on what type of program this is, you may need to use Debug instead of Console.

_xbee.FrameMemberSerializing += XbeeOnFrameMemberSerializing;
_xbee.FrameMemberSerialized += XbeeOnFrameMemberSerialized;
_xbee.FrameMemberDeserializing += XbeeOnFrameMemberDeserializing;
_xbee.FrameMemberDeserialized += XbeeOnFrameMemberDeserialized;
private static void XbeeOnFrameMemberSerializing(object sender, MemberSerializingEventArgs e)
{
	Console.CursorLeft = e.Context.Depth * 4;
	Console.WriteLine("S-Start: {0}", e.MemberName);
}

private static void XbeeOnFrameMemberSerialized(object sender, MemberSerializedEventArgs e)
{
	Console.CursorLeft = e.Context.Depth * 4;
	var value = e.Value ?? "null";
	Console.WriteLine("S-End: {0} ({1})", e.MemberName, value);
}

private static void XbeeOnFrameMemberDeserializing(object sender, MemberSerializingEventArgs e)
{
	Console.CursorLeft = e.Context.Depth * 4;
	Console.WriteLine("D-Start: {0}", e.MemberName);
}

private static void XbeeOnFrameMemberDeserialized(object sender, MemberSerializedEventArgs e)
{
	Console.CursorLeft = e.Context.Depth * 4;
	var value = e.Value ?? "null";
	Console.WriteLine("D-End: {0} ({1})", e.MemberName, value);
}

Hi, I tried the code. Here is what appeared in the console. 0 in FrameId should be the starting byte of
the long address. Last byte of long address (DD) should be the first byte of the short address. (E8) in short address should be SourceEndpoint. The number (97) in options is actually the first character of the serial message. It looks like the data package is not divided correctly. There is one byte shifted.

Running
D-Start: StartDelimiter
D-End: StartDelimiter (FrameDelimiter)
D-Start: Length
D-End: Length (25)
D-Start: Payload
D-Start: FrameType
D-End: FrameType (RxIndicatorExplicitExt)
D-Start: Content
D-Start: FrameId
D-End: FrameId (0)
D-Start: Source
D-Start: Value
D-End: Value (1414693511956423645)
D-End: Source (13A20040F63663DD)
D-Start: ShortAddress
D-Start: Value
D-End: Value (58344)
D-End: ShortAddress (E3E8)
D-Start: SourceEndpoint
D-End: SourceEndpoint (232)
D-Start: DestinationEndpoint
D-End: DestinationEndpoint (0)
D-Start: ClusterId
D-End: ClusterId (4545)
D-Start: ProfileId
D-End: ProfileId (1281)
D-Start: Options
D-End: Options (97)
D-Start: Data
D-End: Data (System.Byte[])
D-End: Content (XBee.Frames.RxIndicatorExplicitExtFrame)
D-End: Payload (XBee.FramePayload)
D-Start: Checksum
D-End: Checksum (187)
D-Start: StartDelimiter
Received 6 bytes

Sorry about that, please try 4.2.

It works. Thanks