need to get values from a function with structure pointer argument and print on serial terminal 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;     ///&lt; Address byte (Start byte)
  uint8_t CB;     ///&lt; Command (index) "ASCII-byte"
  uint8_t SI;     ///&lt; Action (sub index) "ASCII-byte"
  uint8_t PH_1;    ///&lt; Payload "ASCII-byte" of the high nibble of the high byte of the raw payload
  uint8_t PH_2;    ///&lt; Payload "ASCII-byte" of the low nibble of the high byte of the raw payload
  uint8_t PL_1;    ///&lt; Payload "ASCII-byte" of the high nibble of the low byte of the raw payload
  uint8_t PL_2;    ///&lt; Payload "ASCII-byte" of the low nibble of the low byte of the raw payload
  uint8_t CS1;    ///&lt; Checksum "ASCII-byte" of the high nibble of the raw checksum
  uint8_t CS0;    ///&lt; 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-&gt;AB = address;   
  msg-&gt;CB = command;
  msg-&gt;SI = action;
  msg-&gt;PH_1 = (int)((value &amp; 0xF000) &gt;&gt; 12) ; 
  msg-&gt;PH_2 = (int)((value &amp; 0x0F00) &gt;&gt; 8); 
  msg-&gt;PL_1 = (int)((value &amp; 0x00F0) &gt;&gt; 4) ; 
  msg-&gt;PL_2 = (int)(value &amp; 0x000F);     
  int checksumRaw = (msg-&gt;CB) + (msg-&gt;SI) + (msg-&gt;PH_1) + (msg-&gt;PH_2) + (msg-&gt;PL_1) + (msg-&gt;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(&amp;rs485Msg, address, command, action, value); // value is passed in "raw" format
  Serial.write(rs485Msg);       // getting error on this line
}


Please help... Thank you
You can't just print a structure. After all, how is the program supposed to know how it is supposed to be displayed?

Do you want just the raw data, or do you want it formatted in a human readable form?

For just the raw data you need to cast the pointer to a type that can be printed as an array. For example:

Serial.write((uint8_t *)&amp;rs485Msg, sizeof(struct rs485_message_t));


To print it in a human readable form you will need to take each value that you want to see and print it separately with any data manipulation that you may want.  For example:

Serial.print("Checksum 0: ");
Serial.println(rs485Msg.CS0, HEX);


Another thing you can do is to change your structure into a class and inherit the Printable class.  You can then implement the size_t printTo(Print &amp;p); member function which sends the data to the p object for printing in the format you want.  Then you can just print it directly as you are trying to do in your code.