XBee C# library API reference

Show / Hide Table of Contents

Class IOSample

This class represents an IO Data Sample.

Inheritance
System.Object
IOSample
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: XBeeLibrary.Core.IO
Assembly: XBeeLibrary.Core.dll
Syntax
public class IOSample
Remarks

The sample is built using the the constructor. The sample contains an analog and digital mask indicating which IO lines are configured with that functionality. Depending on the protocol the XBee device is executing, the digital and analog masks are retrieved in separated bytes (2 bytes for the digital mask and 1 for the analog mask) or merged (digital and analog masks are contained in the same 2 bytes).

802.15.4 Protocol

Digital and analog channels masks

Indicates which digital and ADC IO lines are configured in the module. Each bit corresponds to one digital or ADC IO line on the module:

bit 0 = DIO0 1 bit 1 = DIO1 0 bit 2 = DIO2 0 bit 3 = DIO3 1 bit 4 = DIO4 0 bit 5 = DIO5 1 bit 6 = DIO6 0 bit 7 = DIO7 0 bit 8 = DIO8 0 bit 9 = AD0 0 bit 10 = AD1 1 bit 11 = AD2 1 bit 12 = AD3 0 bit 13 = AD4 0 bit 14 = AD5 0 bit 15 = N/A 0

Example: mask of {@code 0x0C29} means DIO0, DIO3, DIO5, AD1 and AD2 enabled. 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1

Other Protocols

Digital Channel Mask

Indicates which digital IO lines are configured in the module. Each bit corresponds to one digital IO line on the module:

bit 0 = DIO0/AD0 bit 1 = DIO1/AD1 bit 2 = DIO2/AD2 bit 3 = DIO3/AD3 bit 4 = DIO4/AD4 bit 5 = DIO5/AD5/ASSOC bit 6 = DIO6/RTS bit 7 = DIO7/CTS bit 8 = DIO8/DTR/SLEEP_RQ bit 9 = DIO9/ON_SLEEP bit 10 = DIO10/PWM0/RSSI bit 11 = DIO11/PWM1 bit 12 = DIO12/CD bit 13 = DIO13 bit 14 = DIO14 bit 15 = N/A

Example: mask of {@code 0x040B} means DIO0, DIO1, DIO2, DIO3 and DIO10 enabled. 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1

Analog Channel Mask

Indicates which lines are configured as ADC. Each bit in the analog channel mask corresponds to one ADC line on the module.

bit 0 = AD0/DIO0 bit 1 = AD1/DIO1 bit 2 = AD2/DIO2 bit 3 = AD3/DIO3 bit 4 = AD4/DIO4 bit 5 = AD5/DIO5/ASSOC bit 6 = N/A bit 7 = Supply Voltage Value

Example: mask of {@code 0x03} means AD0, and AD1 enabled. 0 0 0 0 0 0 1 1

Constructors

IOSample(Byte[])

Instantiates a new object of type IOSample with the given IO sample payload.

Declaration
public IOSample(byte[] ioSamplePayload)
Parameters
Type Name Description
System.Byte[] ioSamplePayload

The payload corresponding to an IO sample.

Exceptions
Type Condition
System.ArgumentException

If length of ioSamplePayload is lower than 5.

System.ArgumentNullException

If ioSamplePayload is null.

Properties

AnalogMask

The analog mask.

Declaration
public int AnalogMask { get; }
Property Value
Type Description
System.Int32

AnalogValues

The analog values dictionary.

Declaration
public IDictionary<IOLine, int> AnalogValues { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<IOLine, System.Int32>
Examples

To verify if this sample contains a valid analog values, use the property HasAnalogValues. if (ioSample.HasAnalogValues()) { var values = ioSample.AnalogValues; ... } else { ... } }

See Also
GetAnalogValue(IOLine)
HasAnalogValue(IOLine)
HasAnalogValues
IOLine

DigitalHSBMask

Gets the HSB of the digital mask.

Declaration
public int DigitalHSBMask { get; }
Property Value
Type Description
System.Int32
See Also
DigitalLSBMask
DigitalMask

DigitalLSBMask

Gets the LSB of the digital mask.

Declaration
public int DigitalLSBMask { get; }
Property Value
Type Description
System.Int32
See Also
DigitalHSBMask
DigitalMask

DigitalMask

The combined (HSB + LSB) digital mask.

Declaration
public int DigitalMask { get; }
Property Value
Type Description
System.Int32
See Also
DigitalLSBMask
DigitalHSBMask

DigitalValues

The digital values dictionary.

Declaration
public IDictionary<IOLine, IOValue> DigitalValues { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<IOLine, IOValue>
Examples

To verify if this sample contains a valid digital values, use the method HasDigitalValues. if (ioSample.hasDigitalValues()) { var values = ioSample.DigitalValues; ... } else { ... } }

See Also
GetDigitalValue(IOLine)
HasDigitalValues
IOLine
IOValue

HasAnalogValues

Indicates whether the IOSample has analog values.

Declaration
public bool HasAnalogValues { get; }
Property Value
Type Description
System.Boolean
See Also
GetAnalogValue(IOLine)
AnalogValues
HasAnalogValue(IOLine)
IOLine

HasDigitalValues

Indicates whether or not the IOSample has digital values.

Declaration
public bool HasDigitalValues { get; }
Property Value
Type Description
System.Boolean

true if there are digital values, false otherwise.

HasPowerSupplyValue

Indicates whether the IOSample has power supply value.

Declaration
public bool HasPowerSupplyValue { get; }
Property Value
Type Description
System.Boolean
See Also
PowerSupplyValue

PowerSupplyValue

Gets the value of the power supply voltage.

Declaration
public int PowerSupplyValue { get; }
Property Value
Type Description
System.Int32
Examples

To verify if this sample contains the power supply voltage, use the property HasPowerSupplyValue. if (ioSample.HasPowerSupplyValue) { int value = ioSample.PowerSupplyValue; ... } else { ... } }

Exceptions
Type Condition
OperationNotSupportedException

If the IOSample does not have power supply value.

See Also
HasPowerSupplyValue

Methods

GetAnalogValue(IOLine)

Gets the analog value of the specified ioLine.

Declaration
public int GetAnalogValue(IOLine ioLine)
Parameters
Type Name Description
IOLine ioLine

The IO line to get its analog value.

Returns
Type Description
System.Int32

The analog value of the given IO line.

Examples

To verify if this sample contains an analog value for the specified ioLine, use the method HasAnalogValue(IOLine). if (ioSample.HasAnalogValue(IOLine.DIO0_AD0)) { var value = ioSample.GetAnalogValue(IOLine.DIO0_AD0); ... } else { ... } }

See Also
AnalogValues
HasAnalogValue(IOLine)
HasAnalogValues
IOLine

GetDigitalValue(IOLine)

Gets the digital value of the provided IO line.

Declaration
public IOValue GetDigitalValue(IOLine ioLine)
Parameters
Type Name Description
IOLine ioLine

The IO line to get its digital value.

Returns
Type Description
IOValue

The IOValue of the specified ioLine

Examples

To verify if this sample contains a digital value for the specified ioLine, use the method HasDigitalValue(IOLine).

if (ioSample.HasDigitalValue(IOLine.DIO0_AD0)) {
IOValue value = ioSample.GetDigitalValue(IOLine.DIO0_AD0);
...
} else {
...
}
}
See Also
DigitalValues
HasDigitalValues
IOLine
IOValue

HasAnalogValue(IOLine)

Indicates whether or not the specified ioLine has an analog value.

Declaration
public bool HasAnalogValue(IOLine ioLine)
Parameters
Type Name Description
IOLine ioLine

The IO line to check if has an analog value.

Returns
Type Description
System.Boolean

true if the specified ioLine has an analog value, false otherwise.

See Also
GetAnalogValue(IOLine)
AnalogValues
HasAnalogValues
IOLine

HasDigitalValue(IOLine)

Indicates whether the IO sample contains a digital value for the specified ioLine

Declaration
public bool HasDigitalValue(IOLine ioLine)
Parameters
Type Name Description
IOLine ioLine

The IO line to check if has a digital value.

Returns
Type Description
System.Boolean

true if the specified ioLine has a digital value, false otherwises.

ToString()

Returns the string representation of this IO Sample.

Declaration
public override string ToString()
Returns
Type Description
System.String

The string representation of this IO Sample.

Overrides
System.Object.ToString()
Product page More documentation Official site About Digi Contact us Support
©2019 Digi International Inc. All rights reserved.
Digi International Inc.