#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/timers.h"
#include "freertos/semphr.h"
#include "freertos/semphr.h"
#include "freertos/message_buffer.h"
#include "freertos/event_groups.h"
#include "string.h"
StreamBufferHandle_t myStreamBuffer;
char *tx="123";
char *tx2="abc";
char rx[10]={0};
void send(void *p) {
size_t s = xStreamBufferSend(myStreamBuffer,tx,strlen(tx),pdMS_TO_TICKS(100));
printf("send: %d\n",s);
s = xStreamBufferSend(myStreamBuffer,tx2,strlen(tx2),pdMS_TO_TICKS(999999999));
printf("send: %d\n",s);
while (1) {
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void receive(void *p){
while (1) {
vTaskDelay(pdMS_TO_TICKS(3000));
size_t xReceivedBytes = xStreamBufferReceive(myStreamBuffer,rx,10,pdMS_TO_TICKS(999999999));
printf("ReceivedBytes: %d \n",xReceivedBytes);
printf("Received: %s\n",rx);
}
}
void app_main(void) {
myStreamBuffer = xStreamBufferCreate(4,1);
xTaskCreate(&send, "xEventGroupSetBits", 2048, NULL, configMAX_PRIORITIES-1, NULL);
xTaskCreate(&receive, "xEventGroupSetBits", 2048, NULL, configMAX_PRIORITIES-1, NULL);
return;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)