jefffhaynes / XBee

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

Feature request: new commands or custom command? #27

Closed aderregibus closed 7 years ago

aderregibus commented 7 years ago

Hello Jeff,

Let me start by saying thank you for suck an amazing library. It took me just a few minutes to set up a simple program that would have otherwise taken me days.

Unfortunately I found that there are a few commands missing in the library that I really need for my application. Those commands are: ID, RP, PR, ST, WH, M0 and M1.

I won't expect you to add all of them (although I'll be more than thankful if you did :). But perhaps you could add a method to send a custom command, which would enable the possiblity for anyone to send comamnds that are not supported by specific methods in the library.

What do you think?

Thanks, Agustin.

jefffhaynes commented 7 years ago

I can probably add them. Just might be a few days. Thanks


From: aderregibus notifications@github.com Sent: Wednesday, June 7, 2017 12:34:13 PM To: jefffhaynes/XBee Cc: Subscribed Subject: [jefffhaynes/XBee] Feature request: new commands or custom command? (#27)

Hello Jeff,

Let me start by saying thank you for suck an amazing library. It took me just a few minutes to set up a simple program that would have otherwise taken me days.

Unfortunately I found that there are a few commands missing in the library that I really need for my application. Those commands are: ID, RP, PR, ST, WH, M0 and M1.

I won't expect you to add all of them (although I'll be more than thankful if you did :). But perhaps you could add a method to send a custom command, which would enable the possiblity for anyone to send comamnds that are not supported by specific methods in the library.

What do you think?

Thanks, Agustin.

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

aderregibus commented 7 years ago

Thank you! I'll wait for your news. By the way, I reviewed the commands and I could do just with ID, RP and PR. But I also forgot to ask you for WR command. If I could have those 4, that would be great! Thanks again.

jefffhaynes commented 7 years ago

Try 4.3. I added ID, RP, and PR for now. I can add the rest but I'm in the middle of porting to .NET Standard so I don't want to make too many changes. WR should already be supported as WriteChangesAsync. Let me know if you have any issues.

aderregibus commented 7 years ago

Awesome! I will give them a try and let you know if I encounter any issues. Thanks very much Jeff.

aderregibus commented 7 years ago

Hello Jeff,

I tried the new commands but I'm getting an exception when I use them. All other commands are working fine, so I assume there must be something missing in the new ones.

When calling GetPanIdAsync(), I get the following exception:

_System.NullReferenceException: Object reference not set to an instance of an object. at XBee.Frames.AtCommands.PanIdCommandExt.get_Id() at BinarySerialization.MagicMethods.<>cDisplayClass1_0`2.b__0(Object target) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.RootValueNode.set_Value(Object value) at BinarySerialization.BinarySerializer.Serialize(Stream stream, Object value, Object context) at XBee.FrameSerializer.Serialize(Frame frame) at XBee.SerialConnection.d25.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.XBeeController.d69`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.XBeeController.d731.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.Devices.XBeeSeries2.<GetPanIdAsync>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()_

And when I call SetPanIdAsync() I get:

_XBee.Frames.AtCommandException: AT command failed with status 'InvalidCommand' at _XBee.XBeeController.d_73`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.TaskAwaiter.GetResult() at Configuracion.ConfiguradorIO.d__5.MoveNext()_

Thank you.

jefffhaynes commented 7 years ago

Ok, sorry about that. I'll take a look as soon as possible.


From: aderregibus notifications@github.com Sent: Tuesday, June 13, 2017 10:16:08 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Feature request: new commands or custom command? (#27)

Hello Jeff,

I tried the new commands but I'm getting an exception when I use them. All other commands are working fine, so I assume there must be something missing in the new ones.

When calling GetPanIdAsync(), I get the following exception:

System.NullReferenceException: Object reference not set to an instance of an object. at XBee.Frames.AtCommands.PanIdCommandExt.get_Id() at BinarySerialization.MagicMethods.<>cDisplayClass1_02.b__0(Object target) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value) at BinarySerialization.Graph.ValueGraph.RootValueNode.set_Value(Object value) at BinarySerialization.BinarySerializer.Serialize(Stream stream, Object value, Object context) at XBee.FrameSerializer.Serialize(Frame frame) at XBee.SerialConnection.d25.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.XBeeController.d691.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.XBeeController.d731.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.Devices.XBeeSeries2.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()

And when I call SetPanIdAsync() I get:

XBee.Frames.AtCommandException: AT command failed with status 'InvalidCommand' at XBee.XBeeController.d73`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.TaskAwaiter.GetResult() at Configuracion.ConfiguradorIO.d5.MoveNext()

Thank you.

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

jefffhaynes commented 7 years ago

Wow, I really botched all that. That's why I get for not testing. Can you try XBee 5.0? If not I'll have to go back and fix in the 4.x branch but I'd prefer to be lazy. 5.0 will force you to do .Net 4.6 (or UWP) if you aren't already so if that isn't an option let me know.

jefffhaynes commented 7 years ago

Any luck with this?

aderregibus commented 7 years ago

Hello Jeff,

Sorry I couldn't reply before. Just today I was able to download the new package. I will access to an XBee module tonight to test the new code. Will let you know then.

I was able to update to XBee 5.0 with .NET 4.6. The only thing that is keeping me from compiling is that OpenAsync and Close methods of XBeeController are no longer available. I checked the sample code on GitHub and it's still using OpenAsync. How is that supposed to work now?

Regards.

jefffhaynes commented 7 years ago

I don't think you need to open now because there is no equivalent Open in UWP and I was trying to maximize interop but I'll look at it.


From: aderregibus notifications@github.com Sent: Tuesday, June 20, 2017 10:09:33 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Feature request: new commands or custom command? (#27)

Hello Jeff,

Sorry I couldn't reply before. Just today I was able to download the new package. I will access to an XBee module tonight to test the new code. Will let you know then.

I was able to update to XBee 5.0 with .NET 4.6. The only thing that is keeping me from compiling is that OpenAsync and Close methods of XBeeController are no longer available. I checked the sample code on GitHub and it's still using OpenAsync. How is that supposed to work now?

Regards.

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

aderregibus commented 7 years ago

Hi Jeff,

Where you able to look at this?

I was unavailable last week, but just now I was able to test and I can't make it work without the "OpenAsync" method.

Mi code is: XBeeController controller = new XBeeController(combo_puertos.Text, 9600); //await controller.OpenAsync(); XBeeSeries2 node = (XBeeSeries2)controller.Local;

Since I had to comment the 2nd line (because OpenAsync is no longer available), I'm getting an exception because controller.Local is null.

I'll wait for your comments.

Regards.

jefffhaynes commented 7 years ago

Sorry, I've been swamped. You're right, there was no way to use the controller with the existing pattern (I was testing with FindAndOpenAsync). Try using 5.1.

aderregibus commented 7 years ago

Hi Jeff,

Just now I was able to test the new commands in version 5.3.1.

I'm getting the following exception when calling GetPanIdAsync:

System.NullReferenceException: Object reference not set to an instance of an object.
   at XBee.Frames.AtCommands.PanIdCommandExt.get_Id()
   at BinarySerialization.MagicMethods.<>c__DisplayClass2_0`2.<MagicFuncHelper>g__Func0(Object target)
   at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value)
   at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value)
   at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value)
   at BinarySerialization.Graph.ValueGraph.ObjectValueNode.set_Value(Object value)
   at BinarySerialization.Graph.ValueGraph.RootValueNode.set_Value(Object value)
   at BinarySerialization.BinarySerializer.Serialize(Stream stream, Object value, Object context)
   at XBee.Core.XBeeControllerBase.<ExecuteAsync>d__78.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__71`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.<ExecuteAtQueryAsync>d__75`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.<ExecuteAtQueryAsync>d__74`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.Devices.XBeeSeries2.<GetPanIdAsync>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.TaskAwaiter`1.GetResult()

An exception is also thrown when calling all other methods that I requested in this issue, both for GET and SET.

Can you take a look at it? Thanks!

Regards.

jefffhaynes commented 7 years ago

Fixed in 5.3.2/1.4.2 Core

aderregibus commented 7 years ago

I'm afraid it's still not fixed.

Using 5.3.4/1.4.4 Core I'm getting the following exception when calling GetPanIdAsync:

System.NullReferenceException: Object reference not set to an instance of an object.
   at XBee.Devices.XBeeSeries2.<GetPanIdAsync>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.TaskAwaiter`1.GetResult()

And the following exception when calling SetPanIdAsync:

XBee.Frames.AtCommandException: AT command failed with status 'InvalidCommand'
   at XBee.Core.XBeeControllerBase.<ExecuteAtQueryAsync>d__75`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.<ExecuteAtQueryAsync>d__74`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.TaskAwaiter.GetResult()

Same with other commands that you added for this issue.

Thank you.

jefffhaynes commented 7 years ago

So I think what I'm starting to run into here is a firmware issue. Thus far I've been using just the hardware version to determine what is supported in the protocol but that's not really correct as it can change based on the firmware version. I may have to make some significant changes to address that. Can you tell me what firmware version you're running?

Thanks

aderregibus commented 7 years ago

Hi Jeff, The module I'm using for testing is an XB24C with firmware version 9000. You are probably right about the fact that same hardware might support different commands depending on the firmware version, but why do you disable the command on the library? If the firmware does not support it, and you send the command, you'll just get an error response from the XBee module (or in the worst case, no response at all, which should result in a timeout). That's easier than having to now beforehand all the commands supported by all the different firmware versions, don't you agree? Regards.

jefffhaynes commented 7 years ago

Not sure I'm following. The issue isn't that I'm disabling the command, the issue is I'm expecting to get something back other than what I was getting. The "ID" command appears to be especially devious since it does change within hardware versions depending on the firmware. Anyway, I've made the changes and it's looking better now but I still need to test it. I ended up adding code to determine the protocol based on the super complex rule set in Digi's library. As far as I know there's no other way to support the ID command.

aderregibus commented 7 years ago

Ok, got it. I thought you were disabling the command. My bad. I will test it as soon as you upload a new version. Please not that I'm getting the same error with SetRssiPwmTimeAsync and SetPullUpResistorConfigurationAsync. Let me know if you need help with the testing. Thanks.

jefffhaynes commented 7 years ago

Pushed in 1.5-beta. Let me know how it works for you.

aderregibus commented 7 years ago

Mixed results. GetPanIdAsync is working now, which wasn't working before. But SetPanIdAsync, SetRssiPwmTimeAsync, SetPullUpResistorConfigurationAsync still throw an exception.

jefffhaynes commented 7 years ago

Ok, thanks


From: aderregibus notifications@github.com Sent: Sunday, August 13, 2017 11:24:36 AM To: jefffhaynes/XBee Cc: Jeff Haynes; State change Subject: Re: [jefffhaynes/XBee] Feature request: new commands or custom command? (#27)

Mixed results. GetPanIdAsync is working now, which wasn't working before. But SetPanIdAsync, SetRssiPwmTimeAsync, SetPullUpResistorConfigurationAsync still throw an exception.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/27#issuecomment-322048473, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR45LPuuNMN6-ILbTO9_LIv7kXI3iks5sXxUzgaJpZM4Ny9_6.

jefffhaynes commented 7 years ago

Pushed 1.5