Looking to get a handle on how to deal with short ints when sending 3 ints.
Right now my code looks something like this:
This works great for single bytes, but has a hard cap on the number I am needing to send to the teensy device. I know short ints are int16 and they are 2 bytes wide. How they are put together later I have no idea
The data I am sending is over python. I read teensy uses little-endian so I have < follow by the hhh for short:
I assume I need to join the different bytes to create the short int - so I guess what do I need to do to make that happen?
Right now my code looks something like this:
Code:
#define RX_SIZE 6
int8_t rx[RX_SIZE];
void handle_host_commands() {
while (Serial1.available()) {
Serial1.readBytes((uint8_t*) rx, RX_SIZE);
if (rx[0] == -2) {
This works great for single bytes, but has a hard cap on the number I am needing to send to the teensy device. I know short ints are int16 and they are 2 bytes wide. How they are put together later I have no idea
The data I am sending is over python. I read teensy uses little-endian so I have < follow by the hhh for short:
Code:
pack( '<hhh', -2, 123, 1123 ) # b'\xfe\xff{\x00c\x04'
I assume I need to join the different bytes to create the short int - so I guess what do I need to do to make that happen?