SELKIELogger  1.0.0
LPMSMessages.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Swansea University
3  *
4  * This file is part of the SELKIELogger suite of tools.
5  *
6  * SELKIELogger is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation, either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * SELKIELogger is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this SELKIELogger product.
18  * If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SELKIELoggerLPMS_Messages
22 #define SELKIELoggerLPMS_Messages
23 
30 #include <stdbool.h>
31 #include <stdint.h>
32 
33 #include "SELKIELoggerBase.h"
34 
35 #include "LPMSTypes.h"
36 
37 #define LPMS_START 0x3A
38 #define LPMS_END1 0x0D
39 #define LPMS_END2 0x0A
40 
51 #define LPMS_MSG_REPLY_ACK 0x00
52 #define LPMS_MSG_REPLY_NAK 0x01
53 #define LPMS_MSG_SAVE_REG 0x04
54 #define LPMS_MSG_FACTORY_RESET 0x05
55 #define LPMS_MSG_MODE_CMD 0x06
56 #define LPMS_MSG_MODE_STREAM 0x07
57 #define LPMS_MSG_GET_SENSORSTATE 0x08
58 #define LPMS_MSG_GET_IMUDATA 0x09
59 #define LPMS_MSG_GET_SENSORMODEL 0x14
60 #define LPMS_MSG_GET_FIRMWAREVER 0x15
61 #define LPMS_MSG_GET_SERIALNUM 0x16
62 #define LPMS_MSG_GET_FILTERVER 0x17
63 #define LPMS_MSG_SET_OUTPUTS 0x1E
64 #define LPMS_MSG_GET_OUTPUTS 0x1F
65 #define LPMS_MSG_SET_ID 0x20
66 #define LPMS_MSG_GET_ID 0x21
67 #define LPMS_MSG_SET_FREQ 0x22
68 #define LPMS_MSG_GET_FREQ 0x23
69 #define LPMS_MSG_SET_RADIANS 0x24
70 #define LPMS_MSG_GET_RADIANS 0x25
71 #define LPMS_MSG_SET_ACCRANGE 0x32
72 #define LPMS_MSG_GET_ACCRANGE 0x33
73 #define LPMS_MSG_SET_GYRRANGE 0x3C
74 #define LPMS_MSG_GET_GYRRANGE 0x3D
75 #define LPMS_MSG_SET_MAGRANGE 0x46
76 #define LPMS_MSG_GET_MAGRANGE 0x47
77 #define LPMS_MSG_SET_FILTER 0x5A
78 #define LPMS_MSG_GET_FILTER 0x5B
79 #define LPMS_MSG_SET_UARTBAUD 0x82
80 #define LPMS_MSG_GET_UARTBAUD 0x83
81 #define LPMS_MSG_SET_UARTFORMAT 0x84
82 #define LPMS_MSG_GET_UARTFORMAT 0x85
83 #define LPMS_MSG_SET_UARTPRECISION 0x88
84 #define LPMS_MSG_GET_UARTPRECISION 0x89
85 
87 
89 bool lpms_from_bytes(const uint8_t *in, const size_t len, lpms_message *msg, size_t *pos);
90 
92 bool lpms_to_bytes(const lpms_message *msg, uint8_t **out, size_t *len);
93 
95 bool lpms_checksum(const lpms_message *msg, uint16_t *csum);
96 
98 bool lpms_imu_set_timestamp(const lpms_message *msg, lpms_data *d);
100 bool lpms_imu_set_accel_raw(const lpms_message *msg, lpms_data *d);
102 bool lpms_imu_set_accel_cal(const lpms_message *msg, lpms_data *d);
104 bool lpms_imu_set_gyro_raw(const lpms_message *msg, lpms_data *d);
106 bool lpms_imu_set_gyro_cal(const lpms_message *msg, lpms_data *d);
110 bool lpms_imu_set_mag_raw(const lpms_message *msg, lpms_data *d);
112 bool lpms_imu_set_mag_cal(const lpms_message *msg, lpms_data *d);
114 bool lpms_imu_set_omega(const lpms_message *msg, lpms_data *d);
116 bool lpms_imu_set_quaternion(const lpms_message *msg, lpms_data *d);
122 bool lpms_imu_set_pressure(const lpms_message *msg, lpms_data *d);
124 bool lpms_imu_set_altitude(const lpms_message *msg, lpms_data *d);
126 bool lpms_imu_set_temperature(const lpms_message *msg, lpms_data *d);
127 #endif
bool lpms_imu_set_temperature(const lpms_message *msg, lpms_data *d)
Extract temperature from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:501
bool lpms_checksum(const lpms_message *msg, uint16_t *csum)
Calculate checksum for LPMS message packet.
Definition: LPMSMessages.c:135
bool lpms_imu_set_gyro_aligned(const lpms_message *msg, lpms_data *d)
Extract gyro_aligned from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:258
bool lpms_imu_set_mag_cal(const lpms_message *msg, lpms_data *d)
Extract mag_cal from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:305
bool lpms_imu_set_altitude(const lpms_message *msg, lpms_data *d)
Extract altitude from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:470
bool lpms_imu_set_euler_angles(const lpms_message *msg, lpms_data *d)
Extract euler_angles from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:383
bool lpms_to_bytes(const lpms_message *msg, uint8_t **out, size_t *len)
Convert message structure to flat array.
Definition: LPMSMessages.c:104
bool lpms_imu_set_gyro_raw(const lpms_message *msg, lpms_data *d)
Extract gyro_raw from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:214
bool lpms_imu_set_quaternion(const lpms_message *msg, lpms_data *d)
Extract quaternion from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:356
bool lpms_imu_set_accel_raw(const lpms_message *msg, lpms_data *d)
Extract accel_raw from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:178
bool lpms_imu_set_timestamp(const lpms_message *msg, lpms_data *d)
Extract timestamp from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:161
bool lpms_imu_set_accel_cal(const lpms_message *msg, lpms_data *d)
Extract accel_cal from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:194
bool lpms_imu_set_pressure(const lpms_message *msg, lpms_data *d)
Extract pressure from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:440
bool lpms_imu_set_mag_raw(const lpms_message *msg, lpms_data *d)
Extract mag_raw from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:281
bool lpms_imu_set_gyro_cal(const lpms_message *msg, lpms_data *d)
Extract gyro_cal from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:235
bool lpms_from_bytes(const uint8_t *in, const size_t len, lpms_message *msg, size_t *pos)
Read bytes and populate message structure.
Definition: LPMSMessages.c:42
bool lpms_imu_set_accel_linear(const lpms_message *msg, lpms_data *d)
Extract accel_linear from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:411
bool lpms_imu_set_omega(const lpms_message *msg, lpms_data *d)
Extract omega from lpms_message into lpms_data, if available.
Definition: LPMSMessages.c:330
LPMS IMU data packet.
Definition: LPMSTypes.h:72
Represent LPMS message.
Definition: LPMSTypes.h:48