jefffhaynes / XBee

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

Input5 included in input mask even though it is set as an output. #48

Open PaulHeitkemper opened 6 years ago

PaulHeitkemper commented 6 years ago

Title says it all. I have all I/O disabled except for input 0 as a digital input, and DIO5 as a Digital Output(low). Pullup is set for all I/O pins. However Input5 comes back very often (but not always) in the input mask when I deassert DIO0. Interestingly, it isn't included when I release my button to let input 0 go high.

jefffhaynes commented 6 years ago

Ok, I should be able to look at it in the next few days.

— If you want to build a ship, don't drum up people 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


From: PaulHeitkemper notifications@github.com Sent: Friday, March 30, 2018 12:05:25 PM To: jefffhaynes/XBee Cc: Subscribed Subject: [jefffhaynes/XBee] Input5 included in input mask even though it is set as an output. (#48)

Title says it all. I have all I/O disabled except for input 0 as a digital input, and DIO5 as a Digital Output(low). However Input5 comes back often (but not always) in the input mask when deassert DIO0. Pullup is set for all I/O pins.

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

jefffhaynes commented 6 years ago

Can you post your code and let me know what device you're using? Thanks

PaulHeitkemper commented 6 years ago

The following code seems to sometimes give me

DigitalSampleState = Input0, Input12

Despite the fact that Input12 (pin 4) is internally pulled up, disconnected, and disabled in XCTU. Hardware is a XBeePro-900HP as remote unit (shown below as "ButtonAddress"), with same type of module connected to a USB serial board as the controller. remote module has controller address as DH/DL.


using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using XBee.Devices;
using XBee.Frames;
using XBee.Frames.AtCommands;

namespace XBee.Classic.Tester
{
    class Program
    {
        private const InputOutputChannel LedChannel = InputOutputChannel.Channel0;
        private const string ButtonAddress = "0013a20041073502";

        private static XBeeController controller;
        private static XBeeNode node;
        static void Main(string[] args)
        {
            var controllerTask = XBeeController.FindAndOpenAsync(9600);
            controllerTask.Wait();
            controller = controllerTask.Result;

            if (controller == null)
            {
                Console.WriteLine("Could not find controller. Exiting.");
                return;
            }
            controller.SampleReceived += Controller_SampleReceived;

            while (true)
            {
                getSignalStrength();
                Thread.Sleep(10000);
            }
        }

        private static void Controller_SampleReceived(object sender, SourcedSampleReceivedEventArgs e)
        {
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("Controller_SampleReceived from {0}", e.Address);
            Console.WriteLine("DigitalSampleState = {0}", e.DigitalSampleState);
        }

        private static void getSignalStrength()
        {
            try
            {
                var t = controller.Local.GetSignalStrengthAsync();
                //var t = node.GetSignalStrengthAsync();
                t.Wait(TimeSpan.FromMilliseconds(700));
                var rssi = t.Result;
                Console.WriteLine("RSSI: {0}", rssi);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception getting RSSI: {0}", ex.Message);
            }
        }
    }
}