add message queue related functions
[apps/native/gear-racing-car.git] / inc / message.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __CAR_APP_MESSAGE_H__
18 #define __CAR_APP_MESSAGE_H__
19
20 typedef enum __message_cmd_e {
21         MESSAGE_CMD_HELLO, /* to use keep alive, if needed */
22         MESSAGE_CMD_CALIBRATION,
23         MESSAGE_CMD_DRIVE,
24         MESSAGE_CMD_BYE, /* to notify explicitly closing connection */
25 } message_cmd_e;
26
27 struct __message_type_s {
28         unsigned long long int seq_num;
29         message_cmd_e cmd;
30         int servo;
31         int speed;
32         unsigned long long int time; /* to be used to order messages */
33 };
34 typedef struct __message_type_s message_s;
35
36 int message_new(message_cmd_e cmd, int servo, int speed, message_s *new_msg);
37 void message_reset_seq_num(void);
38
39 int message_queue_new(void);
40 void message_queue_clear(void);
41
42 void message_push_to_inqueue(message_s *msg);
43 message_s *message_pop_from_inqueue(void);
44
45 void message_push_to_outqueue(message_s *msg);
46 message_s *message_pop_from_outqueue(void);
47
48 #endif /* __CAR_APP_MESSAGE_H__ */