HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

communication.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2017 EPFL-LSRO (Laboratoire de Systemes Robotiques).
3 *
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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 __COMMUNICATION_H
18 #define __COMMUNICATION_H
19
20 #include "main.h"
21 #include "definitions.h"
22
23 #include <stdarg.h>
24
45 typedef struct
46 {
47 char name[SYNCVAR_NAME_SIZE];
48 void *address;
49 comm_VarType type;
50 uint8_t size;
51 comm_VarAccess access;
52 bool usesVarAddress;
53 void (*getFunc)(void);
54 void (*setFunc)(void);
55 } comm_SyncVar;
56
57
58 void comm_Init(void);
59 void comm_Step(void);
60
61 void comm_NotifyReady(void);
62
63 void comm_monitorVar(const char name[], void *address, comm_VarType type,
64 uint8_t size, comm_VarAccess access);
65 void comm_monitorVarFunc(const char name[], comm_VarType type, uint8_t size,
66 void (*getFunc)(void), void (*setFunc)(void));
67
68 void comm_monitorBool(const char name[], bool *address,
69 comm_VarAccess access);
70 void comm_monitorUint8(const char name[], uint8_t *address,
71 comm_VarAccess access);
72 void comm_monitorInt8(const char name[], int8_t *address,
73 comm_VarAccess access);
74 void comm_monitorUint16(const char name[], uint16_t *address,
75 comm_VarAccess access);
76 void comm_monitorInt16(const char name[], int16_t *address,
77 comm_VarAccess access);
78 void comm_monitorUint32(const char name[], uint32_t *address,
79 comm_VarAccess access);
80 void comm_monitorInt32(const char name[], int32_t *address,
81 comm_VarAccess access);
82 void comm_monitorUint64(const char name[], uint64_t *address,
83 comm_VarAccess access);
84 void comm_monitorInt64(const char name[], int64_t *address,
85 comm_VarAccess access);
86 void comm_monitorFloat(const char name[], float *address,
87 comm_VarAccess access);
88 void comm_monitorDouble(const char name[], double *address,
89 comm_VarAccess access);
90
91 void comm_monitorBoolFunc(const char name[],
92 bool (*getFunc)(void), void (*setFunc)(bool));
93 void comm_monitorUint8Func(const char name[],
94 uint8_t (*getFunc)(void), void (*setFunc)(uint8_t));
95 void comm_monitorInt8Func(const char name[],
96 int8_t (*getFunc)(void), void (*setFunc)(int8_t));
97 void comm_monitorUint16Func(const char name[],
98 uint16_t (*getFunc)(void),
99 void (*setFunc)(uint16_t));
100 void comm_monitorInt16Func(const char name[],
101 int16_t (*getFunc)(void), void (*setFunc)(int16_t));
102 void comm_monitorUint32Func(const char name[],
103 uint32_t (*getFunc)(void),
104 void (*setFunc)(uint32_t));
105 void comm_monitorInt32Func(const char name[],
106 int32_t (*getFunc)(void), void (*setFunc)(int32_t));
107 void comm_monitorUint64Func(const char name[],
108 uint64_t (*getFunc)(void),
109 void (*setFunc)(uint64_t));
110 void comm_monitorInt64Func(const char name[],
111 int64_t (*getFunc)(void), void (*setFunc)(int64_t));
112 void comm_monitorFloatFunc(const char name[],
113 float (*getFunc)(void), void (*setFunc)(float));
114 void comm_monitorDoubleFunc(const char name[],
115 double (*getFunc)(void), void (*setFunc)(double));
116
117 void comm_LockSyncVarsList(void);
118
119 void comm_SendDebugMessage(const char *format, ...);
120
131 #define comm_SendDebugMessageDecimated(decimation, format, ...) \
132 do \
133 { \
134 static int comm_decim##__COUNTER__ = 0; \
135 if(comm_decim##__COUNTER__++ % decimation == 0) \
136 { \
137 comm_SendDebugMessage(format, ##__VA_ARGS__); \
138 } \
139 } while(0)
140
145 #endif
comm_SyncVar::type
comm_VarType type
Definition: communication.h:49
comm_monitorInt8Func
void comm_monitorInt8Func(const char name[], int8_t(*getFunc)(void), void(*setFunc)(int8_t))
Adds a monitored int8_t variable to the list, with getter/setter.
Definition: communication.c:844
comm_monitorInt16Func
void comm_monitorInt16Func(const char name[], int16_t(*getFunc)(void), void(*setFunc)(int16_t))
Adds a monitored int16_t variable to the list, with getter/setter.
Definition: communication.c:871
comm_monitorFloat
void comm_monitorFloat(const char name[], float *address, comm_VarAccess access)
Adds a monitored float variable to the list, with its address.
Definition: communication.c:791
comm_SyncVar::access
comm_VarAccess access
Definition: communication.h:51
comm_monitorDoubleFunc
void comm_monitorDoubleFunc(const char name[], double(*getFunc)(void), void(*setFunc)(double))
Adds a monitored double variable to the list, with getter/setter.
Definition: communication.c:952
comm_SyncVar::address
void * address
Definition: communication.h:48
comm_monitorUint64
void comm_monitorUint64(const char name[], uint64_t *address, comm_VarAccess access)
Adds a monitored uint64_t variable to the list, with its address.
Definition: communication.c:763
comm_SyncVar::size
uint8_t size
Definition: communication.h:50
comm_SendDebugMessage
void comm_SendDebugMessage(const char *format,...)
Sends a debug message to the computer.
Definition: communication.c:974
comm_monitorInt16
void comm_monitorInt16(const char name[], int16_t *address, comm_VarAccess access)
Adds a monitored int16_t variable to the list, with its address.
Definition: communication.c:721
comm_monitorInt64
void comm_monitorInt64(const char name[], int64_t *address, comm_VarAccess access)
Adds a monitored int64_t variable to the list, with its address.
Definition: communication.c:777
comm_monitorUint8
void comm_monitorUint8(const char name[], uint8_t *address, comm_VarAccess access)
Adds a monitored uint8_t variable to the list, with its address.
Definition: communication.c:679
main.h
comm_monitorInt8
void comm_monitorInt8(const char name[], int8_t *address, comm_VarAccess access)
Adds a monitored int8_t variable to the list, with its address.
Definition: communication.c:693
comm_monitorInt32
void comm_monitorInt32(const char name[], int32_t *address, comm_VarAccess access)
Adds a monitored int32_t variable to the list, with its address.
Definition: communication.c:749
comm_monitorUint32
void comm_monitorUint32(const char name[], uint32_t *address, comm_VarAccess access)
Adds a monitored uint32_t variable to the list, with its address.
Definition: communication.c:735
comm_SyncVar::usesVarAddress
bool usesVarAddress
Definition: communication.h:52
comm_monitorVar
void comm_monitorVar(const char name[], void *address, comm_VarType type, uint8_t size, comm_VarAccess access)
Adds a monitored variable to the list, with its address.
Definition: communication.c:549
comm_Step
void comm_Step(void)
Updates the communication manager. Send the bytes waiting in the TX buffer, and process the bytes rec...
Definition: communication.c:91
comm_LockSyncVarsList
void comm_LockSyncVarsList(void)
Locks the monitored variables, so it can be used. After the call to this function, adding variables will not be possible anymore. The PC will not be able to get the variables list until this function is called.
Definition: communication.c:964
definitions.h
comm_monitorInt64Func
void comm_monitorInt64Func(const char name[], int64_t(*getFunc)(void), void(*setFunc)(int64_t))
Adds a monitored int64_t variable to the list, with getter/setter.
Definition: communication.c:925
comm_monitorUint16
void comm_monitorUint16(const char name[], uint16_t *address, comm_VarAccess access)
Adds a monitored uint16_t variable to the list, with its address.
Definition: communication.c:707
comm_SyncVar
Definition: communication.h:45
comm_monitorInt32Func
void comm_monitorInt32Func(const char name[], int32_t(*getFunc)(void), void(*setFunc)(int32_t))
Adds a monitored int32_t variable to the list, with getter/setter.
Definition: communication.c:898
comm_NotifyReady
void comm_NotifyReady(void)
Sends a packet to notify the PC that the board just (re)started. This informs the PC software that th...
Definition: communication.c:108
SYNCVAR_NAME_SIZE
#define SYNCVAR_NAME_SIZE
Definition: definitions.h:46
comm_VarType
comm_VarType
Definition: definitions.h:55
comm_monitorUint32Func
void comm_monitorUint32Func(const char name[], uint32_t(*getFunc)(void), void(*setFunc)(uint32_t))
Adds a monitored uint32_t variable to the list, with getter/setter.
Definition: communication.c:884
comm_monitorBool
void comm_monitorBool(const char name[], bool *address, comm_VarAccess access)
Adds a monitored bool variable to the list, with its address.
Definition: communication.c:665
comm_VarAccess
comm_VarAccess
Definition: definitions.h:48
comm_monitorFloatFunc
void comm_monitorFloatFunc(const char name[], float(*getFunc)(void), void(*setFunc)(float))
Adds a monitored float variable to the list, with getter/setter.
Definition: communication.c:938
comm_monitorDouble
void comm_monitorDouble(const char name[], double *address, comm_VarAccess access)
Adds a monitored double variable to the list, with its address.
Definition: communication.c:805
comm_monitorBoolFunc
void comm_monitorBoolFunc(const char name[], bool(*getFunc)(void), void(*setFunc)(bool))
Adds a monitored bool variable to the list, with getter/setter.
Definition: communication.c:818
comm_Init
void comm_Init(void)
Init the communication manager.
Definition: communication.c:70
comm_monitorUint8Func
void comm_monitorUint8Func(const char name[], uint8_t(*getFunc)(void), void(*setFunc)(uint8_t))
Adds a monitored uint8_t variable to the list, with getter/setter.
Definition: communication.c:831
comm_monitorUint64Func
void comm_monitorUint64Func(const char name[], uint64_t(*getFunc)(void), void(*setFunc)(uint64_t))
Adds a monitored uint64_t variable to the list, with getter/setter.
Definition: communication.c:911
comm_monitorUint16Func
void comm_monitorUint16Func(const char name[], uint16_t(*getFunc)(void), void(*setFunc)(uint16_t))
Adds a monitored uint16_t variable to the list, with getter/setter.
Definition: communication.c:857
comm_monitorVarFunc
void comm_monitorVarFunc(const char name[], comm_VarType type, uint8_t size, void(*getFunc)(void), void(*setFunc)(void))
Adds a monitored variable to the list, with getter/setter functions. If the getter and setter are set...
Definition: communication.c:605