Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: main.cpp
- Revision:
- 2:16e45ff70baf
- Parent:
- 1:1311e7af0a5c
- Child:
- 3:69587fadfa87
--- a/main.cpp Sun Nov 16 10:04:00 2014 +0000 +++ b/main.cpp Mon Nov 17 13:11:57 2014 +0000 @@ -27,19 +27,19 @@ dw.readRegister(DW1000_SYS_CFG, 0, (uint8_t*)&conf, 4); pc.printf("%d System Configuration: %X\r\n", i, conf); -# if 0 // to make one node sender and one receiver +# if 1 // to make one node sender and one receiver // Send something uint8_t message[13] = "HELLO WORLD!"; // fill buffer - //sprintf((char*)message, "%d World!!", i); + sprintf((char*)message, "Hello: %d!", i); dw.writeRegister(DW1000_TX_BUFFER, 0, message, 13); uint8_t messagecheck[13]; dw.readRegister(DW1000_TX_BUFFER, 0, messagecheck, 13); pc.printf("Message in buffer: %s\r\n", messagecheck); - uint16_t framelength = 13; // put length of frame + uint16_t framelength = 13+2; // put length of frame dw.writeRegister(DW1000_TX_FCTRL, 0, (uint8_t*)&framelength, 1); - if ((i % 2) == 0) { + if (i == 4) { uint8_t txstart = 0x02; // trigger sending process dw.writeRegister(DW1000_SYS_CTRL, 0, &txstart, 1); } @@ -48,13 +48,17 @@ uint8_t rxenable = 0x01; // start listening dw.writeRegister(DW1000_SYS_CTRL, 1, &rxenable, 1); - //uint8_t frameready = 0; // check if frame received - //while (frameready != 0x20) { - // i++; - // pc.printf("%d Waiting for frame... \r\n", i); - // dw.readRegister(DW1000_SYS_STATUS, 1, &frameready, 13); - // wait(0.5); - //} + uint8_t frameready = 0; // check if frame received + while ((frameready & 0x20) != 0x20) { // while no frame ready + i++; + pc.printf("%d Waiting for frame... \r\n", i); + dw.readRegister(DW1000_SYS_STATUS, 1, &frameready, 1); + pc.printf("%X\r\n", frameready); + uint8_t receive[13] = "NOTHING IN!!"; // get data from buffer + dw.readRegister(DW1000_RX_BUFFER, 0, receive, 13); + pc.printf("Message would be: %s\r\n", receive); + wait(0.5); + } uint8_t receive[13] = "NOTHING IN!!"; // get data from buffer dw.readRegister(DW1000_RX_BUFFER, 0, receive, 13);