TwePacketPAL

The TwePacketPal class interprets TWELITE PAL packet data. This class handles TWELITE PAL (sensor data and other upstream data) commonly.

class TwePacketPal : public TwePacket, public DataPal { ... };

PAL common data is defined in DataPal.

Generator functions are provided to retrieve data specific to each PAL sensor board.

DataPal structure

Although the packet data structure of PAL differs depending on the connected sensors, etc., DataPal holds the data structure of the common part.

struct DataPal {
	uint8_t u8lqi; // LQI value

	uint32_t u32addr_rpt; // address of the relay

	uint32_t u32addr_src; // source address
	uint8_t u8addr_src; // source logical address

	uint16_t u16seq; // sequence number

	E_PAL_PCB u8palpcb; // PAL board type
	uint8_t u8palpcb_rev; // Revision of PAL board
	uint8_t u8sensors; // Number of sensor data in the data (MSB=1 is an error)
	uint8_t u8snsdatalen; // sensor data length (in bytes)

	union {
		const uint8_t *au8snsdata; // reference to sensor data part
		uint8_t _pobj[MWX_PARSER_PKT_APPPAL_FIXED_BUF]; // each sensor object
	};
};

The PAL packet data structure consists of two blocks: the common part for all PALs and the individual data part. The individual data part does not interpret the packet, but stores it as is. To simplify handling, data exceeding 32 bytes is stored in dynamically allocated uptr_snsdata.

The individual data parts are stored in a structure whose base class is PalBase. This structure is generated by the generator function defined in TwePacketPal.

If the size fits in MWX_PARSER_PKT_APPPAL_FIXED_BUF when parse<TwePacketPAL>() is executed, a separate sensor object is generated.

If it does not fit, a reference to the byte sequence used for analysis is stored in au8snsdata. In this case, if the data in the byte string used for analysis is rewritten, sensor-specific objects cannot be generated.

PalBase

All data structures for each sensor in PAL inherit from PalBase. The sensor data storage status u32StoredMask is included.

PalEvent

PAL events are information that is sent when certain conditions are met by processing sensor information, rather than directly from sensors. For example, when an acceleration sensor detects a certain level of acceleration from a stationary state.

If event data exists, it can be determined by .is_PalEvent() of TwePacketPal being true, and .get_PalEvent() will yield a PalEvent data structure.

Generator functions

Generator functions are used to extract various types of data from sensor PAL.

To use the generator function, first determine if pkt is an event (.is_PalEvent()). If it is an event, it has get_PalEvent(). Otherwise, it creates an object according to u8palpcb.

get_PalMag()

If .u8palpcb==E_PAL_PCB::MAG, the data PalMag of the open/close sensor pal is taken.

get_PalAmb()

If .u8palpcb==E_PAL_PCB::AMB, the data PalAmb of the environmental sensor pal is taken.

get_PalMot()

If .u8palpcb==E_PAL_PCB::MOT, the data PalMot of the operating sensor pal is taken.

get_PalEvent()

Extracts a PalEvent (PAL event) if .is_PalEvent() is true.

最終更新