I am developing a code in which I need to print value of structure pointer on serial terminal. Below is my code snippet:
typedef struct
{
uint8_t AB; ///< Address byte (Start byte)
uint8_t CB; ///< Command (index) "ASCII-byte"
uint8_t SI; ///< Action (sub index) "ASCII-byte"
uint8_t PH_1; ///< Payload "ASCII-byte" of the high nibble of the high byte of the raw payload
uint8_t PH_2; ///< Payload "ASCII-byte" of the low nibble of the high byte of the raw payload
uint8_t PL_1; ///< Payload "ASCII-byte" of the high nibble of the low byte of the raw payload
uint8_t PL_2; ///< Payload "ASCII-byte" of the low nibble of the low byte of the raw payload
uint8_t CS1; ///< Checksum "ASCII-byte" of the high nibble of the raw checksum
uint8_t CS0; ///< Checksum "ASCII-byte" of the low nibble of the raw checksum
} rs485_message_t;
int proto485ComposeMsg(rs485_message_t* msg, uint8_t address, uint8_t command, uint8_t action, uint16_t value){
msg->AB = address;
msg->CB = command;
msg->SI = action;
msg->PH_1 = (int)((value & 0xF000) >> 12) ;
msg->PH_2 = (int)((value & 0x0F00) >> 8);
msg->PL_1 = (int)((value & 0x00F0) >> 4) ;
msg->PL_2 = (int)(value & 0x000F);
int checksumRaw = (msg->CB) + (msg->SI) + (msg->PH_1) + (msg->PH_2) + (msg->PL_1) + (msg->PL_2);
setCheckSum(msg);
}
uint8_t proto485Write(uint8_t address, uint8_t command, uint8_t action, uint16_t value)
{
int i = 0;
int stringOne[9] = {int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00)}; ;
rs485_message_t rs485Msg;
proto485ComposeMsg(&rs485Msg, address, command, action, value); // value is passed in "raw" format
Serial.write(rs485Msg); // getting error on this line
}
Please help... Thank you