SlideShare a Scribd company logo
1 of 25
Contiki Libraries
Contiki ringbuf
• Interrupt-safe way to pass bytes from
interrupt to non-interrupt code
• Ring buffer size must be even power of
two
• Ring buffer can only pass bytes (uint8_t)
ringbuf
Void ringbuf_init (struct ringbuf *r,
uint8_t *a, uint8_t size_power_of_two);
int ringbuf_put (struct ringbuf *r, uint8_t c);
int ringbuf_get (struct ringbuf *r);
int ringbuf_size (struct ringbuf *r);
int ringbuf_elements (struct ringbuf *r);
The list library
• Convenient way to keep arbitrary structs on a
list
• Only requirement is a ->next pointer at
beginning of the struct
• Example:
struct my_data {
struct my_data *next;
int some_data;
uint8_t more_data[8];
}
The list library
The list library
void list_init (list_t list)
Initialize a list.
void *list_head (list_t list)
Get a pointer to the first element of a list.
void list_push (list_t list, void *item)
Add an item to the start of the list.
void *list_pop (list_t list)
Remove the first object on a list.
void *list_item_next (void *item)
Get the next item following this item.
The list library
#include "lib/list.h"
struct example_list_struct {
struct *next;
int number;
};
LIST(example_list);
static void my_function(void) {
struct example_list_struct *s;
list_init(example_list);

list_add(example_list, &element1);
list_add(example_list, &element2);
for(s = list_head(example_list); s != NULL; s = list_item_next(s)) {
printf("List element number %dn", s->number);
}
}
The memb library
• Manage a chunk of memory
• A fixed set of structs that can be allocated
and deallocated
• Size of set specified at compile time
The memb library
• MEMB(name, structure, num)

– Declare a memory block.
• void memb_init(struct memb *m)

– Initialize a memory block.
• void *memb_alloc(struct memb *m)

– Allocate a memory block.
• int memb_free(struct memb *m, void *ptr)

– Free a memory block.
The memb library
struct my_structure {
int a, b;
}

MEMB(my_mem, struct my_structure, NUM_STRUCTS);
static void my_function(void) {
memb_init(&my_mem);

struct my_structure *s = memb_alloc(&my_mem);
memb_free(s);
}
Memory allocation with a list
• Typical usage pattern:
– Allocate memory from memb
– Maintain on a list

• Makes it easy to keep track of things to
deallocate them later
Memory allocation with a list
struct example_num {
struct example_num *next;
int num;
};
#define MAX_NUMS 16
LIST(num_table);
MEMB(num_mem, struct example_num, MAX_NUMS);
void init_num(void) {
memb_init(&num_mem);
list_init(neighbor_table);
}
Memory allocation with a list
void add_num(int num) {
e = memb_alloc(&neighbor_mem);
if(e != NULL) {
e->num = num;
list_add(num_table, e);
}
}
struct example_num {
void remove_num(struct example_num *e) {
list_remove(num_table, e);
memb_free(&num_mem, e);
}
Memory allocation with a list
struct example_num *find_num(int num) {
struct example_num *n;
for(n = list_head(num_table); n != NULL; n = list_element_next(n)) {
if(n->num == num) {
return n;
}
}
return NULL;
}
The mmem library
• Managed memory allcator
• Maintains a fragmentation-free memory
area
• Sometimes useful
• Somewhat tricky to use
The mmem library
The mmem library
• MMEM_PTR(m)
– Provide a pointer to managed memory.

• int mmem_alloc(struct mmem *m,
unsigned int size)
– Allocated managed memory.

• void mmem_free(struct mmem *)
– Free managed memory.

• void mmem_init(void)
– Initialize the managed memory library.
The lower layers of the netstack
The radio driver
• Input
– Read packet from the radio into packetbuf
– Call NETSTACK_RDC.input();

• Output
– Prepare radio for sending
• NETSTACK_RADIO.prepare()

– Send the packet
• NETSTACK_RADIO.transmit()
Radio driver gotchas
• Radio driver works in two layers
– Interrupt context
– Contiki context

• SPI bus must be protected
– Disable interrupts during an SPI transfer

• Radio core must be protected
– Maintain flag to avoid interrupts when radio
driver is active
Radio driver energy estimator
• The Contiki energest module keeps track
of energy consumption
–
–
–
–

ENERGEST_ON(ENERGEST_TYPE_LISTEN);
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
queuebufs
• “Enough” queuebufs are needed
• Difficult to say beforehand how many that
is
• Trial and error may be needed
Hands-on: HTTP POST
Build big-red-button.c as a
firmware image
•
•
•
•
•

Copy big-red-button.c from demo.thsq.io
Compile and upload on the hardware
Connect the button
Sniff the packets on screen
Code walk-through
More

http://thingsquare.com

More Related Content

What's hot

Presentation about arrays
Presentation about arraysPresentation about arrays
Presentation about arraysslave of Allah
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationRabin BK
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c languagekiran Patel
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocationGrishma Rajput
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in clavanya marichamy
 
TF.data & Eager Execution
TF.data & Eager ExecutionTF.data & Eager Execution
TF.data & Eager ExecutionModulabs
 
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Kamal Acharya
 
Clojure - Revenge of the Verbs
Clojure - Revenge of the VerbsClojure - Revenge of the Verbs
Clojure - Revenge of the VerbsTim Lossen
 
tf.data: TensorFlow Input Pipeline
tf.data: TensorFlow Input Pipelinetf.data: TensorFlow Input Pipeline
tf.data: TensorFlow Input PipelineAlluxio, Inc.
 

What's hot (13)

C dynamic ppt
C dynamic pptC dynamic ppt
C dynamic ppt
 
Pf presntation
Pf presntationPf presntation
Pf presntation
 
Presentation about arrays
Presentation about arraysPresentation about arrays
Presentation about arrays
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory Allocation
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocation
 
7.basic array
7.basic array7.basic array
7.basic array
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
TF.data & Eager Execution
TF.data & Eager ExecutionTF.data & Eager Execution
TF.data & Eager Execution
 
Complier
ComplierComplier
Complier
 
Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)Dynamic Memory Allocation(DMA)
Dynamic Memory Allocation(DMA)
 
Clojure - Revenge of the Verbs
Clojure - Revenge of the VerbsClojure - Revenge of the Verbs
Clojure - Revenge of the Verbs
 
tf.data: TensorFlow Input Pipeline
tf.data: TensorFlow Input Pipelinetf.data: TensorFlow Input Pipeline
tf.data: TensorFlow Input Pipeline
 

Viewers also liked

Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Adam Dunkels
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2Adam Dunkels
 
Building day 2 upload Building the Internet of Things with Thingsquare and ...
Building day 2   upload Building the Internet of Things with Thingsquare and ...Building day 2   upload Building the Internet of Things with Thingsquare and ...
Building day 2 upload Building the Internet of Things with Thingsquare and ...Adam Dunkels
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1Adam Dunkels
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Adam Dunkels
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1Adam Dunkels
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Adam Dunkels
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 2
Building the Internet of Things with Thingsquare and Contiki - day 2 part 2Building the Internet of Things with Thingsquare and Contiki - day 2 part 2
Building the Internet of Things with Thingsquare and Contiki - day 2 part 2Adam Dunkels
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorialSalah Amean
 
protothread and its usage in contiki OS
protothread and its usage in contiki OSprotothread and its usage in contiki OS
protothread and its usage in contiki OSSalah Amean
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.Dingxin Xu
 
Contiki os timer tutorial
Contiki os timer tutorialContiki os timer tutorial
Contiki os timer tutorialSalah Amean
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networkingguest6972eaf
 
Introduction to Tiny OS
Introduction to Tiny OSIntroduction to Tiny OS
Introduction to Tiny OSSudharsan S
 

Viewers also liked (16)

Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
 
Building day 2 upload Building the Internet of Things with Thingsquare and ...
Building day 2   upload Building the Internet of Things with Thingsquare and ...Building day 2   upload Building the Internet of Things with Thingsquare and ...
Building day 2 upload Building the Internet of Things with Thingsquare and ...
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
Building the Internet of Things with Thingsquare and Contiki - day 2 part 1
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
 
Building the Internet of Things with Thingsquare and Contiki - day 2 part 2
Building the Internet of Things with Thingsquare and Contiki - day 2 part 2Building the Internet of Things with Thingsquare and Contiki - day 2 part 2
Building the Internet of Things with Thingsquare and Contiki - day 2 part 2
 
Contiki Presentation
Contiki PresentationContiki Presentation
Contiki Presentation
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorial
 
protothread and its usage in contiki OS
protothread and its usage in contiki OSprotothread and its usage in contiki OS
protothread and its usage in contiki OS
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
 
Contiki os timer tutorial
Contiki os timer tutorialContiki os timer tutorial
Contiki os timer tutorial
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networking
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networking
 
Introduction to Tiny OS
Introduction to Tiny OSIntroduction to Tiny OS
Introduction to Tiny OS
 

Similar to Advanced Internet of Things firmware engineering with Thingsquare and Contiki - day 1, part 3

Laboratory 04 Circularly Linked ListDownload the following files.docx
Laboratory 04 Circularly Linked ListDownload the following files.docxLaboratory 04 Circularly Linked ListDownload the following files.docx
Laboratory 04 Circularly Linked ListDownload the following files.docxfestockton
 
UNIT 3a.pptx
UNIT 3a.pptxUNIT 3a.pptx
UNIT 3a.pptxjack881
 
exp2-sparse.pptx
exp2-sparse.pptxexp2-sparse.pptx
exp2-sparse.pptxSharika Tr
 
Ctutorial-Pointers 1.ppt
Ctutorial-Pointers 1.pptCtutorial-Pointers 1.ppt
Ctutorial-Pointers 1.pptDEEPAK948083
 
Array , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxArray , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxMrNikhilMohanShinde
 
Pointers and Memory Allocation ESC101.pptx
Pointers and Memory Allocation ESC101.pptxPointers and Memory Allocation ESC101.pptx
Pointers and Memory Allocation ESC101.pptxkrishna50blogging
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptxssuser8e50d8
 
L 5 Numpy final ppt kirti.pptx
L 5 Numpy final ppt kirti.pptxL 5 Numpy final ppt kirti.pptx
L 5 Numpy final ppt kirti.pptxKirti Verma
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxkalai75
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2Prerna Sharma
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.Mohamed Fawzy
 

Similar to Advanced Internet of Things firmware engineering with Thingsquare and Contiki - day 1, part 3 (20)

ch08.ppt
ch08.pptch08.ppt
ch08.ppt
 
Laboratory 04 Circularly Linked ListDownload the following files.docx
Laboratory 04 Circularly Linked ListDownload the following files.docxLaboratory 04 Circularly Linked ListDownload the following files.docx
Laboratory 04 Circularly Linked ListDownload the following files.docx
 
UNIT 3a.pptx
UNIT 3a.pptxUNIT 3a.pptx
UNIT 3a.pptx
 
exp2-sparse.pptx
exp2-sparse.pptxexp2-sparse.pptx
exp2-sparse.pptx
 
PYTHON.pptx
PYTHON.pptxPYTHON.pptx
PYTHON.pptx
 
06 linked list
06 linked list06 linked list
06 linked list
 
dynamic-allocation.pdf
dynamic-allocation.pdfdynamic-allocation.pdf
dynamic-allocation.pdf
 
Ctutorial-Pointers 1.ppt
Ctutorial-Pointers 1.pptCtutorial-Pointers 1.ppt
Ctutorial-Pointers 1.ppt
 
Array , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptxArray , Structure and Basic Algorithms.pptx
Array , Structure and Basic Algorithms.pptx
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
Pointers and Memory Allocation ESC101.pptx
Pointers and Memory Allocation ESC101.pptxPointers and Memory Allocation ESC101.pptx
Pointers and Memory Allocation ESC101.pptx
 
C language introduction
C language introduction C language introduction
C language introduction
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
 
Chp4(ref dynamic)
Chp4(ref dynamic)Chp4(ref dynamic)
Chp4(ref dynamic)
 
L 5 Numpy final ppt kirti.pptx
L 5 Numpy final ppt kirti.pptxL 5 Numpy final ppt kirti.pptx
L 5 Numpy final ppt kirti.pptx
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
 
Introduction linked list
Introduction linked listIntroduction linked list
Introduction linked list
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Advanced Internet of Things firmware engineering with Thingsquare and Contiki - day 1, part 3

  • 2. Contiki ringbuf • Interrupt-safe way to pass bytes from interrupt to non-interrupt code • Ring buffer size must be even power of two • Ring buffer can only pass bytes (uint8_t)
  • 3. ringbuf Void ringbuf_init (struct ringbuf *r, uint8_t *a, uint8_t size_power_of_two); int ringbuf_put (struct ringbuf *r, uint8_t c); int ringbuf_get (struct ringbuf *r); int ringbuf_size (struct ringbuf *r); int ringbuf_elements (struct ringbuf *r);
  • 4. The list library • Convenient way to keep arbitrary structs on a list • Only requirement is a ->next pointer at beginning of the struct • Example: struct my_data { struct my_data *next; int some_data; uint8_t more_data[8]; }
  • 6. The list library void list_init (list_t list) Initialize a list. void *list_head (list_t list) Get a pointer to the first element of a list. void list_push (list_t list, void *item) Add an item to the start of the list. void *list_pop (list_t list) Remove the first object on a list. void *list_item_next (void *item) Get the next item following this item.
  • 7. The list library #include "lib/list.h" struct example_list_struct { struct *next; int number; }; LIST(example_list); static void my_function(void) { struct example_list_struct *s; list_init(example_list); list_add(example_list, &element1); list_add(example_list, &element2); for(s = list_head(example_list); s != NULL; s = list_item_next(s)) { printf("List element number %dn", s->number); } }
  • 8. The memb library • Manage a chunk of memory • A fixed set of structs that can be allocated and deallocated • Size of set specified at compile time
  • 9. The memb library • MEMB(name, structure, num) – Declare a memory block. • void memb_init(struct memb *m) – Initialize a memory block. • void *memb_alloc(struct memb *m) – Allocate a memory block. • int memb_free(struct memb *m, void *ptr) – Free a memory block.
  • 10. The memb library struct my_structure { int a, b; } MEMB(my_mem, struct my_structure, NUM_STRUCTS); static void my_function(void) { memb_init(&my_mem); struct my_structure *s = memb_alloc(&my_mem); memb_free(s); }
  • 11. Memory allocation with a list • Typical usage pattern: – Allocate memory from memb – Maintain on a list • Makes it easy to keep track of things to deallocate them later
  • 12. Memory allocation with a list struct example_num { struct example_num *next; int num; }; #define MAX_NUMS 16 LIST(num_table); MEMB(num_mem, struct example_num, MAX_NUMS); void init_num(void) { memb_init(&num_mem); list_init(neighbor_table); }
  • 13. Memory allocation with a list void add_num(int num) { e = memb_alloc(&neighbor_mem); if(e != NULL) { e->num = num; list_add(num_table, e); } } struct example_num { void remove_num(struct example_num *e) { list_remove(num_table, e); memb_free(&num_mem, e); }
  • 14. Memory allocation with a list struct example_num *find_num(int num) { struct example_num *n; for(n = list_head(num_table); n != NULL; n = list_element_next(n)) { if(n->num == num) { return n; } } return NULL; }
  • 15. The mmem library • Managed memory allcator • Maintains a fragmentation-free memory area • Sometimes useful • Somewhat tricky to use
  • 17. The mmem library • MMEM_PTR(m) – Provide a pointer to managed memory. • int mmem_alloc(struct mmem *m, unsigned int size) – Allocated managed memory. • void mmem_free(struct mmem *) – Free managed memory. • void mmem_init(void) – Initialize the managed memory library.
  • 18. The lower layers of the netstack
  • 19. The radio driver • Input – Read packet from the radio into packetbuf – Call NETSTACK_RDC.input(); • Output – Prepare radio for sending • NETSTACK_RADIO.prepare() – Send the packet • NETSTACK_RADIO.transmit()
  • 20. Radio driver gotchas • Radio driver works in two layers – Interrupt context – Contiki context • SPI bus must be protected – Disable interrupts during an SPI transfer • Radio core must be protected – Maintain flag to avoid interrupts when radio driver is active
  • 21. Radio driver energy estimator • The Contiki energest module keeps track of energy consumption – – – – ENERGEST_ON(ENERGEST_TYPE_LISTEN); ENERGEST_OFF(ENERGEST_TYPE_LISTEN); ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
  • 22. queuebufs • “Enough” queuebufs are needed • Difficult to say beforehand how many that is • Trial and error may be needed
  • 24. Build big-red-button.c as a firmware image • • • • • Copy big-red-button.c from demo.thsq.io Compile and upload on the hardware Connect the button Sniff the packets on screen Code walk-through