Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Consider the following method to send 2 variable at the same time:</p> <pre><code> int xpos, ypos; char x_tx_buffer[20], y_tx_buffer[20]; char x_dummy_buffer[20]; char y_dummy_buffer[20]; char *p_x_tx_buffer, *p_y_tx_buffer; sprintf(x_dummy_buffer,"%d", xposs); sprintf(y_dummy_buffer,"%d", yposs); p_x_tx_buffer = &amp;x_tx_buffer[0]; *p_x_tx_buffer++ = x_dummy_buffer[0]; *p_x_tx_buffer++ = x_dummy_buffer[1]; *p_x_tx_buffer++ = x_dummy_buffer[2]; *p_x_tx_buffer++ = x_dummy_buffer[3]; p_y_tx_buffer = &amp;y_tx_buffer[0]; *p_y_tx_buffer++ = y_dummy_buffer[0]; *p_y_tx_buffer++ = y_dummy_buffer[1]; *p_y_tx_buffer++ = y_dummy_buffer[2]; *p_y_tx_buffer++ = y_dummy_buffer[3]; uart0_filestream = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_NDELAY); //Open in non blocking read/write mode if (uart0_filestream == -1) { //ERROR - CAN'T OPEN SERIAL PORT printf("Error - Unable to open UART. Ensure it is not in use by another application\n"); } if (uart0_filestream != -1) { int countx = write(uart0_filestream, &amp;x_tx_buffer[0], (p_x_tx_buffer - &amp;x_tx_buffer[0])); //Filestream, bytes to write, number of bytes to write int county = write(uart0_filestream, &amp;y_tx_buffer[0], (p_y_tx_buffer - &amp;y_tx_buffer[0])); //Filestream, bytes to write, number of bytes to write if (countx &lt; 0 || county &lt; 0) { printf("UART TX error\n"); } } close(uart0_filestream); </code></pre> <p>You can send a max of 8 bytes at a time. Keep that in mind and with that you can modify the about code to send your x and y values in the same uart0_filestream.</p> <p>Good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload