-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensors_queue.c
66 lines (54 loc) · 1.22 KB
/
sensors_queue.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* sensors_queue.c
*
* Created on: 2019Äê11ÔÂ3ÈÕ
* Author: jiez
*/
#include "sensors_queue.h"
void createSensorQ()
{
sensor_queue = xQueueCreate(SENSOR_QUEUE_SIZE, SENSOR_MSG_SIZE);
if(sensor_queue == NULL){
dbgTerminalError();
}
}
int sendMsgToSensorQ(msgQueue_sensor * aStruct)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
BaseType_t err = xQueueSendToBackFromISR(sensor_queue, aStruct, &xHigherPriorityTaskWoken);
if (err != pdPASS) {
dbgTerminalError();
//while(1);
}
//dbgOutputLoc(SEND_TIME_POST_LOC);
return 1;
}
int recieveMsgFromSensorQ( msgQueue_sensor *result)
{
// dbgOutputLoc(RECIEVE_PRE_LOC);
// dbgOutputLoc(RECV_FROM_QUEUE1_PRE_LOC);
BaseType_t err = xQueueReceive(sensor_queue, result, portMAX_DELAY);
if (err == pdFALSE) {
dbgTerminalError();
}
switch(result->dataType){
case PIXY_MSG_TYPE:{
return 0;
}
case ULTRA_MSG_TYPE:{
return 1;
}
case ROVER_MSG_TYPE:{
return 2;
}
case ARM_MSG_TYPE:{
return 3;
}
case MQTT_CREATED_COMPLETE:{
return 4;
}
default:
return -1;
}
// dbgOutputLoc(RECV_FROM_QUEUE1_POST_LOC);
}