FreeRTOS API Stream Buffers

Started by tha, December 29, 2021, 05:06:38 PM

Previous topic - Next topic

tha

https://www.freertos.org/xStreamBufferSetTriggerLevel.html

xStreamBufferSetTriggerLevel()
[RTOS Stream Buffer API]

stream_buffer.h

BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
                                         size_t xTriggerLevel );


A stream buffer's trigger level คือจำนวนของ bytes ที่ต้องอยู่ใน the stream buffer ก่อนที่ a task ที่ถูกบล็อกบน the stream buffer เพื่อรอสำหรับ data จะถูกเคลื่อนออกจาก the blocked state. ตัวอย่างเช่น, ถ้า a task ถูกบล็อกบนการอ่านของ an empty stream buffer ที่มี a trigger level เท่ากับ 1 ดังนั้น the task จะถูกปลดบล็อกเมื่อ a single byte ถูกเขียนไปยัง the buffer หรือ the task's block time หมดเวลาลง. อีกตัวอย่างหนึ่ง, ถ้า a task ถูกบล็อกบนการอ่านของ an empty stream buffer ที่มี a trigger level เท่ากับ 10 ดังนั้น the task จะไม่ถูกปลดบล็อกจนกระทั่ง the stream buffer บรรจุอย่างน้อย 10 bytes หรือ the task's block time หมดเวลาลง. ถ้า a reading task's block time หมดเวลาลงก่อนที่ the trigger level จะถูกถึง ดังนั้น the task จะยังคงรับตามจำนวน bytes ที่มีให้ใช้ประโยชน์จริงๆ. การเซ็ต a trigger level เท่ากับ 0 จะส่งผลให้ a trigger level เท่ากับ 1 กำลังถูกใช้. มันไม่ถูกต้องในการระบุ a trigger level ที่ใหญ่กว่า the buffer size.

A trigger level ถูกเซ็ตเมื่อ the stream buffer ถูกสร้าง, และสามารถถูกโมดิฟายด์โดยใช้ xStreamBufferSetTriggerLevel().

Stream buffer functionality ถูกเปิดการใช้งานโดยการ include ไฟล์ the FreeRTOS/source/stream_buffer.c source file ใน the build.

Parameters:

     xStreamBuffer               The handle of the stream buffer ที่กำลังถูกอัฟเดต.

     xTriggerLevel                The new trigger level สำหรับ the stream buffer.

Returns:

     ถ้า xTriggerLevel น้อยกว่าหรือเท่ากันกับ the stream buffer's length ดังนั้น the trigger level จะถูกอัฟเดตและ pdTRUE จะถูก
     ส่งคืนกลับ. ถ้าเป็นอย่างอื่น pdFALSE จะถูกส่งคืนกลับ.

tha

https://www.freertos.org/xStreamBufferReset.html

xStreamBufferReset()
[RTOS Stream Buffer API]

stream_buffer.h

BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer );

รีเซ็ต a stream buffer ไปเป็นสภาวะเริ่มต้นของมัน, ว่างเปล่า. data ใดๆที่อยู่ใน the stream buffer จะถูกละทิ้ง. A stream buffer สามารถถูกรีเซ็ตเฉพาะถ้าไม่มี taks ถูกบล็อกรอเพื่ออย่างใดอย่างหนึ่ง ส่งไปยัง หรือ รับจาก the stream buffer.

Stream buffer functionality ถูกเปิดการใช้งานโดยการ include ไฟล์ the FreeRTOS/source/stream_buffer.c source file ใน the build.

Parameters:

     xStreamBuffer               The handle of the stream buffer ที่กำลังถูกรีเซ็ต.

Returns:

     ถ้า the stream buffer ถูกรีเซ็ตดังนั้น pdPASS จะถูกส่งคืนกลับ. ถ้ามี taks ถูกบล็อกรอเพื่อ ส่งไปยัง หรือ รับจาก the stream
     buffer ดังนั้น the stream buffer จะไม่รีเซ็ตและ pdFAIL จะถูกส่งคืนกลับ.

tha

https://www.freertos.org/xStreamBufferIsEmpty.html

xStreamBufferIsEmpty()
[RTOS Stream Buffer API]

stream_buffer.h

BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer );

สอบถาม a stream buffer เพื่อดูว่ามันว่างเปล่าหรือไม่. A stream buffer จะว่างเปล่าถ้ามันไม่บรรจุ data ใดๆ.

Stream buffer functionality ถูกเปิดการใช้งานโดยการ include ไฟล์ the FreeRTOS/source/stream_buffer.c source file ใน the build.

Parameters:

     xStreamBuffer               The handle of the stream buffer ที่กำลังถูกสอบถาม.

Returns:

     ถ้า the stream buffer ว่างเปล่าดังนั้น pdTRUE จะถูกส่งคืนกลับ. ถ้าเป็นอย่างอื่น pdFALSE จะถูกส่งคืนกลับ.


tha

https://www.freertos.org/xStreamBufferIsFull.html

xStreamBufferIsFull()
[RTOS Stream Buffer API]

stream_buffer.h

BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer );

สอบถาม a stream buffer เพื่อดูว่ามันเต็มหรือไม่. A stream buffer จะเต็มถ้ามันไม่มี free space ใดๆ. และดังนั้นไม่สามารถยอมรับ data เพิ่มเติมใดๆ

Stream buffer functionality ถูกเปิดการใช้งานโดยการ include ไฟล์ the FreeRTOS/source/stream_buffer.c source file ใน the build.

Parameters:

     xStreamBuffer               The handle of the stream buffer ที่กำลังถูกสอบถาม.

Returns:

     ถ้า the stream buffer เต็มดังนั้น pdTRUE จะถูกส่งคืนกลับ. ถ้าเป็นอย่างอื่น pdFALSE จะถูกส่งคืนกลับ.