crazyflie 2.0 eprintf float values

Firmware/software/electronics/mechanics
Post Reply
almaz_1c
Member
Posts: 43
Joined: Tue Dec 09, 2014 12:58 pm

crazyflie 2.0 eprintf float values

Post by almaz_1c »

Hello!I want to log out from quadcopter via expansion board using usart.
Function

Code: Select all

void usart_send_char(uint8_t Data)
{
  /* Transmit Data */
	while((USART2->SR & USART_FLAG_TXE) == 0);
	USART2->DR = Data;
}
work as expected and send characters via TX2 pin on expansion board.
Now i try to implement eprintf as explained in eprintf.c file:

Code: Select all

int consolePutc(int c)
{
    usart_send_char((uint8_t)c);
    return (unsigned char)c;
}

#define consolePrintf(FMT, ...) eprintf(consolePutc, FMT, ## __VA_ARGS__)
So problem is that consolePrintf don't send correct float values. When i call:

Code: Select all

consolePrintf("%s, %d, %f\r\n", "asd", 777, 2.2 );
I get output:

Code: Select all

asd, 777, 0.0
It seems like

Code: Select all

          num = va_arg(ap, double);
always return zero.
Where i am mistaken?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: crazyflie 2.0 eprintf float values

Post by arnaud »

Hi,

I just tested to compile eprintf in my pc and run a test in the copter and for me it works. This is what I tested:

Code: Select all

diff --git a/modules/src/system.c b/modules/src/system.c
index 3e00801..2f01aaf 100644
--- a/modules/src/system.c
+++ b/modules/src/system.c
@@ -137,6 +137,8 @@ void systemTask(void *arg)
               *((int*)(MCU_ID_ADDRESS+8)), *((int*)(MCU_ID_ADDRESS+4)),
               *((int*)(MCU_ID_ADDRESS+0)), *((short*)(MCU_FLASH_SIZE_ADDRESS)));
 
+  DEBUG_PRINT("%s, %d, %f\r\n", "asd", 777, 2.2);
+
   commanderInit();
   stabilizerInit();
   expbrdInit();
And I got the correct thing in the console:

Code: Select all

SYS: asd, 777, 2.200000
Maybe you can try the same code to see if it works. I never saw this problem before, did you modify eprintf or maybe change the compilation option (we have not tested much the hardware floating point unit).
Post Reply