read RADIO_PARAM_LAST_RSSI and RADIO_PARAM_LAST_PACKET_TIMESTAMP only after the last packet has been read in TSCH: reading the packet might update these values

This commit is contained in:
Atis Elsts 2016-04-25 17:41:56 +03:00
parent 45510f57fa
commit f6967c1f58
2 changed files with 9 additions and 9 deletions

View File

@ -769,20 +769,15 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t))
TSCH_DEBUG_RX_EVENT();
tsch_radio_off(TSCH_RADIO_CMD_OFF_WITHIN_TIMESLOT);
#if TSCH_RESYNC_WITH_SFD_TIMESTAMPS
/* At the end of the reception, get an more accurate estimate of SFD arrival time */
NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &rx_start_time, sizeof(rtimer_clock_t));
#endif
if(NETSTACK_RADIO.pending_packet()) {
static int frame_valid;
static int header_len;
static frame802154_t frame;
radio_value_t radio_last_rssi;
NETSTACK_RADIO.get_value(RADIO_PARAM_LAST_RSSI, &radio_last_rssi);
/* Read packet */
current_input->len = NETSTACK_RADIO.read((void *)current_input->payload, TSCH_PACKET_MAX_LEN);
NETSTACK_RADIO.get_value(RADIO_PARAM_LAST_RSSI, &radio_last_rssi);
current_input->rx_asn = current_asn;
current_input->rssi = (signed)radio_last_rssi;
header_len = frame802154_parse((uint8_t *)current_input->payload, current_input->len, &frame);
@ -790,6 +785,11 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t))
frame802154_check_dest_panid(&frame) &&
frame802154_extract_linkaddr(&frame, &source_address, &destination_address);
#if TSCH_RESYNC_WITH_SFD_TIMESTAMPS
/* At the end of the reception, get an more accurate estimate of SFD arrival time */
NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &rx_start_time, sizeof(rtimer_clock_t));
#endif
packet_duration = TSCH_PACKET_DURATION(current_input->len);
#if LLSEC802154_ENABLED

View File

@ -649,12 +649,12 @@ PT_THREAD(tsch_scan(struct pt *pt))
}
if(is_packet_pending) {
/* Save packet timestamp */
NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t0, sizeof(rtimer_clock_t));
/* Read packet */
input_eb.len = NETSTACK_RADIO.read(input_eb.payload, TSCH_PACKET_MAX_LEN);
/* Save packet timestamp */
NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t0, sizeof(rtimer_clock_t));
/* Parse EB and attempt to associate */
PRINTF("TSCH: association: received packet (%u bytes) on channel %u\n", input_eb.len, current_channel);