Is there a way to know when the last byte of a buffer is shifted out the uart register?
I’m sending a message to a gps receiver that changes it’s baudrate. Once the message is received the gps receiver changes it’s baudrate and then sends and acknowledge message. I need to be able to change the baudrate of my system after sending the message out but before receiving the acknowledge messaged from the receiver.
I’ve tried using:
gpsUart.Write(Globals.gpsTransmitBuffer, 0, gpsTransmitLength)
while(gpsUart.BytesToWrite != 0)
This didn’t work as the BytesToWrite were immediately 0.
A work around is to delay for the amount of time it takes to transmit the number of bytes at the given baudrate…the following code works:
gpsUart.Write(Globals.gpsTransmitBuffer, 0, gpsTransmitLength)
Thread.Sleep(30);
gpsUart.SetActiveSettings(new UartSetting() { BaudRate = 115200 });
while (UbloxDecoder.UbloxResponseMessage(gpsUart, NMEA, (byte)UbloxMessageClass.CFG, (byte)UbloxMessageID.PRT_CFG) != 1)
{ Thread.Sleep(50); }
I feel like the delay method opens myself up to potential issues.
Any feedback is appreciated…Thank you