2021-05-18 11:29 PM
I am trying to implement a feature to log real time measurement data which comes in to MCU via UART peripheral and them write it into file system to USB stick.
Assume I already have a dedicated task call ReceiverTask which is responsible to receive the measurement data. Then another task called USBTask which is responsible to handle file write/read operation. I want this stream of data from UART written into a file for given period of time and stored in USB.
The only idea that I have is for ReceiverTask to notify USBTask of the request via a queue, and also pass the data buffer once it is full. The USBTask then open and write the buffer to file. Then clear the buffer again and redo the process till the time period expired and finally USBTask close the file. But I am not sure, I believe there should be better approach than this.
Is it possible actually for USBTask once notified of logging request just take the stream data directly from UART peripheral? Without relying on ReceiverTask to acquire the data - just a thought.
Thank you for the patience to read this.
Solved! Go to Solution.
2021-06-08 06:10 AM
Hello @BParh.1 ,
Take a look at the following example provided under Firmware\Projects\STM32F769I_EVAL\Applications\Audio\Audio_playback_and_record
It might help you because recording Audio is a type of real-time data logging.
The approach here is to read the data to an in RAM buffer using DMA, then dumping the values to an already open file descriptor chunk by chunk.
When the write operation is progressing, new "samples" are written to another adjacent RAM buffer (similar to double-buffering).
Signaling that enough data is present can be done by posting a message to a queue feeding the task with the already open file descriptor.
Hope my answer helped you.
BeST Regards,
Walid
2021-06-08 06:10 AM
Hello @BParh.1 ,
Take a look at the following example provided under Firmware\Projects\STM32F769I_EVAL\Applications\Audio\Audio_playback_and_record
It might help you because recording Audio is a type of real-time data logging.
The approach here is to read the data to an in RAM buffer using DMA, then dumping the values to an already open file descriptor chunk by chunk.
When the write operation is progressing, new "samples" are written to another adjacent RAM buffer (similar to double-buffering).
Signaling that enough data is present can be done by posting a message to a queue feeding the task with the already open file descriptor.
Hope my answer helped you.
BeST Regards,
Walid