aboutsummaryrefslogtreecommitdiff
path: root/apps/hott_telemetry/messages.c
diff options
context:
space:
mode:
authorSimon Wilks <sjwilks@gmail.com>2012-11-22 01:54:41 +0100
committerSimon Wilks <sjwilks@gmail.com>2012-11-22 01:54:41 +0100
commitbc27a495a0ff4e9e76e38ab606c291d678658e1d (patch)
treeb3fad45f25bc1fb7b134446e6c3f8208feb8b818 /apps/hott_telemetry/messages.c
parent054c65535f41c788a6db2accf1f920eaf3d05ff4 (diff)
downloadpx4-firmware-bc27a495a0ff4e9e76e38ab606c291d678658e1d.tar.gz
px4-firmware-bc27a495a0ff4e9e76e38ab606c291d678658e1d.tar.bz2
px4-firmware-bc27a495a0ff4e9e76e38ab606c291d678658e1d.zip
Make the reading and sending of data independant of the message type.
This will allow us to cleanly support various sensor types by having a byte array interface for send_data() and read_data().
Diffstat (limited to 'apps/hott_telemetry/messages.c')
-rw-r--r--apps/hott_telemetry/messages.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/apps/hott_telemetry/messages.c b/apps/hott_telemetry/messages.c
index eee78a01e..1ce103b12 100644
--- a/apps/hott_telemetry/messages.c
+++ b/apps/hott_telemetry/messages.c
@@ -51,25 +51,32 @@ void messages_init(void)
sensor_sub = orb_subscribe(ORB_ID(sensor_combined));
}
-void build_eam_response(struct eam_module_msg *msg)
+void build_eam_response(char **buffer, int *size)
{
/* get a local copy of the current sensor values */
struct sensor_combined_s raw;
memset(&raw, 0, sizeof(raw));
orb_copy(ORB_ID(sensor_combined), sensor_sub, &raw);
- memset(msg, 0, sizeof(*msg));
+ struct eam_module_msg msg;
+ *size = sizeof(msg);
+ memset(&msg, 0, *size);
- msg->start = START_BYTE;
- msg->eam_sensor_id = ELECTRIC_AIR_MODULE;
- msg->sensor_id = EAM_SENSOR_ID;
- msg->temperature1 = (uint8_t)(raw.baro_temp_celcius + 20);
- msg->temperature2 = TEMP_ZERO_CELSIUS;
- msg->main_voltage_L = (uint8_t)(raw.battery_voltage_v * 10);
+ msg.start = START_BYTE;
+ msg.eam_sensor_id = ELECTRIC_AIR_MODULE;
+ msg.sensor_id = EAM_SENSOR_ID;
+ msg.temperature1 = (uint8_t)(raw.baro_temp_celcius + 20);
+ msg.temperature2 = TEMP_ZERO_CELSIUS;
+ msg.main_voltage_L = (uint8_t)(raw.battery_voltage_v * 10);
uint16_t alt = (uint16_t)(raw.baro_alt_meter + 500);
- msg->altitude_L = (uint8_t)alt & 0xff;
- msg->altitude_H = (uint8_t)(alt >> 8) & 0xff;
+ msg.altitude_L = (uint8_t)alt & 0xff;
+ msg.altitude_H = (uint8_t)(alt >> 8) & 0xff;
- msg->stop = STOP_BYTE;
+ msg.stop = STOP_BYTE;
+
+ //*chunk = malloc( sizeof(char) * length);
+ //char tmp_buffer[*size];
+ *buffer = malloc(sizeof(char) * *size);
+ memcpy(*buffer, &msg, *size);
} \ No newline at end of file