hi,
why is this code only displaying question marks?
when i do
[color=#008080]hal.uartC->printf("%1.5f\n",(double)barometer.get_altitude());
hal.scheduler->delay(1);[/color]
then it works more or less fine…
what i want to do is reading once (in the 50hz loop) the altitude and then
send characterwise the value over uart, one per loop…
but it doesn’t work…
[color=#008080]static int i;
static char baro[8];
if (i==0){
snprintf(baro,8,"%1.5f",(double)barometer.get_altitude());
}else{
hal.uartC->write(baro[i]);
hal.scheduler->delay(1);
i++;
}
if (i >= 7){
i=0;
hal.uartC->print("\n");
}
[/color]
i can and can not find the right way to do this…
i found out…
-no need to call barometer.get_altitude(), this is called by arducopter.pde
-baro_alt, which stores the barometer.get_altitude() value, is something like a long int
-i forgot the terminating 0
-and most important probably, XBee’s working best with 57600 baud, like in the arducopter description…
code above still buggy…
better version:
-no asking for availability, then the xbee starts transmitting automatically
-only need for delay after printing to uart…
[color=#BF4040]#if 1
static int i;
static char baro[16];
if (i==0){
snprintf(baro,16,"%li",baro_alt);
baro[15] = 0;
}
hal.uartC->printf("%c",baro[i]);
hal.scheduler->delay(1);
i++;
if (i >= 15 || baro[i] == 0){
i=0;
hal.uartC->print("\n");
}
like this you can simply communicate with a XBee over uartC. APM now reads incomming words over uart, reads the desired value and sends the value back over uart.