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); }
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"); }
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")); }
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(); }
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(); }
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(); }
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")); }
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(); }
public override void Parse(IPacketParser parser) { var value = parser.Read("Modem Status"); Status = value < (byte)ModemStatus.StackError ? (ModemStatus)value : ModemStatus.StackError; }
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); } }
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()); } }
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")); }
public override void Parse(IPacketParser parser) { base.Parse(parser); Status = (TxStatus)parser.Read("TX Status"); }
public override void Parse(IPacketParser parser) { FrameId = parser.Read("Frame Id"); }
public override void Parse(IPacketParser parser) { Rssi = -1 * parser.Read("RSSI"); Option = (Options)parser.Read("Options"); }
protected virtual void ParseFrameOptions(IPacketParser parser) { Option = (Options)parser.Read("ZNet RX Option"); }
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"); }
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()); }