Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: main.cpp
- Revision:
- 3:69587fadfa87
- Parent:
- 2:16e45ff70baf
- Child:
- 4:6240b9c7a033
diff -r 16e45ff70baf -r 69587fadfa87 main.cpp --- a/main.cpp Mon Nov 17 13:11:57 2014 +0000 +++ b/main.cpp Mon Nov 17 16:00:28 2014 +0000 @@ -27,22 +27,26 @@ dw.readRegister(DW1000_SYS_CFG, 0, (uint8_t*)&conf, 4); pc.printf("%d System Configuration: %X\r\n", i, conf); -# if 1 // to make one node sender and one receiver +# if 0 // to make one node sender and one receiver // Send something uint8_t message[13] = "HELLO WORLD!"; // fill buffer - sprintf((char*)message, "Hello: %d!", 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); + pc.printf("Message in buffer: %s\r\nHex: 0x", messagecheck); + for (int i = 0;i < 13; i++) + pc.printf("%X", messagecheck[i]); + pc.printf("\r\n", messagecheck[i]); - uint16_t framelength = 13+2; // put length of frame + uint16_t framelength = 13; // put length of frame dw.writeRegister(DW1000_TX_FCTRL, 0, (uint8_t*)&framelength, 1); - if (i == 4) { + //if (i==4) { uint8_t txstart = 0x02; // trigger sending process dw.writeRegister(DW1000_SYS_CTRL, 0, &txstart, 1); - } + pc.printf("Sending...\r\n"); + //} # else // Receive something uint8_t rxenable = 0x01; // start listening @@ -53,10 +57,10 @@ 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 + pc.printf("Status: %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); + pc.printf("Message would be: %s\r\n", receive);*/ wait(0.5); } @@ -64,7 +68,7 @@ dw.readRegister(DW1000_RX_BUFFER, 0, receive, 13); pc.printf("Message received: %s\r\n", receive); # endif - wait(0.5); + return 0; } } \ No newline at end of file