Bug in FastSerial Library?

Hi guys,


I think I may have found a bug in the FastSerial Library...


In trying to get the CLI test to perform a XBee test, I found that no data was being written to the telemetry port, after checking my APM_Config.h settings, my XBee setup and hooking up my osciloscope up to the telemetry transmit pin, I turned to the code to start debugging...


I found that in the XBee test routine the line that should transmit the data read




and although this line was clearly directing output to serial port 3, the data was in fact coming back on serial port 1, I also found that using Serial3.printf instead worked fine.


I therefore looked in the FastSerial Library source, where these two functions are declared on the base class and found that in the printf_P function, the code was passing stdout instead of a pointer the local _fd member variable to the stdio vfprintf_P function (while in the printf routine this code was correct)


So, in the prinf_P routine, I replaced the line


i = vfprintf_P(stdout, fmt, ap);




i = vfprintf_P(&_fd, fmt, ap);


and this seemed to solve all my problems.


Since stdout seems to default to serial port 1, this would not have caused a problem when using Serial.printf_P and therefore would also only have affected the APM with it's multiple ports.


Any thoughts or collaborations on my findings, my c++ is a bit rusty so wanna be sure I am on the right track.






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

Join diydrones

Email me when people reply –


  • Thank for all the help guys... much appreciated.
  • Developer
    I'm pretty sure that DrZiplock fixed this bug a day or two ago.

    Hopefully you'll see that if you download the latest version of the code from SVN.
  • Oh - also just found another fix/tip....

    In the XBee test code (the test_xbee function in test.pde)....

    Removing the \n from the string being transmitted will make the data match up perfectly with the data packets sent from the X-CTU software... the new line of code will look like:


    Therefore the X-CTU range test results will now show 100% results and not average around 50%

    Hope this helps....

  • Admin

    Nice work! Maybe you should file a bug report on the APM official repository: http://code.google.com/p/ardupilot-mega/issues/list

This reply was deleted.