コード例 #1
0
ファイル: IoSampleResponse.cs プロジェクト: vishalishere/xbee
        private IoSample ParseIoSample(IPacketParser parser)
        {
            ushort digital = 0;
            var analog = new double[Pin.AnalogCount];

            if (ContainsDigital)
            {
                Logger.LowDebug("Sample contains digital inputs");
                digital = UshortUtils.ToUshort(parser.Read(), parser.Read());
            }

            if (ContainsAnalog)
            {
                var analogCount = 0;

                for (var i = 0; i < analog.Length; i++)
                {
                    if (!IsEnabled((Pin.Analog) i))
                        continue;

                    var reading = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
                    analog[i] = AdcHelper.ToMilliVolts(reading);
                    analogCount++;
                }

                Logger.LowDebug("Sample contains " + analogCount +" analog inputs");
            }

            return new IoSample(analog, digital);
        }
コード例 #2
0
ファイル: TxStatusResponse.cs プロジェクト: vishalishere/xbee
 public override void Parse(IPacketParser parser)
 {
     base.Parse(parser);
     DestinationAddress = parser.ParseAddress16();
     RetryCount         = parser.Read("ZNet Tx Status Tx Count");
     DeliveryStatus     = (DeliveryResult)parser.Read("ZNet Tx Status Delivery Status");
     DiscoveryStatus    = (DiscoveryResult)parser.Read("ZNet Tx Status Discovery Status");
 }
コード例 #3
0
        protected override void ParseFrameHeader(IPacketParser parser)
        {
            base.ParseFrameHeader(parser);

            SourceEndpoint      = parser.Read("Reading Source Endpoint");
            DestinationEndpoint = parser.Read("Reading Destination Endpoint");
            ClusterId           = UshortUtils.ToUshort(parser.Read("Reading Cluster Id MSB"), parser.Read("Reading Cluster Id LSB"));
            ProfileId           = UshortUtils.ToUshort(parser.Read("Reading Profile Id MSB"), parser.Read("Reading Profile Id LSB"));
        }
コード例 #4
0
        public override void Parse(IPacketParser parser)
        {
            base.Parse(parser);

            Command = UshortUtils.ToUshort(
                parser.Read("AT Response Char 1"),
                parser.Read("AT Response Char 2"));

            Status = (AtResponseStatus)parser.Read("AT Response Status");
            Value  = parser.ReadRemainingBytes();
        }
コード例 #5
0
ファイル: AtResponse.cs プロジェクト: jamespettigrew/GBee
        public override void Parse(IPacketParser parser)
        {
            base.Parse(parser);

            Command = UshortUtils.ToUshort(
                parser.Read("AT Response Char 1"),
                parser.Read("AT Response Char 2"));

            Status = (AtResponseStatus) parser.Read("AT Response Status");
            Value = parser.ReadRemainingBytes();
        }
コード例 #6
0
        public override void Parse(IPacketParser parser)
        {
            FrameId = parser.Read("Frame Id");

            RemoteSerial = parser.ParseAddress64();
            RemoteAddress = parser.ParseAddress16();

            Command = UshortUtils.ToUshort(
                parser.Read("AT Response Char 1"),
                parser.Read("AT Response Char 2"));

            Status = (AtResponseStatus) parser.Read("AT Response Status");
            Value = parser.ReadRemainingBytes();
        }
コード例 #7
0
        public override void Parse(IPacketParser parser)
        {
            Sender = new NodeInfo
            {
                SerialNumber   = parser.ParseAddress64(),
                NetworkAddress = parser.ParseAddress16()
            };

            Option = (PacketOption)parser.Read("Option");

            Remote = new NodeInfo
            {
                NetworkAddress = parser.ParseAddress16(),
                SerialNumber   = parser.ParseAddress64()
            };

            byte ch;

            // NI is terminated with 0
            while ((ch = parser.Read("Node Identifier")) != 0)
            {
                if (ch > 32 && ch < 126)
                {
                    Remote.NodeIdentifier += (char)ch;
                }
            }

            ParentAddress = parser.ParseAddress16();
            NodeType      = (NodeType)parser.Read("Device Type");
            SourceAction  = (SourceActions)parser.Read("Source Action");
            ProfileId     = UshortUtils.ToUshort(parser.Read("Profile MSB"), parser.Read("Profile LSB"));
            MfgId         = UshortUtils.ToUshort(parser.Read("MFG MSB"), parser.Read("MFG LSB"));
        }
コード例 #8
0
        public override void Parse(IPacketParser parser)
        {
            FrameId = parser.Read("Frame Id");

            RemoteSerial  = parser.ParseAddress64();
            RemoteAddress = parser.ParseAddress16();

            Command = UshortUtils.ToUshort(
                parser.Read("AT Response Char 1"),
                parser.Read("AT Response Char 2"));

            Status = (AtResponseStatus)parser.Read("AT Response Status");
            Value  = parser.ReadRemainingBytes();
        }
コード例 #9
0
        public override void Parse(IPacketParser parser)
        {
            var value = parser.Read("Modem Status");

            Status = value < (byte)ModemStatus.StackError
                ? (ModemStatus)value
                : ModemStatus.StackError;
        }
コード例 #10
0
        public override void Parse(IPacketParser parser)
        {
            Source = parser.ApiId == ApiId.Rx16IoResponse
             ? (XBeeAddress)parser.ParseAddress16()
             : parser.ParseAddress64();

            base.Parse(parser);

            SampleCount = parser.Read();
            ChannelIndicator = UshortUtils.ToUshort(parser.Read(), parser.Read());
            ContainsDigital = (ChannelIndicator & DigitalMask) > 0;
            ContainsAnalog = (ChannelIndicator & AnalogMask) > 0;
            Samples = new IoSample[SampleCount];

            for (var i = 0; i < SampleCount; i++)
            {
                Logger.LowDebug("Parsing I/O sample nr " + (i + 1));
                Samples[i] = ParseIoSample(parser);
            }
        }
コード例 #11
0
ファイル: IoSampleResponse.cs プロジェクト: vishalishere/xbee
        public override void Parse(IPacketParser parser)
        {
            Source = parser.ApiId == ApiId.Rx16IoResponse
             ? (XBeeAddress)parser.ParseAddress16()
             : parser.ParseAddress64();

            base.Parse(parser);

            SampleCount = parser.Read();
            ChannelIndicator = UshortUtils.ToUshort(parser.Read(), parser.Read());
            ContainsDigital = (ChannelIndicator & DigitalMask) > 0;
            ContainsAnalog = (ChannelIndicator & AnalogMask) > 0;
            Samples = new IoSample[SampleCount];

            for (var i = 0; i < SampleCount; i++)
            {
                Logger.LowDebug("Parsing I/O sample nr " + (i + 1));
                Samples[i] = ParseIoSample(parser);
            }
        }
コード例 #12
0
        protected override void ParseFramePayload(IPacketParser parser)
        {
            // eat sample size.. always 1
            var size = parser.Read("ZNet RX IO Sample Size");

            if (size != 1)
            {
                throw new XBeeParseException("Sample size is not supported if > 1 for ZNet I/O");
            }

            DigitalChannelMask = UshortUtils.ToUshort(parser.Read("ZNet RX IO Sample Digital Mask 1"),
                                                      parser.Read("ZNet RX IO Sample Digital Mask 2"));

            // TODO apparent bug: channel mask on ZigBee Pro firmware has DIO10/P0 as enabled even though it's set to 01 (RSSI).  Digital value reports low.
            DigitalChannelMask &= 0x1CFF; //11100 zero out all but bits 3-5

            AnalogChannelMask  = parser.Read("ZNet RX IO Sample Analog Channel Mask");
            AnalogChannelMask &= 0x8f; //10001111 zero out n/a bits

            if (ContainsDigital)
            {
                Digital = UshortUtils.ToUshort(parser.Read("ZNet RX IO DIO MSB"),
                                               parser.Read("ZNet RX IO DIO LSB"));
            }

            // parse 10-bit analog values

            Analog = new int[5];

            for (var pin = Pin.A0; pin <= Pin.A3; pin++)
            {
                if (!IsAnalogEnabled(pin))
                {
                    continue;
                }

                Analog[(byte)pin] = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
            }

            if (IsAnalogEnabled(Pin.SupplyVoltage))
            {
                Analog[SupplyVoltageIndex] = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
            }
        }
コード例 #13
0
        protected override void ParseFrameHeader(IPacketParser parser)
        {
            base.ParseFrameHeader(parser);

            SourceEndpoint = parser.Read("Reading Source Endpoint");
            DestinationEndpoint = parser.Read("Reading Destination Endpoint");
            ClusterId = UshortUtils.ToUshort(parser.Read("Reading Cluster Id MSB"), parser.Read("Reading Cluster Id LSB"));
            ProfileId = UshortUtils.ToUshort(parser.Read("Reading Profile Id MSB"), parser.Read("Reading Profile Id LSB"));
        }
コード例 #14
0
        public override void Parse(IPacketParser parser)
        {
            Sender = new NodeInfo
            {
                SerialNumber = parser.ParseAddress64(),
                NetworkAddress = parser.ParseAddress16()
            };

            Option = (PacketOption) parser.Read("Option");

            Remote = new NodeInfo
            {
                NetworkAddress = parser.ParseAddress16(),
                SerialNumber = parser.ParseAddress64()
            };

            byte ch;

            // NI is terminated with 0
            while ((ch = parser.Read("Node Identifier")) != 0)
            {
                if (ch > 32 && ch < 126)
                    Remote.NodeIdentifier += (char) ch;
            }

            ParentAddress = parser.ParseAddress16();
            NodeType = (NodeType) parser.Read("Device Type");
            SourceAction = (SourceActions) parser.Read("Source Action");
            ProfileId = UshortUtils.ToUshort(parser.Read("Profile MSB"), parser.Read("Profile LSB"));
            MfgId = UshortUtils.ToUshort(parser.Read("MFG MSB"), parser.Read("MFG LSB"));
        }
コード例 #15
0
 public override void Parse(IPacketParser parser)
 {
     base.Parse(parser);
     Status = (TxStatus)parser.Read("TX Status");
 }
コード例 #16
0
        private IoSample ParseIoSample(IPacketParser parser)
        {
            ushort digital = 0;
            var analog = new double[Pin.AnalogCount];

            if (ContainsDigital)
            {
                Logger.LowDebug("Sample contains digital inputs");
                digital = UshortUtils.ToUshort(parser.Read(), parser.Read());
            }

            if (ContainsAnalog)
            {
                var analogCount = 0;

                for (var i = 0; i < analog.Length; i++)
                {
                    if (!IsEnabled((Pin.Analog) i))
                        continue;

                    var reading = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
                    analog[i] = AdcHelper.ToMilliVolts(reading);
                    analogCount++;
                }

                Logger.LowDebug("Sample contains " + analogCount +" analog inputs");
            }

            return new IoSample(analog, digital);
        }
コード例 #17
0
 public override void Parse(IPacketParser parser)
 {
     FrameId = parser.Read("Frame Id");
 }
コード例 #18
0
ファイル: RxResponseBase.cs プロジェクト: jamespettigrew/GBee
 public override void Parse(IPacketParser parser)
 {
     Rssi = -1 * parser.Read("RSSI");
     Option = (Options)parser.Read("Options");
 }
コード例 #19
0
ファイル: RxResponseBase.cs プロジェクト: vishalishere/xbee
 protected virtual void ParseFrameOptions(IPacketParser parser)
 {
     Option = (Options)parser.Read("ZNet RX Option");
 }
コード例 #20
0
 public override void Parse(IPacketParser parser)
 {
     base.Parse(parser);
     DestinationAddress = parser.ParseAddress16();
     RetryCount = parser.Read("ZNet Tx Status Tx Count");
     DeliveryStatus = (DeliveryResult) parser.Read("ZNet Tx Status Delivery Status");
     DiscoveryStatus = (DiscoveryResult) parser.Read("ZNet Tx Status Discovery Status");
 }
コード例 #21
0
 public override void Parse(IPacketParser parser)
 {
     Rssi   = -1 * parser.Read("RSSI");
     Option = (Options)parser.Read("Options");
 }
コード例 #22
0
        protected override void ParseFramePayload(IPacketParser parser)
        {
            // eat sample size.. always 1
            var size = parser.Read("ZNet RX IO Sample Size");

            if (size != 1)
                throw new XBeeParseException("Sample size is not supported if > 1 for ZNet I/O");

            DigitalChannelMask = UshortUtils.ToUshort(parser.Read("ZNet RX IO Sample Digital Mask 1"),
                                                      parser.Read("ZNet RX IO Sample Digital Mask 2"));

            // TODO apparent bug: channel mask on ZigBee Pro firmware has DIO10/P0 as enabled even though it's set to 01 (RSSI).  Digital value reports low.
            DigitalChannelMask &= 0x1CFF; //11100 zero out all but bits 3-5

            AnalogChannelMask = parser.Read("ZNet RX IO Sample Analog Channel Mask");
            AnalogChannelMask &= 0x8f; //10001111 zero out n/a bits

            if (ContainsDigital)
                Digital = UshortUtils.ToUshort(parser.Read("ZNet RX IO DIO MSB"),
                                               parser.Read("ZNet RX IO DIO LSB"));

            // parse 10-bit analog values

            Analog = new int[5];

            for (var pin = Pin.A0; pin <= Pin.A3; pin++)
            {
                if (!IsAnalogEnabled(pin))
                    continue;

                Analog[(byte)pin] = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
            }

            if (IsAnalogEnabled(Pin.SupplyVoltage))
                Analog[SupplyVoltageIndex] = UshortUtils.Parse10BitAnalog(parser.Read(), parser.Read());
        }
コード例 #23
0
 public override void Parse(IPacketParser parser)
 {
     FrameId = parser.Read("Frame Id");
 }