Running TauLabs software on hardware that isn't supported? Work with others to get a new platform supported.
no avatar
User

droney

Posts

20

Joined

Fri Mar 27, 2015 10:25 am

BrainFPV OSD and Flight Statistics

by droney » Mon Dec 07, 2015 12:45 am

Thought I would start a new topic for BrainFPV OSD and flight statistics discussions.

Love the flight statistics.... any chance you can add flight time to the stats list? Preferably actual motor run time, but the same time displayed during flight would be OK too. Thanks!
User avatar
User

shred

Posts

287

Joined

Fri Mar 14, 2014 11:50 am

Re: BrainFPV OSD and Flight Statistics

by shred » Mon Dec 07, 2015 9:05 am

droney wrote:Thought I would start a new topic for BrainFPV OSD and flight statistics discussions.

Love the flight statistics.... any chance you can add flight time to the stats list? Preferably actual motor run time, but the same time displayed during flight would be OK too. Thanks!


Good idea. There is already an open issue for this: https://github.com/BrainFPV/TauLabs/issues/37
no avatar
User

droney

Posts

20

Joined

Fri Mar 27, 2015 10:25 am

Compiling brain fw and sprintf for floats issue

by droney » Sat Jan 02, 2016 10:09 pm

I've modified osd_menu.c to add the vtol_follower settings, but I am having trouble with sprintf displaying floating point numbers. sprintf followed by the write_string calls is displaying some very odd numbers, not anything close to the actual value. If I convert the floats to ints using modulo and multiplies, I can confirm the data is correct so I know the sprintf is the issue. After a little research it may be due to the EABI stack alignment issue. I noticed flight/PiOS/Common/printf2.c employs a 'USE_NEWLIB' define to enable the stack alignment code. If I enable this define, the vtol follower floating point settings display properly, but some (not all) other floating point sprintfs break (voltage, current, some PIDs) on the various other settings pages supported by brain menu feature. A make fw_brain_clean followed by a make brain, which compiles cleanly, does not resolve the issue. Anyone have some thoughts on resolving this? Thanks!!
no avatar
User

droney

Posts

20

Joined

Fri Mar 27, 2015 10:25 am

Re: BrainFPV OSD and Flight Statistics

by droney » Tue Jan 05, 2016 1:07 pm

droney wrote:I've modified osd_menu.c to add the vtol_follower settings, but I am having trouble with sprintf displaying floating point numbers. sprintf followed by the write_string calls is displaying some very odd numbers, not anything close to the actual value. If I convert the floats to ints using modulo and multiplies, I can confirm the data is correct so I know the sprintf is the issue. After a little research it may be due to the EABI stack alignment issue. I noticed flight/PiOS/Common/printf2.c employs a 'USE_NEWLIB' define to enable the stack alignment code. If I enable this define, the vtol follower floating point settings display properly, but some (not all) other floating point sprintfs break (voltage, current, some PIDs) on the various other settings pages supported by brain menu feature. A make fw_brain_clean followed by a make brain, which compiles cleanly, does not resolve the issue. Anyone have some thoughts on resolving this? Thanks!!


Well it appears the USE_NEWLIB code in flight/PiOS/Common/printf2.c actually has a bug, resulting in stack misalignments for some calls of printf/sprintf when floating point prints are desired. Here is the code snip...

Code: Select all
#ifdef USE_NEWLIB
            char *cptr = (char *) varg ;  //lint !e740 !e826  convert to double pointer
            uint caddr = (uint) cptr ;
            if ((caddr & 0xF) != 0) {
               cptr += 4 ;
            }
            double *dblptr = (double *) cptr ;  //lint !e740 !e826  convert to double pointer
#else
            double *dblptr = (double *) varg ;  //lint !e740 !e826  convert to double pointer
#endif


Notice the argument pointer is incremented by 4 if any of the lower four bits of the address are set. I believe the pointer should only be adjusted if bit 2 is set ( if((caddr&0x4)!=0) ). After making this change in printf2.c and defining USE_NEWLIB, all floating point prints work properly in osd_menu.c and onscreendisplay.c.

I do not see printf2.c in the taulabs code base, so I must assume this is added with the brainfpv release and therefore I will file an issue against it.

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron