59 #if (TSCH_LOG_QUEUE_LEN & (TSCH_LOG_QUEUE_LEN - 1)) != 0 60 #error TSCH_LOG_QUEUE_LEN must be power of two 62 static struct ringbufindex log_ringbuf;
63 static struct tsch_log_t log_array[TSCH_LOG_QUEUE_LEN];
64 static int log_dropped = 0;
65 static int log_active = 0;
72 static int last_log_dropped = 0;
75 if(log_dropped != last_log_dropped) {
76 printf(
"[WARN: TSCH-LOG ] logs dropped %u\n", log_dropped);
77 last_log_dropped = log_dropped;
80 struct tsch_log_t *log = &log_array[log_index];
81 if(log->link == NULL) {
82 printf(
"[INFO: TSCH-LOG ] {asn %02x.%08lx link-NULL} ", log->asn.ms1b, log->asn.ls4b);
85 printf(
"[INFO: TSCH-LOG ] {asn %02x.%08lx link %2u %3u %3u %2u %2u ch %2u} ",
86 log->asn.ms1b, log->asn.ls4b,
87 log->link->slotframe_handle, sf ? sf->size.val : 0,
88 log->burst_count, log->link->timeslot + log->burst_count, log->link->channel_offset,
93 printf(
"%s-%u-%u tx ",
98 printf(
", len %3u, seq %3u, st %d %2d",
99 log->tx.datalen, log->tx.seqno, log->tx.mac_tx_status, log->tx.num_tx);
100 if(log->tx.drift_used) {
101 printf(
", dr %3d", log->tx.drift);
106 printf(
"%s-%u-%u rx ",
107 log->rx.is_unicast == 0 ?
"bc" :
"uc", log->rx.is_data, log->rx.sec_level);
111 printf(
", len %3u, seq %3u",
112 log->rx.datalen, log->rx.seqno);
113 printf(
", edr %3d", (
int)log->rx.estimated_drift);
114 if(log->rx.drift_used) {
115 printf(
", dr %3d\n", log->rx.drift);
120 case tsch_log_message:
121 printf(
"%s\n", log->message);
135 if(log_index != -1) {
136 struct tsch_log_t *log = &log_array[log_index];
137 log->asn = tsch_current_asn;
138 log->link = current_link;
139 log->burst_count = tsch_current_burst_count;
140 log->channel = tsch_current_channel;
152 if(log_active == 1) {
162 if(log_active == 0) {
172 if(log_active == 1) {
void ringbufindex_init(struct ringbufindex *r, uint8_t size)
Initialize a ring buffer.
void tsch_log_process_pending(void)
Process pending log messages.
Header file for the ringbufindex library
int ringbufindex_peek_get(const struct ringbufindex *r)
Return the index of the first element which will be removed if calling ringbufindex_get.
void tsch_log_init(void)
Initialize log module.
802.15.4e slotframe (contains links)
struct tsch_log_t * tsch_log_prepare_add(void)
Prepare addition of a new log.
const linkaddr_t linkaddr_null
The null link-layer address.
void log_lladdr_compact(const linkaddr_t *lladdr)
Logs a link-layer address with a compact format.
void tsch_log_stop(void)
Stop logging module.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
struct tsch_slotframe * tsch_schedule_get_slotframe_by_handle(uint16_t handle)
Looks up a slotframe by handle.
void process_poll(struct process *p)
Request a process to be polled.
#define PROCESS_NAME(name)
Declare the name of a process.
Main API declarations for TSCH.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
void tsch_log_commit(void)
Actually add the previously prepared log.
int ringbufindex_get(struct ringbufindex *r)
Remove the first element and return its index.
int ringbufindex_peek_put(const struct ringbufindex *r)
Check if there is space to put an element.
Header file for the logging system
int ringbufindex_put(struct ringbufindex *r)
Put one element to the ring buffer.