Skip to content

Commit af8438e

Browse files
author
Jarkko Paso
authored
Timing tool traces (ARMmbed#2401)
* Added FHSS timing tool traces * Fixed TX done trace * timing tool: use TIMING_TOOL_TRACES flag for traces
1 parent 7938795 commit af8438e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include "MAC/IEEE802_15_4/mac_mcps_sap.h"
3737
#include "MAC/IEEE802_15_4/mac_cca_threshold.h"
3838
#include "MAC/rf_driver_storage.h"
39+
#include "ns_trace.h"
40+
41+
#define TRACE_GROUP "mPDs"
3942

4043
/* Define TX Timeot Period */
4144
// Hardcoded to 1200ms. Should be changed dynamic: (FHSS) channel retries needs longer timeout
@@ -373,6 +376,9 @@ static void mac_sap_cca_fail_cb(protocol_interface_rf_mac_setup_s *rf_ptr, uint
373376

374377
static void mac_sap_no_ack_cb(protocol_interface_rf_mac_setup_s *rf_ptr)
375378
{
379+
#ifdef TIMING_TOOL_TRACES
380+
tr_info("%u no_ack", mac_mcps_sap_get_phy_timestamp(rf_ptr));
381+
#endif
376382
rf_ptr->macRfRadioTxActive = false;
377383
if (rf_ptr->mac_tx_retry < rf_ptr->mac_mlme_retry_max) {
378384
rf_ptr->mac_cca_retry = 0;
@@ -438,6 +444,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
438444
if (rf_ptr->mac_ack_tx_active) {
439445
//Accept direct non crypted acks and crypted only if neighbor is at list
440446
if (rf_ptr->ack_tx_possible) {
447+
#ifdef TIMING_TOOL_TRACES
448+
tr_info("%u TX_start %u", mac_mcps_sap_get_phy_timestamp(rf_ptr), rf_ptr->mac_channel);
449+
#endif
441450
return PHY_TX_ALLOWED;
442451
}
443452

@@ -454,6 +463,9 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
454463
}
455464

456465
if (mac_data_asynch_channel_switch(rf_ptr, rf_ptr->active_pd_data_request)) {
466+
#ifdef TIMING_TOOL_TRACES
467+
tr_info("%u TX_start %u", mac_mcps_sap_get_phy_timestamp(rf_ptr), rf_ptr->mac_channel);
468+
#endif
457469
rf_ptr->active_pd_data_request->initial_tx_channel = rf_ptr->mac_channel;
458470
int8_t channel_cca_threshold = mac_cca_thr_get_dbm(rf_ptr, rf_ptr->mac_channel);
459471
if (CCA_FAILED_DBM != channel_cca_threshold) {
@@ -501,12 +513,17 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
501513
return PHY_RESTART_CSMA;
502514
}
503515
}
504-
516+
#ifdef TIMING_TOOL_TRACES
517+
tr_info("%u TX_start %u", mac_mcps_sap_get_phy_timestamp(rf_ptr), rf_ptr->mac_channel);
518+
#endif
505519
return 0;
506520
}
507521

508522
if (rf_ptr->mac_ack_tx_active) {
509523
mac_data_ack_tx_finish(rf_ptr);
524+
#ifdef TIMING_TOOL_TRACES
525+
tr_info("%u TX_done", mac_mcps_sap_get_phy_timestamp(rf_ptr));
526+
#endif
510527
return 0;
511528
} else {
512529

@@ -531,6 +548,11 @@ static int8_t mac_data_interface_tx_done_cb(protocol_interface_rf_mac_setup_s *r
531548
* PHY_LINK_TX_FAIL either happened during transmission or when waiting Ack -> we must use the CCA count given by PHY.
532549
*/
533550
if ((cca_retry == 0) && (status != PHY_LINK_TX_FAIL)) {
551+
#ifdef TIMING_TOOL_TRACES
552+
if (status != PHY_LINK_CCA_FAIL) {
553+
tr_info("%u TX_done", mac_mcps_sap_get_phy_timestamp(rf_ptr));
554+
}
555+
#endif
534556
cca_retry = 1;
535557
}
536558
rf_ptr->mac_tx_status.cca_cnt += cca_retry;
@@ -970,6 +992,10 @@ int8_t mac_pd_sap_data_cb(void *identifier, arm_phy_sap_msg_t *message)
970992
if (pd_data_ind->data_len < 3) {
971993
return -1;
972994
}
995+
#ifdef TIMING_TOOL_TRACES
996+
tr_info("%u RX_start", mac_pd_sap_get_phy_rx_time(rf_ptr));
997+
tr_info("%u RX_done", mac_mcps_sap_get_phy_timestamp(rf_ptr));
998+
#endif
973999
mac_cca_threshold_event_send(rf_ptr, rf_ptr->mac_channel, pd_data_ind->dbm);
9741000
mac_fcf_sequence_t fcf_read;
9751001
const uint8_t *ptr = mac_header_parse_fcf_dsn(&fcf_read, pd_data_ind->data_ptr);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,23 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
343343
#ifdef FHSS_CHANNEL_DEBUG
344344
tr_info("%"PRIu32" UC %u", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api), fhss_structure->rx_channel);
345345
#endif /*FHSS_CHANNEL_DEBUG*/
346+
#ifdef TIMING_TOOL_TRACES
347+
tr_info("%u UC_change %u", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api), next_channel);
348+
#endif
346349
}
347350
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, next_channel);
348351
#ifdef FHSS_CHANNEL_DEBUG_CBS
349352
if (fhss_bc_switch) {
350353
fhss_bc_switch();
351354
}
352355
#endif /*FHSS_CHANNEL_DEBUG_CBS*/
356+
#ifdef TIMING_TOOL_TRACES
357+
if (fhss_structure->ws->is_on_bc_channel == true) {
358+
tr_info("%u BC_start %u", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api), next_channel);
359+
} else {
360+
tr_info("%u BC_done", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api));
361+
}
362+
#endif
353363
}
354364

355365
static int own_floor(float value)
@@ -392,6 +402,9 @@ static void fhss_event_timer_cb(int8_t timer_id, uint16_t slots)
392402
}
393403
if (queue_size) {
394404
fhss_structure->callbacks.tx_poll(fhss_structure->fhss_api);
405+
#ifdef TIMING_TOOL_TRACES
406+
tr_info("%u TX_poll", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api));
407+
#endif
395408
}
396409
}
397410

@@ -517,6 +530,9 @@ static void fhss_ws_update_uc_channel_callback(fhss_structure_t *fhss_structure)
517530
#ifdef FHSS_CHANNEL_DEBUG
518531
tr_info("%"PRIu32" UC %u %u", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api), next_channel, fhss_structure->ws->uc_slot);
519532
#endif /*FHSS_CHANNEL_DEBUG*/
533+
#ifdef TIMING_TOOL_TRACES
534+
tr_info("%u UC_change %u", fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api), next_channel);
535+
#endif
520536
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, next_channel);
521537
#ifdef FHSS_CHANNEL_DEBUG_CBS
522538
if (fhss_uc_switch) {

0 commit comments

Comments
 (0)