Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
telemetry-data.cpp
00001 /* 00002 * telemetry-data.cpp 00003 * 00004 * Created on: Mar 2, 2015 00005 * Author: Ducky 00006 * 00007 * Implementation for Telemetry Data classes. 00008 */ 00009 #include <telemetry.h> 00010 #include <string.h> 00011 00012 namespace telemetry { 00013 void packet_write_string(TransmitPacketInterface& packet, const char* str) { 00014 // TODO: move into HAL for higher performance? 00015 while (*str != '\0') { 00016 packet.write_uint8(*str); 00017 str++; 00018 } 00019 packet.write_uint8('\0'); 00020 } 00021 00022 size_t Data::get_header_kvrs_length() { 00023 return 1 + strlen(internal_name) + 1 00024 + 1 + strlen(display_name) + 1 00025 + 1 + strlen(units) + 1; 00026 } 00027 00028 void Data::write_header_kvrs(TransmitPacketInterface& packet) { 00029 packet.write_uint8(RECORDID_INTERNAL_NAME); 00030 packet_write_string(packet, internal_name); 00031 packet.write_uint8(RECORDID_DISPLAY_NAME); 00032 packet_write_string(packet, display_name); 00033 packet.write_uint8(RECORDID_UNITS); 00034 packet_write_string(packet, units); 00035 } 00036 00037 template<> 00038 uint8_t Numeric<uint8_t>::get_subtype() { 00039 return NUMERIC_SUBTYPE_UINT; 00040 } 00041 template<> 00042 void Numeric<uint8_t>::serialize_data(uint8_t value, TransmitPacketInterface& packet) { 00043 packet.write_uint8(value); 00044 } 00045 template<> 00046 uint8_t Numeric<uint8_t>::deserialize_data(ReceivePacketBuffer& packet) { 00047 return packet.read_uint8(); 00048 } 00049 00050 template<> 00051 uint8_t Numeric<uint16_t>::get_subtype() { 00052 return NUMERIC_SUBTYPE_UINT; 00053 } 00054 template<> 00055 void Numeric<uint16_t>::serialize_data(uint16_t value, TransmitPacketInterface& packet) { 00056 packet.write_uint16(value); 00057 } 00058 template<> 00059 uint16_t Numeric<uint16_t>::deserialize_data(ReceivePacketBuffer& packet) { 00060 return packet.read_uint16(); 00061 } 00062 00063 template<> 00064 uint8_t Numeric<uint32_t>::get_subtype() { 00065 return NUMERIC_SUBTYPE_UINT; 00066 } 00067 template<> 00068 void Numeric<uint32_t>::serialize_data(uint32_t value, TransmitPacketInterface& packet) { 00069 packet.write_uint32(value); 00070 } 00071 template<> 00072 uint32_t Numeric<uint32_t>::deserialize_data(ReceivePacketBuffer& packet) { 00073 return packet.read_uint32(); 00074 } 00075 00076 // TODO: move into HAL 00077 template<> 00078 uint8_t Numeric<float>::get_subtype() { 00079 return NUMERIC_SUBTYPE_FLOAT; 00080 } 00081 template<> 00082 void Numeric<float>::serialize_data(float value, TransmitPacketInterface& packet) { 00083 packet.write_float(value); 00084 } 00085 template<> 00086 float Numeric<float>::deserialize_data(ReceivePacketBuffer& packet) { 00087 return packet.read_float(); 00088 } 00089 00090 }
Generated on Tue Jul 12 2022 22:03:01 by
