Serial Buffer very laggy! Can you explain why?

Hello all,

I am using APM 2.5 with the 3DR radios. I am running the system at 100Hz with a BAUD rate of 57.6kbps
When I send messages from quad to a ground station PC I am able to attain almost flawless communication (only drawback about 100ms lag). However, when I send messages to the quad is when I encounter problems. Through various experiments (which I can detail if anyone is interested) I have already confirmed that the radios can handle the data rates I impose. But when I access the serial buffer by issuing the command serial.available() I noticed that the data doesn't show up in consistency with what I expect. More clearly, we send 11bytes packets every 10ms, but the bytes available on the serial buffer on the APM looks something like this (an abstraction): 
bytesAvail: 11 0 22 0 0 33 8 14 11 ...

here bytesAvail are the bytes available on the serial buffer each time the main loop runs; btw whenever there are bytes available I read them off the buffer. As you can see no information is actually lost but the data doesn't show up when expected. For example from time index 4 to 6 I sent 3 messages each sample time and I only received them all lumped up at time index 6. 

Where do you think this lumped buffering is happening. I looked at SoftwareSerial.cpp .h and at UARTDriver.cpp .h but I didn't see any unneeded buffering. Could this be hardware. If so would it be on the radio side or on the APM side? Can this be fixed?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • Hi,

    You do know the radios break the byte stream into frames and can send only whole frames, right? The 3DR radios can be set to look at or not look at the MAVLink message boundaries when doing this, in order to avoid splitting MAVLink messages over several frames (wasting one if the other is lost etc). It probably may well put multiple messages into a single frame.

    If you replace the radios by a serial cable (but, for experiment's sake, not the USB one), what happens then?



    • Hi Soren,

      thank you for posting.

      Using 3DRRadioConfig v1.0 I deselected the Mavlink checkbox when I configured the radios. By the way I just tried it with it selected and still no go. You say the radios break down the byte stream in whole frames. What is the size of this frame? Can I custom create a frame of my own? How?  Right now, on the ground-station side, I have a PC building 11byte messages (2header bytes + 8bytes actual message + checkSum). I then dump this message every 10ms on the COM port where the radio is connected. I know that there is no issue with the software on the PC because I connected two computers together using the 3DR radios and I get impecable communication (i.e. no unnecessary buffering). Also the software comes from a very reputable company and has been proven to be very reliable (Quanser/QUARC).

      I don't have a pure serial cable on hand but using the USB cable that we use to flash the APM, I also observe perfect data transmission. Meaning, I see 11 bytes available every cycle.

      Below is a fragment of code similar to what I am using to see how many bytes I have available each cycle through the main loop running at 100Hz. This is simplified a lot and showing only the basics operations.

      Many thanks,



      static unsigned char buffer[256]={0};
      int number_of_new_bytes = 0;
      int bytesAvail = hal.uartA->available();
      number_of_new_bytes = bytesAvail;
      if (bytesAvail > 0)
       int i=0;
       while(bytesAvail > 0){
         buffer[i] = hal.uartA->read();
This reply was deleted.


DIY Robocars via Twitter
RT @_JonMyer: 🚨Our 1st AWS DeepRacer Community Race is Underway on 🚨 Join us to find out which member of your commu…
32 minutes ago
Ben Sinnock left a comment on New Zealand DIY Drones Group
"Hi all, glad to be in the group. Apologies in advance but I have a great many questions."
6 hours ago
DIY Robocars via Twitter
17 hours ago
DIY Robocars via Twitter
RT @BackyardRobotcs: After an admittedly long wait, the new Tinymovr R3.3 motor controller is now available 🥳
20 hours ago
DIY Robocars via Twitter
RT @_JonMyer: 🏎 1 hr left before the #AWS #DeepRacer Community 🏎 Top 5 Race tomorrow LIVE on Twitch 1st Place = $50 Amazon GC or AWS Credit…
21 hours ago
DIY Robocars via Twitter
DIY Robocars via Twitter
DIY Robocars via Twitter
DIY Robocars via Twitter
RT @davidfsmith: Race virtually with The AWS DeepRacer Community Race and then join us on the track to see how your times compare on the ph…
DIY Robocars via Twitter
Hiroki Tanaka liked Hiroki Tanaka's profile
Oct 13
DIY Robocars via Twitter
RT @breadcentric: It's now!
Oct 13
DIY Robocars via Twitter
RT @SahikaGenc: Happy Prime Day! AWS DeepRacer is available at a 30% discount today! @sunilmallya #AWSDeepRacer
Oct 13
DIY Robocars via Twitter
RT @chr1sa: Printing all the parts for @DIYRobocars
Oct 11
DIY Robocars via Twitter
RT @chr1sa: Cool new @donkey_car controller app (iOS or Android). Can even do training in-app. Impressive! cc @DIYRobocars…
Oct 11
DIY Robocars via Twitter
RT @chr1sa: Drifting with @donkey_car! This is an example of the fully autonomous @DIYRobocars we race monthly now (virtually, in the shar…
Oct 10