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.
Name | Type | Default | Description |
---|---|---|---|
port | string | None | Name of the serial port to open e.g., COM3, /dev/ttyUSB0 |
baud | int | 115200 | Baud rate |
tout | float | 0.1 | Timeout duration (in seconds) for serial communication |
sformat | string | Ascii | This value is fixed to Ascii |
autolog | boolean | False | If True, automatically logs interpreted payload to a CSV file |
err | boolean | False | If True, outputs error messages |
ReadSensorData()
This method reads the payload and interprets it according to the TWELITE PAL parent format.
Interprets the TWELITE PAL parent format (ASCII format only). Most of the interpretation follows this specification.
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.
For details on the meaning of EventID and related data, please refer to this document.
Key | Type | Description |
---|---|---|
ArriveTime | datetime | Time the payload was received |
LogicalID | int | Logical device ID of the end device |
EndDeviceSID | int | Serial number of the end device |
RouterSID | int | Serial number of the first repeater to receive the packet (0x80000000 if the parent directly receives the packet) |
LQI | int | Link quality of received signal |
SequenceNumber | int | Sequence number incremented with each transmission Starts from 1, rolls over to 0 after 65535 |
Sensor | int | Sensor type (fixed at 0x80) |
PALID | int | PAL board ID |
PALVersion | int | PAL board version |
HALLIC | int | State of the Hall IC |
Temperature | float | Temperature (degC) |
Humidity | float | Humidity (%) |
Illuminance | int | Illuminance (lux) |
AccelerationX | list,float | Acceleration on X-axis (g) |
AccelerationY | list,float | Acceleration on Y-axis (g) |
AccelerationZ | list,float | Acceleration on Z-axis (g) |
SamplingFrequency | int | Sampling frequency of acceleration |
EventID | list,int | Cause of event and event ID |
WakeupFactor | list,int | Data on wakeup factors, etc. |
OutputCSV()
Outputs the dictionary object to a CSV file.
Parameters
None
Return Value
None