Hi, I have used the serial ports separately, but now my application requieres 2 serial ports, but i fail.
i have tested separatedly and works!, the first device is an IMU at 57600 baudrate, the other is a xbee working at 115200, i work with interrupts and the scanf. but i dont know if is not possible to use 2 interruptions? could someone tell me what could be happening? because its rare, the IMU is always connected to mbed, and scanf works good, then the xbee starts the transmission and the scanf of IMU sucks :( and the scanf of xbee works properly, if i cancell the attach of IMU the xbee also works good, but at same time fail.
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
DigitalOut dg(p21);
DigitalOut dh(p22);
Serial imu(p9,p10);// tx,rx
Serial xbee(p13,p14);
float Y=0,P=0,R=0;
int pd=0,rd=0,yd=0,act=0;
void rximu() {
led3 = !led3;
dg=1;
imu.scanf("#YPR=%f,%f,%f\r\n",&Y,&P,&R);
if(R>0){
led1=1;
}else{
led1=0;
}
dg=0;
}
void rxbee() {
led2 = !led2;
dh=1;
xbee.scanf("X:%d,%d,%d,%d\r",&pd,&rd,&yd,&act);
if(act==1){
led4=1;
}else{
led4=0;
}
dh=0;
}
int main() {
imu.baud(57600);
xbee.baud(115200);
imu.attach(&rximu);
xbee.attach(&rxbee);
while(1) {
}
}
Thanks
I'am new to mbed and C.
Since many hours i try to implement MODSERIAL into a library. Using MODSERIAL inside main.cpp is quite easy and works very well. But when I try to convert the code into a library it does not work. Even when I reduce the code to a minimum it compiles but it does not run (mled1 does not blink).
main.cpp
SBUS.h
SBUS.cpp
Do I miss something? How to use the .attach functionality?
thanks