Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Baby-O serial not waiting (solved)


I am working on a Grbl pendant with a Baby-O and a joystick. For communicating with the Grbl controller I need to switch the Tx line ON, send my message and disconnect the Tx line so UGS can send the machine code to the router.

For this I use the following code:

if (((PIND&(1<<DDD7))==0)&&(jog==0))     // Check button            
          Tx_ON;                            // Tx line connected through 4066N Switch
          memcpy_P(send_buffer, PSTR("$J=G91G21 Z1.000F300"), 20);
          serial_send(send_buffer, 20);
          jog = jog+1;
          delay_ms(1);     // If wait for sending did its job this would not be necessary
          Tx_OFF;           // Tx line disconnected

If I look into the Tx output before the switch it shows all the text
If I look into the Tx output after the switch it falls short by 2 characters and without the 0x0A
When I add 1ms delay then it work like a dream

I get the impression that wait_for_sending_to_finish is not waiting
Atmel Studio 7 with Pololu Library



It is difficult for me to help you troubleshoot the issue from your code snippet. Can you post your entire code here?

The wait_for_sending_to_finish() implementation in our example code actually just waits until the software transmission buffer in our serial library is empty. It does not wait for the UART hardware to finish sending the bytes that it has buffered.

- Amanda


That is spot on, in order to prevent the Tx hardware to be disconnected too soon I need that 1ms waiting time, can even be us.

Thanks my system is working now.