jefffhaynes / XBee

A .NET library for XBee wireless controllers
MIT License
40 stars 17 forks source link

Error in FindControllersAsync #50

Closed scervellera closed 6 years ago

scervellera commented 6 years ago

Hello Jeff, I have upgraded my version from 1.5.10 to 1.6.1.

I have very often an error in XBeeController.FindControllersAsync

{System.IO.InvalidDataException: Found invalid data while decoding. at XBee.AtCommandWriter.<WriteAsync>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.<SetApiModeAsync>d__85.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.<InitializeAsync>d__84.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.<ExecuteAsync>d__83.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.<ExecuteQueryAsync>d__761.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d80`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d73.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Universal.XBeeController.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Universal.XBeeController.d1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at IT.ITSellingSolution.OmniGreenMaster.XbeeHubNs.XBeeHub.d__89.MoveNext()}

`

I don't have this kind of error in 1.5.10 and I don't have made any changes to code.

jefffhaynes commented 6 years ago

Hm, that's a result of the API mode auto-configure from 1.6 not working. Can you please try 1.6.2-beta and post the exception if it happens again? I've added more debug info to the exception message. Thanks.

On Wed, Apr 18, 2018 at 11:11 AM, scervellera notifications@github.com wrote:

Hello Jeff, I have upgrade my version from 1.5.10 to 1.6.1.

I have very often an error in XBeeController.FindControllersAsync

{System.IO.InvalidDataException: Found invalid data while decoding. at XBee.AtCommandWriter.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime. CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d85.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d84.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d83.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d__761.MoveNext() --- End of stack trace from previous location where exception was thrown

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d801.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime. CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d73.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Universal.XBeeController.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Universal.XBeeController.d1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime. CompilerServices.TaskAwaiter1.GetResult() at IT.ITSellingSolution.OmniGreenMaster.XbeeHubNs. XBeeHub.d__89.MoveNext()}

`

I don't have this kind of error in 1.5.10 and I don't have made any changes to code.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jefffhaynes/XBee/issues/50, or mute the thread https://github.com/notifications/unsubscribe-auth/AJSKRzT5nY1i6bsDz8w9Nwr2dVFZMLUCks5tp1e5gaJpZM4TaQR_ .

-- If you want to build a ship, don't drum up people together to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea.

Antoine de Saint-Exupery

ilcearini commented 6 years ago

Hello, i was having the same problem with 1.6.1, tried 1.6.2-beta, and here it is the new error.

System.IO.InvalidDataException

System.IO.InvalidDataException: Expected OK but received System.Byte[] at XBee.AtCommandWriter.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d85.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d84.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d83.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d76`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.d801.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Core.XBeeControllerBase.<GetHardwareVersionAsync>d__73.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Universal.XBeeController.<TryGetControllerAsync>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at XBee.Universal.XBeeController.<FindControllersAsync>d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at IT.ITSellingSolution.OmniGreenMaster.XbeeHubNs.XBeeHub.d__89.MoveNext()

ilcearini commented 6 years ago

Hello, i forgot to specify some informations: -i'm working on a raspberry in UWP -the xbee connected to the raspberry is the coordinator

Anyway, i downloaded the sources so i can make more tests.

The problem is in SetApiModeAsync when you try to send : await writer.WriteAsync("+++").ConfigureAwait(false);

The response is AckResponse, only if xbee network is not established. In other case (a standard for our application) we don't have a AckResponse, but the 3 bytes that i always find in the response are : 126,0,35

jefffhaynes commented 6 years ago

Interesting. I’m not sure what would cause that. Let me spend more time on it.

If you get a chance can you try issuing “+++” from a serial terminal or X-CTU and see what you get?

Thanks


From: Daniele ilcea Cearini notifications@github.com Sent: Thursday, April 19, 2018 8:11:11 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Error in FindControllersAsync (#50)

Hello, i forgot to specify some informations: -i'm working on a raspberry in UWP -the xbee connected to the raspberry is the coordinator

Anyway, i downloaded the sources so i can make more tests.

The problem is in SetApiModeAsync when you try to send : await writer.WriteAsync("+++").ConfigureAwait(false);

The response is AckResponse, only if xbee network is not established. In other case (a standard for our application) we don't have a AckResponse, but the 3 bytes that i always find in the response are : 126,0,35

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/50#issuecomment-382710857, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR0VejHLZ2DOsE6hLWcQhlSN5RCORks5tqH7fgaJpZM4TaQR_.

ilcearini commented 6 years ago

ok, tried from Tera-Term sotware. when i send +++, i always have OK as response. but when i receive a message from another xbee, the OK response is at the end of the message (see screenshot).

cattura

I think that is necessary to clean the already receveid messages on the serialdevice, or wait for any Ok response bytes in the stream.

jefffhaynes commented 6 years ago

Ah, of course. Ok, thank you.


From: Daniele ilcea Cearini notifications@github.com Sent: Friday, April 20, 2018 4:57:41 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Error in FindControllersAsync (#50)

ok, tried from Tera-Term sotware. when i send +++, i always have OK as response. but when i receive a message from another xbee, the OK response is at the end of the message (see screenshot).

[cattura]https://user-images.githubusercontent.com/12558892/39041219-a751a0a0-4488-11e8-8431-55cde1f91646.PNG

I think that is necessary to clean the already receveid messages on the serialdevice, or wait for any Ok response bytes in the stream.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/50#issuecomment-383032514, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR52FAm8SAqvc3CSoLCveQ7uaLtsfks5tqaMFgaJpZM4TaQR_.

jefffhaynes commented 6 years ago

Can you please try 1.6.2-beta3 and see if it works better for you? Thanks

ilcearini commented 6 years ago

it works. I tryed to start the app several times, and i've never had the error.

Thanks you!!

jefffhaynes commented 6 years ago

Great, glad to hear it


From: Daniele ilcea Cearini notifications@github.com Sent: Monday, April 23, 2018 5:01:06 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Error in FindControllersAsync (#50)

it works. I tryed to start the app several times, and i've never had the error.

Thanks you!!

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/50#issuecomment-383504961, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR3FuGztby6G6GQi9UN-K-P6cUWK4ks5trZhSgaJpZM4TaQR_.