45 #include "net/mac/tsch/tsch.h"
46 #include "net/mac/tsch/tsch-queue.h"
48 #include "net/mac/tsch/tsch-log.h"
49 #include "net/mac/tsch/tsch-packet.h"
50 #include "net/mac/tsch/tsch-schedule.h"
51 #include "net/mac/tsch/tsch-slot-operation.h"
54 #if TSCH_LOG_LEVEL >= 1
55 #define DEBUG DEBUG_PRINT
57 #define DEBUG DEBUG_NONE
61 #if TSCH_LOG_LEVEL >= 2
66 #if (TSCH_LOG_QUEUE_LEN & (TSCH_LOG_QUEUE_LEN - 1)) != 0
67 #error TSCH_LOG_QUEUE_LEN must be power of two
69 static struct ringbufindex log_ringbuf;
70 static struct tsch_log_t log_array[TSCH_LOG_QUEUE_LEN];
71 static int log_dropped = 0;
76 tsch_log_process_pending(
void)
78 static int last_log_dropped = 0;
81 if(log_dropped != last_log_dropped) {
82 printf(
"TSCH:! logs dropped %u\n", log_dropped);
83 last_log_dropped = log_dropped;
85 while((log_index = ringbufindex_peek_get(&log_ringbuf)) != -1) {
86 struct tsch_log_t *log = &log_array[log_index];
87 if(log->link ==
NULL) {
88 printf(
"TSCH: {asn-%x.%lx link-NULL} ", log->asn.ms1b, log->asn.ls4b);
90 struct tsch_slotframe *sf = tsch_schedule_get_slotframe_by_handle(log->link->slotframe_handle);
91 printf(
"TSCH: {asn-%x.%lx link-%u-%u-%u-%u ch-%u} ",
92 log->asn.ms1b, log->asn.ls4b,
93 log->link->slotframe_handle, sf ? sf->size.val : 0, log->link->timeslot, log->link->channel_offset,
94 tsch_calculate_channel(&log->asn, log->link->channel_offset));
98 printf(
"%s-%u-%u %u tx %d, st %d-%d",
99 log->tx.dest == 0 ?
"bc" :
"uc", log->tx.is_data, log->tx.sec_level,
102 log->tx.mac_tx_status, log->tx.num_tx);
103 if(log->tx.drift_used) {
104 printf(
", dr %d", log->tx.drift);
109 printf(
"%s-%u-%u %u rx %d",
110 log->rx.is_unicast == 0 ?
"bc" :
"uc", log->rx.is_data, log->rx.sec_level,
113 if(log->rx.drift_used) {
114 printf(
", dr %d", log->rx.drift);
116 printf(
", edr %d\n", (
int)log->rx.estimated_drift);
118 case tsch_log_message:
119 printf(
"%s\n", log->message);
123 ringbufindex_get(&log_ringbuf);
130 tsch_log_prepare_add(
void)
132 int log_index = ringbufindex_peek_put(&log_ringbuf);
133 if(log_index != -1) {
134 struct tsch_log_t *log = &log_array[log_index];
135 log->asn = current_asn;
136 log->link = current_link;
146 tsch_log_commit(
void)
148 ringbufindex_put(&log_ringbuf);
156 ringbufindex_init(&log_ringbuf, TSCH_LOG_QUEUE_LEN);
void process_poll(struct process *p)
Request a process to be polled.
Private TSCH definitions (meant for use by TSCH implementation files only) ...
Header file for the ringbufindex library
PROCESS_NAME(sample_process)
Process the sampler runs as.
A set of debugging macros for the netstack
#define NULL
The null pointer.