Skip to content

Commit 3cccfa5

Browse files
e-rknashif
authored andcommitted
drivers: ieee802154: nrf5: prevent negative timestamps
The nrf-802154 driver may be unable to acquire a valid timestamp under rare conditions. In such case, the nrf_802154_received_timestamp_raw reports time=NRF_802154_NO_TIMESTAMP. The shim implementation must not calculate the PHR timestamp when receiving this value, because doing so results in an assert in ptp_packet.h due to a negative time value. When the driver is unable to capture the timestamp, the packet is assigned zero as its timestamp. Signed-off-by: Rafał Kuźnia <[email protected]>
1 parent 97e363f commit 3cccfa5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,8 +1121,12 @@ void nrf_802154_received_timestamp_raw(uint8_t *data, int8_t power, uint8_t lqi,
11211121
nrf5_data.rx_frames[i].lqi = lqi;
11221122

11231123
#if defined(CONFIG_NET_PKT_TIMESTAMP)
1124-
nrf5_data.rx_frames[i].time =
1125-
nrf_802154_timestamp_end_to_phr_convert(time, data[0]);
1124+
if (time != NRF_802154_NO_TIMESTAMP) {
1125+
nrf5_data.rx_frames[i].time =
1126+
nrf_802154_timestamp_end_to_phr_convert(time, data[0]);
1127+
} else {
1128+
nrf5_data.rx_frames[i].time = 0;
1129+
}
11261130
#endif
11271131

11281132
nrf5_data.rx_frames[i].ack_fpb = nrf5_data.last_frame_ack_fpb;

0 commit comments

Comments
 (0)