Skip to content

Commit

Permalink
Documented changes to rovecomm packet size and changed said size to n…
Browse files Browse the repository at this point in the history
…umbers listed in the read me
  • Loading branch information
antrob25 committed Feb 22, 2022
1 parent 65d6ce1 commit 02a8ccd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
3 changes: 0 additions & 3 deletions examples/RoveCommUdp/RoveCommUdp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/RoveCommPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions src/RoveCommPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -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);
Expand Down

0 comments on commit 02a8ccd

Please sign in to comment.