From 02a8ccd0b3fae028d2712fe487042417553008e8 Mon Sep 17 00:00:00 2001 From: antrob25 Date: Mon, 21 Feb 2022 22:33:00 -0600 Subject: [PATCH] Documented changes to rovecomm packet size and changed said size to numbers listed in the read me --- README.md | 4 ++++ examples/RoveCommUdp/RoveCommUdp.ino | 3 --- src/RoveCommPacket.cpp | 6 +++++- src/RoveCommPacket.h | 12 ++++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 93fd9e8..0a71209 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,9 @@ The RoveComm udp packet header is 5 bytes long: The packet then countains a data_count number of data elements. The size of each element depends on the data type. +Due to memory limitations, the Tiva can only support 21,845 uint8_ts, 10,922 uint16_ts, 5461 uint32_ts, 5461 floats, or 2730 doubles at once. + +Due to memory limitations, the Teensy can only support 32,767 uint8_ts, 16,383 uint16_ts, 8,191 uint32_ts, 8,191 floats, or 4,095 doubles at once. + ## Use Examples of how to implement RoveComm on the Tiva C Microcontroller and Teensy 4.1 are [here](https://github.com/MissouriMRDT/RoveComm/tree/dev/examples). diff --git a/examples/RoveCommUdp/RoveCommUdp.ino b/examples/RoveCommUdp/RoveCommUdp.ino index 2970231..ea517f0 100644 --- a/examples/RoveCommUdp/RoveCommUdp.ino +++ b/examples/RoveCommUdp/RoveCommUdp.ino @@ -38,9 +38,6 @@ void loop() { case RC_DRIVEBOARD_DRIVEINDIVIDUAL_DATA_ID: Serial.println("We received an individual wheel drive command"); - char* sped; - sped = (char*)packet.data; - Serial.println(sped[0]); break; case RC_DRIVEBOARD_DRIVELEFTRIGHT_DATA_ID: //cast the packet to the correct data type diff --git a/src/RoveCommPacket.cpp b/src/RoveCommPacket.cpp index a92c1c6..e8c0274 100644 --- a/src/RoveCommPacket.cpp +++ b/src/RoveCommPacket.cpp @@ -273,7 +273,11 @@ namespace roveware uint16_t data_count = (header[3] << 8) | header[4]; data_type_t data_type = (data_type_t)header[5]; - char bytes[(ROVECOMM_PACKET_MAX_DATA_COUNT/257)*8]; + #if defined(ENERGIA) + char data[ROVECOMM_PACKET_MAX_DATA_COUNT*sizeof(uint8_t)/3]; //Tiva can only support 21,000 uint8_t at once due to memory issues + #elif defined(ARDUINO) && (ARDUINO>100) + char data[ROVECOMM_PACKET_MAX_DATA_COUNT*sizeof(uint8_t)/2]; //Teensy can only support 32,000 uint8_t at once due to memory issues + #endif //Unpack data based on data_type if(data_type == INT32_T) diff --git a/src/RoveCommPacket.h b/src/RoveCommPacket.h index 19666b2..ad31f11 100644 --- a/src/RoveCommPacket.h +++ b/src/RoveCommPacket.h @@ -25,7 +25,11 @@ struct rovecomm_packet uint16_t data_id; uint16_t data_count; uint8_t data_type; - char data[(ROVECOMM_PACKET_MAX_DATA_COUNT/257)*8]; + #if defined(ENERGIA) + char data[ROVECOMM_PACKET_MAX_DATA_COUNT/3*sizeof(uint8_t)]; //Tiva can only support 21,000 uint8_t at once due to memory issues + #elif defined(ARDUINO) && (ARDUINO>100) + char data[ROVECOMM_PACKET_MAX_DATA_COUNT/2*sizeof(uint8_t)]; //Teensy can only support 32,000 uint8_t at once due to memory issues + #endif }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -44,7 +48,11 @@ namespace roveware //Carrys Udp packet data struct _packet { - uint8_t bytes[ROVECOMM_PACKET_HEADER_SIZE + sizeof(uint8_t) * ROVECOMM_PACKET_MAX_DATA_COUNT]; + #if defined(ENERGIA) + uint8_t bytes[ROVECOMM_PACKET_HEADER_SIZE + sizeof(uint8_t) * ROVECOMM_PACKET_MAX_DATA_COUNT/3]; //Tiva can only support 21,000 uint8_t at once due to memory issues + #elif defined(ARDUINO) && (ARDUINO>100) + uint8_t bytes[ROVECOMM_PACKET_HEADER_SIZE + sizeof(uint8_t) * ROVECOMM_PACKET_MAX_DATA_COUNT/2]; //Teensy can only support 32,000 uint8_t at once due to memory issues + #endif }; struct _packet packPacket(const uint16_t data_id, const uint16_t data_count, const data_type_t data_type, const void* data);