Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: MMRanging/MMRanging.cpp
- Revision:
- 32:041dd02e0e3b
- Parent:
- 31:6f76f3d518ac
- Child:
- 33:6ea4c3dd504d
diff -r 6f76f3d518ac -r 041dd02e0e3b MMRanging/MMRanging.cpp --- a/MMRanging/MMRanging.cpp Mon Dec 01 13:04:18 2014 +0000 +++ b/MMRanging/MMRanging.cpp Tue Dec 02 13:32:34 2014 +0000 @@ -17,27 +17,27 @@ void MMRanging::callbackRX() { RX_timestamp = dw.getRXTimestamp(); - dw.receiveString(messageRX); + rangingframe RX; + dw.readRegister(DW1000_RX_BUFFER, 0, (uint8_t*)&RX, dw.getFramelength()); // get data from buffer - rangingframe* RX = (rangingframe*)messageRX; - switch (RX->type) { + switch (RX.type) { case 1: - rangingtimingsReceiver[RX->sequence_number][0] = dw.getRXTimestamp(); + rangingtimingsReceiver[RX.sequence_number][0] = dw.getRXTimestamp(); TX.type = 2; - TX.sequence_number = RX->sequence_number; + TX.sequence_number = RX.sequence_number; TX.time_difference_receiver = 0; dw.sendFrame((uint8_t*)&TX, 10); break; case 2: - rangingtimingsSender[RX->sequence_number][1] = dw.getRXTimestamp(); + rangingtimingsSender[RX.sequence_number][1] = dw.getRXTimestamp(); break; case 3: TX.type = 4; - TX.time_difference_receiver = rangingtimingsReceiver[TX.sequence_number][1] - rangingtimingsReceiver[TX.sequence_number][0]; + TX.time_difference_receiver = 0;//rangingtimingsReceiver[TX.sequence_number][1] - rangingtimingsReceiver[TX.sequence_number][0]; dw.sendFrame((uint8_t*)&TX, 10); break; case 4: - tofs[RX->sequence_number] = rangingtimingsSender[RX->sequence_number][1] - rangingtimingsSender[RX->sequence_number][0] - RX->time_difference_receiver; + tofs[RX.sequence_number] = /*rangingtimingsSender[RX.sequence_number][1] - rangingtimingsSender[RX.sequence_number][0] - */RX.time_difference_receiver; //tofs[RX->sequence_number] = (rangingtimingsSender[RX->sequence_number][1] - rangingtimingsSender[RX->sequence_number][0] - RX->time_difference_receiver) >> 1; break; default : break; @@ -47,8 +47,7 @@ event[event_i][0] = '!'; event[event_i][1] = 'R'; event[event_i][2] = ' '; - for(int i = 0; i < 10; i++) - event[event_i][i+3] = messageRX[i]; + sprintf(&event[event_i][3], "%d %d", RX.sequence_number, RX.type); if (event_i == 8) event_i = 0; else @@ -75,8 +74,6 @@ event[event_i][1] = 'S'; event[event_i][2] = ' '; sprintf(&event[event_i][3], "%d %d", TX.sequence_number, TX.type); - //for(int i = 0; i < 10; i++) - // event[event_i][i+3] = message[i]; if (event_i == 8) event_i = 0; else