I'm totally new in Arduino and I don't have experience in programming, so I hope you can help me.
I'm making a communication with two Xbee and serial.print() in Simulink, but I need to know the exactly number of bytes transmitted. I'm sending an array where the values change constantly, so every time I send something I need to count the number bytes.
I found the function size_t (long): print() , but I don't have any idea of how to implement it, and the information in the web are very advanced for me.
This is my actual code, it works fine but I need to implement the transmitter count:
int as=0;
Serial1.print('
The rest of the code are declaration of simulink but the Arduinos code is very simple.
Can you give me some idea of how implement that?
Thanks);
for (as=0;as<u_width;as=as+1){
Serial1.print(UART_1[as],6);
if (as!=(u_width-1)){
Serial1.print(',');
}
}
Serial1.println('%');
The rest of the code are declaration of simulink but the Arduinos code is very simple.
Can you give me some idea of how implement that?
Thanks
Instead of serial.print, use either the sprintf() or the snprintf() function to format the data. Then you can determine the exact size of the buffer before sending it anywhere.