Git Product home page Git Product logo

intertask-communication-esp32's Introduction

InterTask Communication using Multiple Queues

This code shows a basic logic to perform inter-task communication using multiple queues

GPIO Functions:

  • GPIO2 : output ( built-in led on Devkit-V1 )

Understanding the Flow:

  • This code is developed for ESP32 on Embedded C Language using FreeRTOS.
  • FreeRTOS task don't have the provision to return values.
  • That said, one can either use global variables to track changes in values but is not the most appropriate way.
  • This is where "Queue" comes into picture, enabling inter-task communications.

Queues in FreeRTOS:

  • As the name suggests, Queues acts like a stacked list and mostly preferred in FIFO ( First In First Out ).
  • There are various Queue operations available, but in this program I will cover the basic functions.

Create a Queue-

  • xQueueCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize );
  • uxQueueLength --> The maximum number of items the queue can hold at any one time.
  • uxItemSize --> The size, in bytes, required to hold each item in the queue.
  • Example --> xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
  • If created successfully, returns the handle or "NULL" otherwise.

Delete a Queue-

  • vQueueDelete( QueueHandle_t xQueue );
  • Deletes the queue with the provided handle "xQueue".

Send messages on Queue-

  • xQueueSend( QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait );
  • xQueue --> The handle to the queue on which the item is to be posted.
  • pvItemToQueue --> A pointer to the item that is to be placed on the queue.
  • xTicksToWait --> The maximum amount of time the task should block waiting for space to become available on the queue, should it already be full.
  • Returns "pdTRUE" if the item was successfully posted, otherwise "errQUEUE_FULL".

Receive messages on Queue-

  • *xQueueReceive( QueueHandle_t xQueue, void pvBuffer, TickType_t xTicksToWait );
  • xQueue --> The handle to the queue on which the item is to be received.
  • pvBuffer --> Pointer to the buffer into which the received item will be copied.
  • xTicksToWait --> The maximum amount of time the task should block waiting for an item to receive should the queue be empty at the time of the call.
  • Returns "pdTRUE" if an item was successfully received from the queue, otherwise "pdFALSE".

intertask-communication-esp32's People

Contributors

negasonicx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.