I want to write in python something like this: Fill the array with values like bellow and send it like bytes array.
#define ADDR_1 0x5
#define ADDR_2 0x1288
#define CMD 0x63
typedef struct
{
uint8_t addr1;
uint8_t addr2[2];
uint8_t cmd;
}tAddress;
typedef union
{
tAddress Values;
uint8_t array[4]
}Temp
Temp packet;
packet.tAddress.addr1 = ADDR_1;
packet.tAddress.addr2 = ADDR_2;
packet.tAddress.cmd = CMD;
SendBytes(packet.array);
Could you help me please how to do this?
Best regards, Jan.
packet=[ADDR1.to_bytes(1,byteorder = 'big'), ADDR2.to_bytes(2,byteorder = 'big'),CMD.to_bytes(1,byteorder = 'big')]
but now I need take this packet and pass it to function with bytearray param -how can I do that? def crc16(self, data : bytearray, offset , length): – WITC Oct 29 '20 at 21:04