cu-ecen-aeld / final-project-atharvdesai1996

final-project-atharvdesai1996 created by GitHub Classroom
0 stars 0 forks source link

Implementing Queues & Locking Mechanisms for Intertask Communication in FreeRTOS #10

Closed atharvdesai1996 closed 4 years ago

atharvdesai1996 commented 4 years ago

ToDo: Implementing Queues & Locking Mechanism for intertask communication in FreeRTOS Application

DoD: These tools will be required to be implemented so that the TMP-102 readings and Fingerprint Matched Strings can be sent through the common UART port of Tiva to the BeagleBone Server

atharvdesai1996 commented 4 years ago

### Working Principle of Queues in my Application

--> Here, in my FreeRTOS application, I am using Queues to establish Intertask communication between Fingerprint sensor and Temperature sensor

--> I implemented FreeRTOS queue functions namely xQueueSend and xQueueReceive to acquire 10 sensor readings in my xQueueSend function of Temperature task and then transfer those readings through Fingerprint task only when my Fingerprint is matched

atharvdesai1996 commented 4 years ago

Importance of xQueueReset

I realized that I will have to use xQueueReset function too to make my queue hold the most recent 10 temperature readings.

I have attached the screenshots of both :

q_reset_imp

--> Without xQueueReset where my queue gets full quickly with first 10 readings and of temperature sensor and feeds old readings only to the Fingerprint task xQueueReceive Function

withqueue_reset-imp2

--> Using xQueueReset , my queue is able to hold the most recent value of temperature in the queue and as soon as the Fingerprint is matched the value gets sent to UART through my xQueueReceive Function

aakshajaywant commented 4 years ago

### Semaphore Locking Mechanism Implementation

--> Implemented locking mechanism using semaphores.

--> It involves xSemaphoreTake and xSemaphoreGive.

--> Earlier I was using a global flag to indicate that the fingerprint is matched used in the fingerprint task to send temperature readings to the server.

--> Therefore, the critical section was protected by replacing my 'fmatchflag' in the screenshots below by Semaphore sema1 sema2

Code