/      日本語

apppal.py

Class that interprets the read byte sequence and stores it in a dictionary object

Class AppPAL

This class inherits from AppBase, interprets the received payload, converts it into usable data, and stores it in a dictionary object.

Parameters for Definition

Parameters with default values are optional.

NameTypeDefaultDescription
portstringNone

Name of the serial port to open

e.g., COM3, /dev/ttyUSB0

baudint115200Baud rate
toutfloat0.1Timeout duration (in seconds) for serial communication
sformatstringAsciiThis value is fixed to Ascii
autologbooleanFalseIf True, automatically logs interpreted payload to a CSV file
errbooleanFalseIf True, outputs error messages

ReadSensorData()

This method reads the payload and interprets it according to the TWELITE PAL parent format.

Parameters

None

Return Value

If data is successfully read: True If data could not be read: False

The keys stored in the dictionary object are as follows.

KeyTypeDescription
ArriveTimedatetimeTime the payload was received
LogicalIDintLogical device ID of the end device
EndDeviceSIDintSerial number of the end device
RouterSIDint

Serial number of the first repeater to receive the packet

(0x80000000 if the parent directly receives the packet)

LQIintLink quality of received signal
SequenceNumberint

Sequence number incremented with each transmission

Starts from 1, rolls over to 0 after 65535

SensorintSensor type (fixed at 0x80)
PALIDintPAL board ID
PALVersionintPAL board version
HALLICintState of the Hall IC
TemperaturefloatTemperature (degC)
HumidityfloatHumidity (%)
IlluminanceintIlluminance (lux)
AccelerationXlist,floatAcceleration on X-axis (g)
AccelerationYlist,floatAcceleration on Y-axis (g)
AccelerationZlist,floatAcceleration on Z-axis (g)
SamplingFrequencyintSampling frequency of acceleration
EventIDlist,intCause of event and event ID
WakeupFactorlist,intData on wakeup factors, etc.

OutputCSV()

Outputs the dictionary object to a CSV file.

Parameters

None

Return Value

None