jefffhaynes / XBee

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

XBeeNode.SampleReceived Handler not called. Continued #36

Closed PaulNoto closed 6 years ago

PaulNoto commented 6 years ago

Hope you don't mind, I wanted to start a fresh Issue, because the other one had gotten to lengthy.

Anyway, my way of initializing the XBeeNode.SampleReceived handler still doesn't work. However, I made a test, adapting your DiscoverNetwork example and it works.

I did find 2 Issues:

1) args.Name is missing the first character of the Name for all nodes found.

2) DiscoverNetworkAsync does not discover Sleeping Nodes, which is to be expected because they are asleep. That is why I developed a reactive system that adds nodes when they send a sample for the first time.

Now I'm back to my original problem. I remember you said you tried my code on your machine and it worked. I am lost at this point. You just suggested that it might be a difference in the way we are creating nodes, but you ran my code on your system and it was calling the Node_SampleReceived Handler.

Anyway, I have made something that does work, and it is always good to know that everything can work. However, it won't work for what I need, because of the sleeping nodes. Any suggestions would be greatly appreciated. Thanks, Paul.


THIS CODE WORKS to call the Node_SampleReceived Handler

using System; using System.Windows; using XBee;

namespace WpfApp2 { ///

/// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private XBeeController controller = null;

    public MainWindow() {
        InitializeComponent();
        controller = new XBeeController();

        controller.NodeDiscovered += NodeDiscovered;

        Await_DiscoverController();
    }

    //----------------------------------------------------------

    private async void Await_DiscoverController() {
        try {
            await controller.OpenAsync( "COM3", 115200 );
            // NOTE: DiscoverNetworkAsync does not discover Sleeping Nodes  < < < < < < < < < < < <
            await controller.DiscoverNetworkAsync();
        }
        catch ( Exception e ) {
            string s = e.Message;
        }
    }

    //----------------------------------------------------------

    private void NodeDiscovered( object sender, NodeDiscoveredEventArgs args ) {
    // NOTE: args.Name is missing the first character of the Name for all nodes found  < < < < < < < < < < < <
    string s = args.Name;
        if ( args.Node.Address.LongAddress.Value == 0x0013A20040F4F731 ) {
            args.Node.SampleReceived += Node_SampleReceived;
        }
    }

    //---------------------------------------------------------------------------

    private int _sampleReceived_Cntr = 0;
    private void Node_SampleReceived( object sender, SampleReceivedEventArgs e ) {
        _sampleReceived_Cntr++;
    }

}

}

jefffhaynes commented 6 years ago

Not a difference in the way we're creating nodes, a difference in the way the hardware is configured. Can you use X-CTU to export your node configuration?


From: PaulNoto notifications@github.com Sent: Sunday, September 10, 2017 3:16:41 PM To: jefffhaynes/XBee Cc: Subscribed Subject: [jefffhaynes/XBee] XBeeNode.SampleReceived Handler not called. Continued (#36)

Hope you don't mind, I wanted to start a fresh Issue, because the other one had gotten to lengthy.

Anyway, my way of initializing the XBeeNode.SampleReceived handler still doesn't work. However, I made a test, adapting your DiscoverNetwork example and it works.

I did find 2 Issues:

1https://github.com/jefffhaynes/XBee/issues/1) args.Name is missing the first character of the Name for all nodes found.

2https://github.com/jefffhaynes/XBee/issues/2) DiscoverNetworkAsync does not discover Sleeping Nodes, which is to be expected because they are asleep. That is why I developed a reactive system that adds nodes when they send a sample for the first time.

Now I'm back to my original problem. I remember you said you tried my code on your machine and it worked. I am lost at this point. You just suggested that it might be a difference in the way we are creating nodes, but you ran my code on your system and it was calling the Node_SampleReceived Handler.

Anyway, I have made something that does work, and it is always good to know that everything can work. However, it won't work for what I need, because of the sleeping nodes. Any suggestions would be greatly appreciated. Thanks, Paul.


THIS CODE WORKS to call the Node_SampleReceived Handler

using System; using System.Windows; using XBee;

namespace WpfApp2 { ///

/// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private XBeeController controller = null;

    public MainWindow() {
            InitializeComponent();
            controller = new XBeeController();

            controller.NodeDiscovered += NodeDiscovered;

            Await_DiscoverController();
    }

    //----------------------------------------------------------

    private async void Await_DiscoverController() {
            try {
                    await controller.OpenAsync( "COM3", 115200 );
                    // NOTE: DiscoverNetworkAsync does not discover Sleeping Nodes  < < < < < < < < < < < <
                    await controller.DiscoverNetworkAsync();
            }
            catch ( Exception e ) {
                    string s = e.Message;
            }
    }

    //----------------------------------------------------------

    private void NodeDiscovered( object sender, NodeDiscoveredEventArgs args ) {
    // NOTE: args.Name is missing the first character of the Name for all nodes found  < < < < < < < < < < < <
    string s = args.Name;
            if ( args.Node.Address.LongAddress.Value == 0x0013A20040F4F731 ) {
                    args.Node.SampleReceived += Node_SampleReceived;
            }
    }

    //---------------------------------------------------------------------------

    private int _sampleReceived_Cntr = 0;
    private void Node_SampleReceived( object sender, SampleReceivedEventArgs e ) {
            _sampleReceived_Cntr++;
    }

}

}

— 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/36, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKRwJ1F7IY_M54HcDnhhCEICegX06Xks5shDWZgaJpZM4PSa6t.

PaulNoto commented 6 years ago

Sorry, I misunderstood.

I assume you mean the profile.xml files. When I try to add them here, I get an error of: We don't support that file type. Is there another way to export from XCTU or another way to attach these xml files?

PaulNoto commented 6 years ago

Attached are the configuration for my Coordinator and 1 of the Routers.

From: Jeff Haynes [mailto:notifications@github.com] Sent: Sunday, September 10, 2017 1:00 PM To: jefffhaynes/XBee Cc: PaulNoto; Author Subject: Re: [jefffhaynes/XBee] XBeeNode.SampleReceived Handler not called. Continued (#36)

Not a difference in the way we're creating nodes, a difference in the way the hardware is configured. Can you use X-CTU to export your node configuration?


From: PaulNoto notifications@github.com Sent: Sunday, September 10, 2017 3:16:41 PM To: jefffhaynes/XBee Cc: Subscribed Subject: [jefffhaynes/XBee] XBeeNode.SampleReceived Handler not called. Continued (#36)

Hope you don't mind, I wanted to start a fresh Issue, because the other one had gotten to lengthy.

Anyway, my way of initializing the XBeeNode.SampleReceived handler still doesn't work. However, I made a test, adapting your DiscoverNetwork example and it works.

I did find 2 Issues:

1https://github.com/jefffhaynes/XBee/issues/1) args.Name is missing the first character of the Name for all nodes found.

2https://github.com/jefffhaynes/XBee/issues/2) DiscoverNetworkAsync does not discover Sleeping Nodes, which is to be expected because they are asleep. That is why I developed a reactive system that adds nodes when they send a sample for the first time.

Now I'm back to my original problem. I remember you said you tried my code on your machine and it worked. I am lost at this point. You just suggested that it might be a difference in the way we are creating nodes, but you ran my code on your system and it was calling the Node_SampleReceived Handler.

Anyway, I have made something that does work, and it is always good to know that everything can work. However, it won't work for what I need, because of the sleeping nodes. Any suggestions would be greatly appreciated. Thanks, Paul.


THIS CODE WORKS to call the Node_SampleReceived Handler

using System; using System.Windows; using XBee;

namespace WpfApp2 { ///

/// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private XBeeController controller = null;

public MainWindow() { InitializeComponent(); controller = new XBeeController();

controller.NodeDiscovered += NodeDiscovered;

Await_DiscoverController(); }

//----------------------------------------------------------

private async void Await_DiscoverController() { try { await controller.OpenAsync( "COM3", 115200 ); // NOTE: DiscoverNetworkAsync does not discover Sleeping Nodes < < < < < < < < < < < < await controller.DiscoverNetworkAsync(); } catch ( Exception e ) { string s = e.Message; } }

//----------------------------------------------------------

private void NodeDiscovered( object sender, NodeDiscoveredEventArgs args ) { // NOTE: args.Name is missing the first character of the Name for all nodes found < < < < < < < < < < < < string s = args.Name; if ( args.Node.Address.LongAddress.Value == 0x0013A20040F4F731 ) { args.Node.SampleReceived += Node_SampleReceived; } }

//---------------------------------------------------------------------------

private int _sampleReceived_Cntr = 0; private void Node_SampleReceived( object sender, SampleReceivedEventArgs e ) { _sampleReceived_Cntr++; }

}

}

— 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/36, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKRwJ1F7IY_M54HcDnhhCEICegX06Xks5shDWZgaJpZM4PSa6t.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jefffhaynes/XBee/issues/36#issuecomment-328367752 , or mute the thread https://github.com/notifications/unsubscribe-auth/ARrLxKvCjXkMMhykPA-f1a2N7kjbAl4nks5shD_JgaJpZM4PSa6t . https://github.com/notifications/beacon/ARrLxCgcvb1ZkkiAnoVJXkRWsDjC4GQHks5shD_JgaJpZM4PSa6t.gif

PaulNoto commented 6 years ago

Just found out I could reply to your email with them attached.

PaulNoto commented 6 years ago

Did they come through on the email reply?

jefffhaynes commented 6 years ago

Doesn't look like it. Could you pastebin or publicly share a folder on OneDrive or something?


From: PaulNoto notifications@github.com Sent: Sunday, September 10, 2017 4:25:23 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] XBeeNode.SampleReceived Handler not called. Continued (#36)

Did they come through on the email reply?

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

PaulNoto commented 6 years ago

Hmm... Let me look in to that.

PaulNoto commented 6 years ago

Haven't used onedrive since it was skydrive, here goes:

https://1drv.ms/f/s!ArPDpRHDMgzfehRpy01XdthK3uo

That should be a link to the files. Let me know if it works.

jefffhaynes commented 6 years ago

Yup that worked. I'll load it up as soon as I can.


From: PaulNoto notifications@github.com Sent: Sunday, September 10, 2017 4:49:31 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] XBeeNode.SampleReceived Handler not called. Continued (#36)

Haven't used onedrive since it was skydrive, here goes:

https://1drv.ms/f/s!ArPDpRHDMgzfehRpy01XdthK3uo

That should be a link to the files. Let me know if it works.

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

PaulNoto commented 6 years ago

Thanks I appreciate all the help. Remember, there is no rush. I am using your old code that works perfect. I just need this so I don't remain trapped in the past, and can't access new features. Thanks, Paul

jefffhaynes commented 6 years ago

I tried loading both. Coordinator, no problem. For some reason the router config is putting the node into a state where I can't talk to it (locally) and I have to do a forced recovery on it. Have you seen this?

I also realized that I only have one S2C module so I may have to order a second one before I can reproduce this. I don't mind but obviously it'll be a few days...

PaulNoto commented 6 years ago

OOPS! I sent you the Router config off the xbee network, after my software had changed the DIN pin to an output. I just added the unchanged profile to one drive as profile_Router_2.xml. Does the link above still work to be able to get at it.

jefffhaynes commented 6 years ago

No worries. No, the folder just has the coord config now.

PaulNoto commented 6 years ago

Try this link

https://1drv.ms/u/s!ArPDpRHDMgzffP2P7kGOdLDlMds

jefffhaynes commented 6 years ago

Yup, that works but I am going to need more nodes to reproduce. I ordered them so hopefully it won't take too long.

jefffhaynes commented 6 years ago

Found it! Try 1.5.4