OctopOS  0.6.0
Data communication bus for SPACE HAUC
utility.h
Go to the documentation of this file.
1 // Copyright 2017 Space HAUC Command and Data Handling
2 // This file is part of octopOS which is released under AGPLv3.
3 // See file LICENSE.txt or go to <http://www.gnu.org/licenses/> for full
4 // license details.
5 
9 #ifndef INCLUDE_UTILITY_H_
10 #define INCLUDE_UTILITY_H_
11 
12 #include <sys/types.h>
13 #include <sys/ipc.h>
14 #include <sys/shm.h>
15 #include <sys/msg.h>
16 #include <sys/sem.h>
17 
18 #include <exception>
19 #include <system_error> // NOLINT
20 #include <cerrno>
21 
22 
23 #define MEMKEY 0x45861534
24 #define SEMKEY 0x45861534
25 #define MSGKEY 0x45861534
26 
27 #define MSGLEN 126
28 #define SHMSIZE 4096
29 
30 const unsigned NUMMODULES = 20;
31 
33 const unsigned SUB_BIT = 0x20000000;
35 const unsigned TEMP_BIT = 0x40000000;
36 
38 const unsigned CREATE_PUB = 1;
40 const unsigned PUBLISH_CODE = 2;
42 const unsigned CREATE_SUB = 3;
43 
45 typedef intptr_t generic_t;
47 typedef long octopOS_id_t; // NOLINT
49 typedef uint sem_id_t;
50 
52 typedef struct {
54  unsigned rw_array[2];
55 } shm_object;
56 
58 typedef struct {
60  long type; // NOLINT
62  char text[MSGLEN];
64 
66 union semun {
68  int val;
70  struct semid_ds *buf;
72  unsigned short *array; // NOLINT
73 };
74 
79 extern intptr_t* connect_shm();
80 
87 extern int p(int sem, int counter);
88 
95 extern int v(int sem, int counter);
96 
104 extern int semsetall(int sem_group, int number_in_group, int value);
105 
106 #endif // INCLUDE_UTILITY_H_
Definition: utility.h:52
const unsigned NUMMODULES
Definition: utility.h:30
intptr_t generic_t
Definition: utility.h:45
int semsetall(int sem_group, int number_in_group, int value)
Definition: utility.cpp:25
long type
Definition: utility.h:60
const unsigned CREATE_SUB
Definition: utility.h:42
const unsigned TEMP_BIT
Definition: utility.h:35
const unsigned SUB_BIT
Definition: utility.h:33
Definition: utility.h:58
const unsigned CREATE_PUB
Definition: utility.h:38
int val
Definition: utility.h:68
int v(int sem, int counter)
Definition: utility.cpp:54
uint sem_id_t
Definition: utility.h:49
Definition: utility.h:66
intptr_t * connect_shm()
Definition: utility.cpp:11
int p(int sem, int counter)
Definition: utility.cpp:39
struct semid_ds * buf
Definition: utility.h:70
long octopOS_id_t
Definition: utility.h:47
unsigned short * array
Definition: utility.h:72
const unsigned PUBLISH_CODE
Definition: utility.h:40