From 2163f47dc61b655b5ab21837d427d399d4b53cbf Mon Sep 17 00:00:00 2001 From: kcl93 Date: Thu, 11 Feb 2021 22:45:56 +0100 Subject: [PATCH 01/14] Add return values to linkVariable --- library.properties | 2 +- src/muComBase.h | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/library.properties b/library.properties index 372ef62..632cd4f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=muCom -version=1.1 +version=1.2 author=Kai Liebich maintainer=Kai Liebich sentence=The reliable, fast and easy way to exchange binary data via UART diff --git a/src/muComBase.h b/src/muComBase.h index cde797e..06d2217 100644 --- a/src/muComBase.h +++ b/src/muComBase.h @@ -139,35 +139,36 @@ class muComBase \param[in] index Index used to access the variable/buffer \param[in] var Pointer to the variable or buffer to be linked to the interface \param[in] size Size of the variable/buffer in bytes (only neccessary when linking buffers) + \return MUCOM_OK if all is alright */ int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size); - inline void linkVariable(uint8_t index, uint8_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(uint8_t)); } + inline int8_t linkVariable(uint8_t index, uint8_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(uint8_t)); } - inline void linkVariable(uint8_t index, int8_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(int8_t)); } + inline int8_t linkVariable(uint8_t index, int8_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(int8_t)); } - inline void linkVariable(uint8_t index, uint16_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(uint16_t)); } + inline int8_t linkVariable(uint8_t index, uint16_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(uint16_t)); } - inline void linkVariable(uint8_t index, int16_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(int16_t)); } + inline int8_t linkVariable(uint8_t index, int16_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(int16_t)); } - inline void linkVariable(uint8_t index, uint32_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(uint32_t)); } + inline int8_t linkVariable(uint8_t index, uint32_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(uint32_t)); } - inline void linkVariable(uint8_t index, int32_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(int32_t)); } + inline int8_t linkVariable(uint8_t index, int32_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(int32_t)); } - inline void linkVariable(uint8_t index, uint64_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(uint64_t)); } + inline int8_t linkVariable(uint8_t index, uint64_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(uint64_t)); } - inline void linkVariable(uint8_t index, int64_t *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(int64_t)); } + inline int8_t linkVariable(uint8_t index, int64_t *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(int64_t)); } - inline void linkVariable(uint8_t index, float *var) - { this->linkVariable(index, (uint8_t*)var, sizeof(float)); } + inline int8_t linkVariable(uint8_t index, float *var) + { return this->linkVariable(index, (uint8_t*)var, sizeof(float)); } /** From 47feb78ef2a9d571dfacd71ed00d1f15f277e262 Mon Sep 17 00:00:00 2001 From: kcl93 Date: Thu, 11 Feb 2021 22:46:50 +0100 Subject: [PATCH 02/14] Update documentation --- extras/Doxyfile | 2 +- extras/html/annotated.html | 2 +- extras/html/classes.html | 2 +- extras/html/classmu_com-members.html | 2 +- extras/html/classmu_com.html | 56 ++--- extras/html/classmu_com_base-members.html | 2 +- extras/html/classmu_com_base.html | 57 ++--- .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- extras/html/files.html | 2 +- extras/html/functions.html | 2 +- extras/html/functions_func.html | 2 +- extras/html/hierarchy.html | 2 +- extras/html/index.html | 2 +- extras/html/mu_com_8h_source.html | 4 +- extras/html/mu_com_base_8h_source.html | 220 +++++++++--------- ...mu_com___linked_variable__str-members.html | 2 +- .../structmu_com___linked_variable__str.html | 2 +- 17 files changed, 182 insertions(+), 181 deletions(-) diff --git a/extras/Doxyfile b/extras/Doxyfile index 5b4f790..ca76b7b 100644 --- a/extras/Doxyfile +++ b/extras/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = muCom # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.1 +PROJECT_NUMBER = 1.2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/extras/html/annotated.html b/extras/html/annotated.html index f679984..6f4ac1f 100644 --- a/extras/html/annotated.html +++ b/extras/html/annotated.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classes.html b/extras/html/classes.html index 2c75b4d..bb0587c 100644 --- a/extras/html/classes.html +++ b/extras/html/classes.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com-members.html b/extras/html/classmu_com-members.html index cf2a917..951bff1 100644 --- a/extras/html/classmu_com-members.html +++ b/extras/html/classmu_com-members.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com.html b/extras/html/classmu_com.html index 17a8444..f955c70 100644 --- a/extras/html/classmu_com.html +++ b/extras/html/classmu_com.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
@@ -90,33 +90,33 @@ int8_t linkVariable (uint8_t index, uint8_t *var, uint8_t size)  Link a variable or a buffer to the muCom interface. More...
  - -void linkVariable (uint8_t index, uint8_t *var) -  - -void linkVariable (uint8_t index, int8_t *var) -  - -void linkVariable (uint8_t index, uint16_t *var) -  - -void linkVariable (uint8_t index, int16_t *var) -  - -void linkVariable (uint8_t index, uint32_t *var) -  - -void linkVariable (uint8_t index, int32_t *var) -  - -void linkVariable (uint8_t index, uint64_t *var) -  - -void linkVariable (uint8_t index, int64_t *var) -  - -void linkVariable (uint8_t index, float *var) -  + +int8_t linkVariable (uint8_t index, uint8_t *var) +  + +int8_t linkVariable (uint8_t index, int8_t *var) +  + +int8_t linkVariable (uint8_t index, uint16_t *var) +  + +int8_t linkVariable (uint8_t index, int16_t *var) +  + +int8_t linkVariable (uint8_t index, uint32_t *var) +  + +int8_t linkVariable (uint8_t index, int32_t *var) +  + +int8_t linkVariable (uint8_t index, uint64_t *var) +  + +int8_t linkVariable (uint8_t index, int64_t *var) +  + +int8_t linkVariable (uint8_t index, float *var) +  void invokeFunction (uint8_t index, uint8_t *data, uint8_t cnt)  Invoke a function at the communication partner. More...
  diff --git a/extras/html/classmu_com_base-members.html b/extras/html/classmu_com_base-members.html index 2e9c8e6..7c3adfc 100644 --- a/extras/html/classmu_com_base-members.html +++ b/extras/html/classmu_com_base-members.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com_base.html b/extras/html/classmu_com_base.html index 37e72e3..8cd0854 100644 --- a/extras/html/classmu_com_base.html +++ b/extras/html/classmu_com_base.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
@@ -86,33 +86,33 @@ int8_t linkVariable (uint8_t index, uint8_t *var, uint8_t size)  Link a variable or a buffer to the muCom interface. More...
  - -void linkVariable (uint8_t index, uint8_t *var) -  - -void linkVariable (uint8_t index, int8_t *var) -  - -void linkVariable (uint8_t index, uint16_t *var) -  - -void linkVariable (uint8_t index, int16_t *var) -  - -void linkVariable (uint8_t index, uint32_t *var) -  - -void linkVariable (uint8_t index, int32_t *var) -  - -void linkVariable (uint8_t index, uint64_t *var) -  - -void linkVariable (uint8_t index, int64_t *var) -  - -void linkVariable (uint8_t index, float *var) -  + +int8_t linkVariable (uint8_t index, uint8_t *var) +  + +int8_t linkVariable (uint8_t index, int8_t *var) +  + +int8_t linkVariable (uint8_t index, uint16_t *var) +  + +int8_t linkVariable (uint8_t index, int16_t *var) +  + +int8_t linkVariable (uint8_t index, uint32_t *var) +  + +int8_t linkVariable (uint8_t index, int32_t *var) +  + +int8_t linkVariable (uint8_t index, uint64_t *var) +  + +int8_t linkVariable (uint8_t index, int64_t *var) +  + +int8_t linkVariable (uint8_t index, float *var) +  void invokeFunction (uint8_t index, uint8_t *data, uint8_t cnt)  Invoke a function at the communication partner. More...
  @@ -439,6 +439,7 @@

Returns
MUCOM_OK if all is alright
diff --git a/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 1b9e822..56b57f9 100644 --- a/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/files.html b/extras/html/files.html index 53cc2cd..766adfa 100644 --- a/extras/html/files.html +++ b/extras/html/files.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/functions.html b/extras/html/functions.html index f3fef11..c00254c 100644 --- a/extras/html/functions.html +++ b/extras/html/functions.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/functions_func.html b/extras/html/functions_func.html index afaf044..ee6e2f6 100644 --- a/extras/html/functions_func.html +++ b/extras/html/functions_func.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/hierarchy.html b/extras/html/hierarchy.html index 7598614..613122b 100644 --- a/extras/html/hierarchy.html +++ b/extras/html/hierarchy.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/index.html b/extras/html/index.html index 92000ce..b0ae71d 100644 --- a/extras/html/index.html +++ b/extras/html/index.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/mu_com_8h_source.html b/extras/html/mu_com_8h_source.html index 3607328..26b81af 100644 --- a/extras/html/mu_com_8h_source.html +++ b/extras/html/mu_com_8h_source.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
@@ -84,7 +84,7 @@
46 
47 #endif //MUCOM_H
-
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:197
+
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:198
Base muCom class.
Definition: muComBase.h:58
File containing the main class for the muCom interface when being used for an Arduino.
Definition: muCom.h:21
diff --git a/extras/html/mu_com_base_8h_source.html b/extras/html/mu_com_base_8h_source.html index 5df287b..36b4e28 100644 --- a/extras/html/mu_com_base_8h_source.html +++ b/extras/html/mu_com_base_8h_source.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
@@ -139,124 +139,124 @@
134  int8_t linkFunction(uint8_t index, muComFunc function);
135 
136 
-
143  int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size);
-
144 
-
145  inline void linkVariable(uint8_t index, uint8_t *var)
-
146  { this->linkVariable(index, (uint8_t*)var, sizeof(uint8_t)); }
-
147 
-
148  inline void linkVariable(uint8_t index, int8_t *var)
-
149  { this->linkVariable(index, (uint8_t*)var, sizeof(int8_t)); }
-
150 
-
151  inline void linkVariable(uint8_t index, uint16_t *var)
-
152  { this->linkVariable(index, (uint8_t*)var, sizeof(uint16_t)); }
-
153 
-
154  inline void linkVariable(uint8_t index, int16_t *var)
-
155  { this->linkVariable(index, (uint8_t*)var, sizeof(int16_t)); }
-
156 
-
157  inline void linkVariable(uint8_t index, uint32_t *var)
-
158  { this->linkVariable(index, (uint8_t*)var, sizeof(uint32_t)); }
-
159 
-
160  inline void linkVariable(uint8_t index, int32_t *var)
-
161  { this->linkVariable(index, (uint8_t*)var, sizeof(int32_t)); }
-
162 
-
163  inline void linkVariable(uint8_t index, uint64_t *var)
-
164  { this->linkVariable(index, (uint8_t*)var, sizeof(uint64_t)); }
-
165 
-
166  inline void linkVariable(uint8_t index, int64_t *var)
-
167  { this->linkVariable(index, (uint8_t*)var, sizeof(int64_t)); }
-
168 
-
169  inline void linkVariable(uint8_t index, float *var)
-
170  { this->linkVariable(index, (uint8_t*)var, sizeof(float)); }
-
171 
+
144  int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size);
+
145 
+
146  inline int8_t linkVariable(uint8_t index, uint8_t *var)
+
147  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint8_t)); }
+
148 
+
149  inline int8_t linkVariable(uint8_t index, int8_t *var)
+
150  { return this->linkVariable(index, (uint8_t*)var, sizeof(int8_t)); }
+
151 
+
152  inline int8_t linkVariable(uint8_t index, uint16_t *var)
+
153  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint16_t)); }
+
154 
+
155  inline int8_t linkVariable(uint8_t index, int16_t *var)
+
156  { return this->linkVariable(index, (uint8_t*)var, sizeof(int16_t)); }
+
157 
+
158  inline int8_t linkVariable(uint8_t index, uint32_t *var)
+
159  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint32_t)); }
+
160 
+
161  inline int8_t linkVariable(uint8_t index, int32_t *var)
+
162  { return this->linkVariable(index, (uint8_t*)var, sizeof(int32_t)); }
+
163 
+
164  inline int8_t linkVariable(uint8_t index, uint64_t *var)
+
165  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint64_t)); }
+
166 
+
167  inline int8_t linkVariable(uint8_t index, int64_t *var)
+
168  { return this->linkVariable(index, (uint8_t*)var, sizeof(int64_t)); }
+
169 
+
170  inline int8_t linkVariable(uint8_t index, float *var)
+
171  { return this->linkVariable(index, (uint8_t*)var, sizeof(float)); }
172 
-
179  inline void invokeFunction(uint8_t index, uint8_t* data, uint8_t cnt)
-
180  { this->writeRaw(MUCOM_EXECUTE_REQUEST, index, data, cnt); }
-
181 
-
187  inline void invokeFunction(uint8_t index)
-
188  { uint8_t dummy; this->writeRaw(MUCOM_EXECUTE_REQUEST, index, &dummy, 1); }
-
189 
-
190 
-
197  inline void write(uint8_t index, uint8_t *data, uint8_t cnt)
-
198  { this->writeRaw(MUCOM_WRITE_REQUEST, index, data, cnt); }
-
199 
-
205  inline void writeByte(uint8_t index, uint8_t data)
-
206  { this->write(index, (uint8_t*)&data, sizeof(uint8_t)); }
-
207 
-
213  inline void writeShort(uint8_t index, uint16_t data)
-
214  { this->write(index, (uint8_t*)&data, sizeof(uint16_t)); }
-
215 
-
221  inline void writeLong(uint8_t index, uint32_t data)
-
222  { this->write(index, (uint8_t*)&data, sizeof(uint32_t)); }
-
223 
-
229  inline void writeLongLong(uint8_t index, uint64_t data)
-
230  { this->write(index, (uint8_t*)&data, sizeof(uint64_t)); }
-
231 
-
237  inline void writeFloat(uint8_t index, float data)
-
238  { this->write(index, (uint8_t*)&data, sizeof(float)); }
-
239 
-
240 
-
247  int8_t read(uint8_t index, uint8_t *data, uint8_t cnt);
-
248 
-
255  inline int8_t readByte(uint8_t index, uint8_t *data)
-
256  { return this->read(index, (uint8_t*)data, sizeof(uint8_t)); }
-
257 
-
258  inline int8_t readByte(uint8_t index, int8_t *data)
-
259  { return this->read(index, (uint8_t*)data, sizeof(int8_t)); }
-
260 
-
267  inline int8_t readShort(uint8_t index, uint16_t *data)
-
268  { return this->read(index, (uint8_t*)data, sizeof(uint16_t)); }
-
269 
-
270  inline int8_t readShort(uint8_t index, int16_t *data)
-
271  { return this->read(index, (uint8_t*)data, sizeof(int16_t)); }
-
272 
-
279  inline int8_t readLong(uint8_t index, uint32_t *data)
-
280  { return this->read(index, (uint8_t*)data, sizeof(uint32_t)); }
-
281 
-
282  inline int8_t readLong(uint8_t index, int32_t *data)
-
283  { return this->read(index, (uint8_t*)data, sizeof(int32_t)); }
-
284 
-
291  inline int8_t readLongLong(uint8_t index, uint64_t *data)
-
292  { return this->read(index, (uint8_t*)data, sizeof(uint64_t)); }
-
293 
-
294  inline int8_t readLongLong(uint8_t index, int64_t *data)
-
295  { return this->read(index, (uint8_t*)data, sizeof(int64_t)); }
-
296 
-
303  inline int8_t readFloat(uint8_t index, float *data)
-
304  { return this->read(index, (uint8_t*)data, sizeof(float)); }
-
305 
-
312  uint8_t readByte(uint8_t index);
-
313 
-
320  uint16_t readShort(uint8_t index);
-
321 
-
328  uint32_t readLong(uint8_t index);
-
329 
-
336  uint64_t readLongLong(uint8_t index);
-
337 
-
344  float readFloat(uint8_t index);
-
345 };
-
346 
+
173 
+
180  inline void invokeFunction(uint8_t index, uint8_t* data, uint8_t cnt)
+
181  { this->writeRaw(MUCOM_EXECUTE_REQUEST, index, data, cnt); }
+
182 
+
188  inline void invokeFunction(uint8_t index)
+
189  { uint8_t dummy; this->writeRaw(MUCOM_EXECUTE_REQUEST, index, &dummy, 1); }
+
190 
+
191 
+
198  inline void write(uint8_t index, uint8_t *data, uint8_t cnt)
+
199  { this->writeRaw(MUCOM_WRITE_REQUEST, index, data, cnt); }
+
200 
+
206  inline void writeByte(uint8_t index, uint8_t data)
+
207  { this->write(index, (uint8_t*)&data, sizeof(uint8_t)); }
+
208 
+
214  inline void writeShort(uint8_t index, uint16_t data)
+
215  { this->write(index, (uint8_t*)&data, sizeof(uint16_t)); }
+
216 
+
222  inline void writeLong(uint8_t index, uint32_t data)
+
223  { this->write(index, (uint8_t*)&data, sizeof(uint32_t)); }
+
224 
+
230  inline void writeLongLong(uint8_t index, uint64_t data)
+
231  { this->write(index, (uint8_t*)&data, sizeof(uint64_t)); }
+
232 
+
238  inline void writeFloat(uint8_t index, float data)
+
239  { this->write(index, (uint8_t*)&data, sizeof(float)); }
+
240 
+
241 
+
248  int8_t read(uint8_t index, uint8_t *data, uint8_t cnt);
+
249 
+
256  inline int8_t readByte(uint8_t index, uint8_t *data)
+
257  { return this->read(index, (uint8_t*)data, sizeof(uint8_t)); }
+
258 
+
259  inline int8_t readByte(uint8_t index, int8_t *data)
+
260  { return this->read(index, (uint8_t*)data, sizeof(int8_t)); }
+
261 
+
268  inline int8_t readShort(uint8_t index, uint16_t *data)
+
269  { return this->read(index, (uint8_t*)data, sizeof(uint16_t)); }
+
270 
+
271  inline int8_t readShort(uint8_t index, int16_t *data)
+
272  { return this->read(index, (uint8_t*)data, sizeof(int16_t)); }
+
273 
+
280  inline int8_t readLong(uint8_t index, uint32_t *data)
+
281  { return this->read(index, (uint8_t*)data, sizeof(uint32_t)); }
+
282 
+
283  inline int8_t readLong(uint8_t index, int32_t *data)
+
284  { return this->read(index, (uint8_t*)data, sizeof(int32_t)); }
+
285 
+
292  inline int8_t readLongLong(uint8_t index, uint64_t *data)
+
293  { return this->read(index, (uint8_t*)data, sizeof(uint64_t)); }
+
294 
+
295  inline int8_t readLongLong(uint8_t index, int64_t *data)
+
296  { return this->read(index, (uint8_t*)data, sizeof(int64_t)); }
+
297 
+
304  inline int8_t readFloat(uint8_t index, float *data)
+
305  { return this->read(index, (uint8_t*)data, sizeof(float)); }
+
306 
+
313  uint8_t readByte(uint8_t index);
+
314 
+
321  uint16_t readShort(uint8_t index);
+
322 
+
329  uint32_t readLong(uint8_t index);
+
330 
+
337  uint64_t readLongLong(uint8_t index);
+
338 
+
345  float readFloat(uint8_t index);
+
346 };
347 
-
348 #endif //MUCOMBASE_H
+
348 
+
349 #endif //MUCOMBASE_H
~muComBase(void)
Destructor of the base class.
Definition: muComBase.cpp:66
-
void invokeFunction(uint8_t index)
Invoke a function at the communication partner.
Definition: muComBase.h:187
-
void writeShort(uint8_t index, uint16_t data)
Write a short (16 bit) to the communication partner.
Definition: muComBase.h:213
-
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:197
-
int8_t readLongLong(uint8_t index, uint64_t *data)
Read a long long from the communication partner.
Definition: muComBase.h:291
-
void invokeFunction(uint8_t index, uint8_t *data, uint8_t cnt)
Invoke a function at the communication partner.
Definition: muComBase.h:179
-
void writeByte(uint8_t index, uint8_t data)
Write a byte (8 bit) to the communication partner.
Definition: muComBase.h:205
-
int8_t readShort(uint8_t index, uint16_t *data)
Read a short from the communication partner.
Definition: muComBase.h:267
-
void writeLong(uint8_t index, uint32_t data)
Write a long (32 bit) to the communication partner.
Definition: muComBase.h:221
+
void invokeFunction(uint8_t index)
Invoke a function at the communication partner.
Definition: muComBase.h:188
+
void writeShort(uint8_t index, uint16_t data)
Write a short (16 bit) to the communication partner.
Definition: muComBase.h:214
+
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:198
+
int8_t readLongLong(uint8_t index, uint64_t *data)
Read a long long from the communication partner.
Definition: muComBase.h:292
+
void invokeFunction(uint8_t index, uint8_t *data, uint8_t cnt)
Invoke a function at the communication partner.
Definition: muComBase.h:180
+
void writeByte(uint8_t index, uint8_t data)
Write a byte (8 bit) to the communication partner.
Definition: muComBase.h:206
+
int8_t readShort(uint8_t index, uint16_t *data)
Read a short from the communication partner.
Definition: muComBase.h:268
+
void writeLong(uint8_t index, uint32_t data)
Write a long (32 bit) to the communication partner.
Definition: muComBase.h:222
int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size)
Link a variable or a buffer to the muCom interface.
Definition: muComBase.cpp:213
-
int8_t readFloat(uint8_t index, float *data)
Read a float from the communication partner.
Definition: muComBase.h:303
+
int8_t readFloat(uint8_t index, float *data)
Read a float from the communication partner.
Definition: muComBase.h:304
uint8_t handle(void)
Handle the muCom interface.
Definition: muComBase.cpp:85
int8_t read(uint8_t index, uint8_t *data, uint8_t cnt)
Read data from the communication partner.
Definition: muComBase.cpp:265
-
void writeLongLong(uint8_t index, uint64_t data)
Write a long long (64 bit) to the communication partner.
Definition: muComBase.h:229
+
void writeLongLong(uint8_t index, uint64_t data)
Write a long long (64 bit) to the communication partner.
Definition: muComBase.h:230
muComBase(uint8_t num_var, uint8_t num_func)
Constructor of the base class.
Definition: muComBase.cpp:47
-
void writeFloat(uint8_t index, float data)
Write a float to the communication partner.
Definition: muComBase.h:237
+
void writeFloat(uint8_t index, float data)
Write a float to the communication partner.
Definition: muComBase.h:238
uint32_t getLastCommTime(void)
Get timestamp of last successful communication.
Definition: muComBase.h:108
-
int8_t readByte(uint8_t index, uint8_t *data)
Read a byte from the communication partner.
Definition: muComBase.h:255
-
int8_t readLong(uint8_t index, uint32_t *data)
Read a long from the communication partner.
Definition: muComBase.h:279
+
int8_t readByte(uint8_t index, uint8_t *data)
Read a byte from the communication partner.
Definition: muComBase.h:256
+
int8_t readLong(uint8_t index, uint32_t *data)
Read a long from the communication partner.
Definition: muComBase.h:280
Base muCom class.
Definition: muComBase.h:58
int8_t linkFunction(uint8_t index, muComFunc function)
Link function to the muCom interface.
Definition: muComBase.cpp:199
Internal structure to store references to linked variables.
Definition: muComBase.h:47
diff --git a/extras/html/structmu_com___linked_variable__str-members.html b/extras/html/structmu_com___linked_variable__str-members.html index 04e039e..e98a8b2 100644 --- a/extras/html/structmu_com___linked_variable__str-members.html +++ b/extras/html/structmu_com___linked_variable__str-members.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/structmu_com___linked_variable__str.html b/extras/html/structmu_com___linked_variable__str.html index bd68f73..1262209 100644 --- a/extras/html/structmu_com___linked_variable__str.html +++ b/extras/html/structmu_com___linked_variable__str.html @@ -19,7 +19,7 @@
muCom -  1.1 +  1.2
The reliable, fast and easy way to exchange binary data via UART
From 37edab7ee5c7e2145e159226f9785ba26d2ede80 Mon Sep 17 00:00:00 2001 From: kcl93 Date: Fri, 12 Feb 2021 23:33:29 +0100 Subject: [PATCH 03/14] Bugfixes --- README.md | 4 +++- extras/Doxyfile | 2 +- extras/html/annotated.html | 2 +- extras/html/classes.html | 2 +- extras/html/classmu_com-members.html | 2 +- extras/html/classmu_com.html | 2 +- extras/html/classmu_com_base-members.html | 2 +- extras/html/classmu_com_base.html | 2 +- .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- extras/html/files.html | 2 +- extras/html/functions.html | 2 +- extras/html/functions_func.html | 2 +- extras/html/hierarchy.html | 2 +- extras/html/index.html | 2 +- extras/html/mu_com_8h_source.html | 2 +- extras/html/mu_com_base_8h_source.html | 2 +- ...uctmu_com___linked_variable__str-members.html | 2 +- .../structmu_com___linked_variable__str.html | 2 +- library.properties | 2 +- src/muComBase.cpp | 16 ++++++++-------- 20 files changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 7d697eb..dadc0de 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Variables and functions are accessed via indexes which need to be known to their The muCom protocol does not define master or slave ECUs. Both act as equal partners and define their capabilities but the variables and functions they link to the muCom interface. -##### Benchmark results ##### +##### Benchmark results from v1.1 ##### | Function | Execution time in us | | --- | --- | | writeByte() | 35 | @@ -33,3 +33,5 @@ Executed on an Atmega328p with a 250000kBaud serial interface in loopback mode. ##### Frame structure ##### See muComBase.cpp for details regarding the binary structure of muCom frames. +Each muCom frame is tuned for maximum transmission speed and efficiency resulting in a binary efficiency of 87.5% when comparing the useful transmitted data (frame type, payload byte count and target variable ID are considered useful) to the overall frame length. +The muCom protocol has no need for wait times for frame synchronization, allowing the serial interface to run at 100% load when streaming data as fast as possible. diff --git a/extras/Doxyfile b/extras/Doxyfile index ca76b7b..700fde9 100644 --- a/extras/Doxyfile +++ b/extras/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = muCom # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2 +PROJECT_NUMBER = 1.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/extras/html/annotated.html b/extras/html/annotated.html index 6f4ac1f..23c1ca2 100644 --- a/extras/html/annotated.html +++ b/extras/html/annotated.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classes.html b/extras/html/classes.html index bb0587c..15bf486 100644 --- a/extras/html/classes.html +++ b/extras/html/classes.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com-members.html b/extras/html/classmu_com-members.html index 951bff1..a090134 100644 --- a/extras/html/classmu_com-members.html +++ b/extras/html/classmu_com-members.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com.html b/extras/html/classmu_com.html index f955c70..e65834d 100644 --- a/extras/html/classmu_com.html +++ b/extras/html/classmu_com.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com_base-members.html b/extras/html/classmu_com_base-members.html index 7c3adfc..b17c56d 100644 --- a/extras/html/classmu_com_base-members.html +++ b/extras/html/classmu_com_base-members.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/classmu_com_base.html b/extras/html/classmu_com_base.html index 8cd0854..b6d22e3 100644 --- a/extras/html/classmu_com_base.html +++ b/extras/html/classmu_com_base.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 56b57f9..dd483ab 100644 --- a/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/extras/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/files.html b/extras/html/files.html index 766adfa..137ca26 100644 --- a/extras/html/files.html +++ b/extras/html/files.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/functions.html b/extras/html/functions.html index c00254c..d600f6d 100644 --- a/extras/html/functions.html +++ b/extras/html/functions.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/functions_func.html b/extras/html/functions_func.html index ee6e2f6..e8f2d13 100644 --- a/extras/html/functions_func.html +++ b/extras/html/functions_func.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/hierarchy.html b/extras/html/hierarchy.html index 613122b..ccee170 100644 --- a/extras/html/hierarchy.html +++ b/extras/html/hierarchy.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/index.html b/extras/html/index.html index b0ae71d..244772a 100644 --- a/extras/html/index.html +++ b/extras/html/index.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/mu_com_8h_source.html b/extras/html/mu_com_8h_source.html index 26b81af..030f322 100644 --- a/extras/html/mu_com_8h_source.html +++ b/extras/html/mu_com_8h_source.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/mu_com_base_8h_source.html b/extras/html/mu_com_base_8h_source.html index 36b4e28..1a99cfb 100644 --- a/extras/html/mu_com_base_8h_source.html +++ b/extras/html/mu_com_base_8h_source.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/structmu_com___linked_variable__str-members.html b/extras/html/structmu_com___linked_variable__str-members.html index e98a8b2..e60108e 100644 --- a/extras/html/structmu_com___linked_variable__str-members.html +++ b/extras/html/structmu_com___linked_variable__str-members.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/extras/html/structmu_com___linked_variable__str.html b/extras/html/structmu_com___linked_variable__str.html index 1262209..b8cbda4 100644 --- a/extras/html/structmu_com___linked_variable__str.html +++ b/extras/html/structmu_com___linked_variable__str.html @@ -19,7 +19,7 @@
muCom -  1.2 +  1.3
The reliable, fast and easy way to exchange binary data via UART
diff --git a/library.properties b/library.properties index 632cd4f..2ae00f4 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=muCom -version=1.2 +version=1.3 author=Kai Liebich maintainer=Kai Liebich sentence=The reliable, fast and easy way to exchange binary data via UART diff --git a/src/muComBase.cpp b/src/muComBase.cpp index 0c4c0f6..4663860 100644 --- a/src/muComBase.cpp +++ b/src/muComBase.cpp @@ -122,8 +122,8 @@ uint8_t muComBase::handle(void) this->_rcv_buf_cnt++; if((frameDesc == MUCOM_READ_REQUEST) - || ((dataCnt <= 1) && (this->_rcv_buf_cnt >= dataCnt)) - || (this->_rcv_buf_cnt >= (dataCnt + 1))) + || ((dataCnt == 1) && (this->_rcv_buf_cnt >= (dataCnt + 2))) + || (this->_rcv_buf_cnt > (dataCnt + 2))) { //Sufficient data received. Decode it and do stuff if required @@ -157,28 +157,28 @@ uint8_t muComBase::handle(void) case MUCOM_READ_REQUEST: //Check index, whether a variable is linked and whether the read size is not greater than the linked variable size - if((this->_rcv_buf[0] <= this->_linked_var_num) && (this->_linked_var[this->_rcv_buf[0]].addr != NULL) && (dataCnt <= this->_linked_var[this->_rcv_buf[0]].size)) + if((this->_rcv_buf[0] < this->_linked_var_num) && (this->_linked_var[this->_rcv_buf[0]].addr != NULL) && (dataCnt <= this->_linked_var[this->_rcv_buf[0]].size)) { - this->writeRaw(MUCOM_READ_RESPONSE, this->_rcv_buf[0], this->_linked_var[this->_rcv_buf[0]].addr, this->_linked_var[this->_rcv_buf[0]].size); + this->writeRaw(MUCOM_READ_RESPONSE, this->_rcv_buf[0], this->_linked_var[this->_rcv_buf[0]].addr, dataCnt); } break; case MUCOM_WRITE_REQUEST: //Check index, whether a variable is linked and whether the read size is not greater than the linked variable size - if((this->_rcv_buf[0] <= this->_linked_var_num) && (this->_linked_var[this->_rcv_buf[0]].addr != NULL) && (dataCnt <= this->_linked_var[this->_rcv_buf[0]].size)) + if((this->_rcv_buf[0] < this->_linked_var_num) && (this->_linked_var[this->_rcv_buf[0]].addr != NULL) && (dataCnt <= this->_linked_var[this->_rcv_buf[0]].size)) { for(tmp = 0; tmp < dataCnt; tmp++) { - (this->_linked_var[this->_rcv_buf[0]].addr)[tmp] = this->_rcv_buf[tmp + 1]; + this->_linked_var[this->_rcv_buf[0]].addr[tmp] = this->_rcv_buf[tmp + 1]; } } break; case MUCOM_EXECUTE_REQUEST: //Check index and whether a function is linked - if((this->_rcv_buf[0] <= this->_linked_func_num) && (this->_linked_func[this->_rcv_buf[0]] != NULL)) + if((this->_rcv_buf[0] < this->_linked_func_num) && (this->_linked_func[this->_rcv_buf[0]] != NULL)) { - (this->_linked_func[this->_rcv_buf[0]])(this->_rcv_buf, dataCnt); + (this->_linked_func[this->_rcv_buf[0]])((uint8_t*)(this->_rcv_buf + 1), dataCnt); } break; From 31924a6e3f8b89ef42155d9a2373c70033b1b233 Mon Sep 17 00:00:00 2001 From: kcl93 Date: Fri, 12 Feb 2021 23:51:49 +0100 Subject: [PATCH 04/14] Interrupts should be disabled during write accesses to own variables --- extras/html/mu_com_8h_source.html | 21 +- extras/html/mu_com_base_8h_source.html | 258 +++++++++++++------------ src/muCom.h | 5 + src/muComBase.cpp | 2 + src/muComBase.h | 6 + 5 files changed, 158 insertions(+), 134 deletions(-) diff --git a/extras/html/mu_com_8h_source.html b/extras/html/mu_com_8h_source.html index 030f322..2feb300 100644 --- a/extras/html/mu_com_8h_source.html +++ b/extras/html/mu_com_8h_source.html @@ -76,15 +76,20 @@
38  inline uint32_t _getTimestamp(void)
39  { return millis(); }
40 
-
41 
-
42  public:
-
43  muCom(Stream &ser, uint8_t num_var, uint8_t num_func);
-
44 };
-
45 
-
46 
-
47 #endif //MUCOM_H
+
41  inline void _disableInterrupts(void)
+
42  { noInterrupts(); }
+
43 
+
44  inline void _enableInterrupts(void)
+
45  { interrupts(); }
+
46 
+
47  public:
+
48  muCom(Stream &ser, uint8_t num_var, uint8_t num_func);
+
49 };
+
50 
+
51 
+
52 #endif //MUCOM_H
-
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:198
+
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:204
Base muCom class.
Definition: muComBase.h:58
File containing the main class for the muCom interface when being used for an Arduino.
Definition: muCom.h:21
diff --git a/extras/html/mu_com_base_8h_source.html b/extras/html/mu_com_base_8h_source.html index 1a99cfb..8104d79 100644 --- a/extras/html/mu_com_base_8h_source.html +++ b/extras/html/mu_com_base_8h_source.html @@ -118,147 +118,153 @@
85  //Internal function to get the current timestamp in ms
86  virtual uint32_t _getTimestamp(void) = 0;
87 
-
88 
-
89  public:
-
95  muComBase(uint8_t num_var, uint8_t num_func);
-
96 
-
97 
-
101  ~muComBase(void);
+
88  //Internal function to disable interrupts
+
89  virtual void _disableInterrupts(void) = 0;
+
90 
+
91  //Internal function to enable interrupts
+
92  virtual void _enableInterrupts(void) = 0;
+
93 
+
94 
+
95  public:
+
101  muComBase(uint8_t num_var, uint8_t num_func);
102 
103 
-
108  inline uint32_t getLastCommTime(void)
-
109  { return this->_lastCommTime; }
-
110 
-
111 
-
116  void setTimeout(int16_t timeout);
+
107  ~muComBase(void);
+
108 
+
109 
+
114  inline uint32_t getLastCommTime(void)
+
115  { return this->_lastCommTime; }
+
116 
117 
-
118 
-
126  uint8_t handle(void);
-
127 
-
128 
-
134  int8_t linkFunction(uint8_t index, muComFunc function);
-
135 
-
136 
-
144  int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size);
-
145 
-
146  inline int8_t linkVariable(uint8_t index, uint8_t *var)
-
147  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint8_t)); }
-
148 
-
149  inline int8_t linkVariable(uint8_t index, int8_t *var)
-
150  { return this->linkVariable(index, (uint8_t*)var, sizeof(int8_t)); }
+
122  void setTimeout(int16_t timeout);
+
123 
+
124 
+
132  uint8_t handle(void);
+
133 
+
134 
+
140  int8_t linkFunction(uint8_t index, muComFunc function);
+
141 
+
142 
+
150  int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size);
151 
-
152  inline int8_t linkVariable(uint8_t index, uint16_t *var)
-
153  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint16_t)); }
-
154 
-
155  inline int8_t linkVariable(uint8_t index, int16_t *var)
-
156  { return this->linkVariable(index, (uint8_t*)var, sizeof(int16_t)); }
+
152  inline int8_t linkVariable(uint8_t index, uint8_t *var)
+
153  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint8_t)); }
+
154 
+
155  inline int8_t linkVariable(uint8_t index, int8_t *var)
+
156  { return this->linkVariable(index, (uint8_t*)var, sizeof(int8_t)); }
157 
-
158  inline int8_t linkVariable(uint8_t index, uint32_t *var)
-
159  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint32_t)); }
+
158  inline int8_t linkVariable(uint8_t index, uint16_t *var)
+
159  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint16_t)); }
160 
-
161  inline int8_t linkVariable(uint8_t index, int32_t *var)
-
162  { return this->linkVariable(index, (uint8_t*)var, sizeof(int32_t)); }
+
161  inline int8_t linkVariable(uint8_t index, int16_t *var)
+
162  { return this->linkVariable(index, (uint8_t*)var, sizeof(int16_t)); }
163 
-
164  inline int8_t linkVariable(uint8_t index, uint64_t *var)
-
165  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint64_t)); }
+
164  inline int8_t linkVariable(uint8_t index, uint32_t *var)
+
165  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint32_t)); }
166 
-
167  inline int8_t linkVariable(uint8_t index, int64_t *var)
-
168  { return this->linkVariable(index, (uint8_t*)var, sizeof(int64_t)); }
+
167  inline int8_t linkVariable(uint8_t index, int32_t *var)
+
168  { return this->linkVariable(index, (uint8_t*)var, sizeof(int32_t)); }
169 
-
170  inline int8_t linkVariable(uint8_t index, float *var)
-
171  { return this->linkVariable(index, (uint8_t*)var, sizeof(float)); }
+
170  inline int8_t linkVariable(uint8_t index, uint64_t *var)
+
171  { return this->linkVariable(index, (uint8_t*)var, sizeof(uint64_t)); }
172 
-
173 
-
180  inline void invokeFunction(uint8_t index, uint8_t* data, uint8_t cnt)
-
181  { this->writeRaw(MUCOM_EXECUTE_REQUEST, index, data, cnt); }
-
182 
-
188  inline void invokeFunction(uint8_t index)
-
189  { uint8_t dummy; this->writeRaw(MUCOM_EXECUTE_REQUEST, index, &dummy, 1); }
-
190 
-
191 
-
198  inline void write(uint8_t index, uint8_t *data, uint8_t cnt)
-
199  { this->writeRaw(MUCOM_WRITE_REQUEST, index, data, cnt); }
-
200 
-
206  inline void writeByte(uint8_t index, uint8_t data)
-
207  { this->write(index, (uint8_t*)&data, sizeof(uint8_t)); }
-
208 
-
214  inline void writeShort(uint8_t index, uint16_t data)
-
215  { this->write(index, (uint8_t*)&data, sizeof(uint16_t)); }
-
216 
-
222  inline void writeLong(uint8_t index, uint32_t data)
-
223  { this->write(index, (uint8_t*)&data, sizeof(uint32_t)); }
-
224 
-
230  inline void writeLongLong(uint8_t index, uint64_t data)
-
231  { this->write(index, (uint8_t*)&data, sizeof(uint64_t)); }
-
232 
-
238  inline void writeFloat(uint8_t index, float data)
-
239  { this->write(index, (uint8_t*)&data, sizeof(float)); }
-
240 
-
241 
-
248  int8_t read(uint8_t index, uint8_t *data, uint8_t cnt);
-
249 
-
256  inline int8_t readByte(uint8_t index, uint8_t *data)
-
257  { return this->read(index, (uint8_t*)data, sizeof(uint8_t)); }
-
258 
-
259  inline int8_t readByte(uint8_t index, int8_t *data)
-
260  { return this->read(index, (uint8_t*)data, sizeof(int8_t)); }
-
261 
-
268  inline int8_t readShort(uint8_t index, uint16_t *data)
-
269  { return this->read(index, (uint8_t*)data, sizeof(uint16_t)); }
-
270 
-
271  inline int8_t readShort(uint8_t index, int16_t *data)
-
272  { return this->read(index, (uint8_t*)data, sizeof(int16_t)); }
-
273 
-
280  inline int8_t readLong(uint8_t index, uint32_t *data)
-
281  { return this->read(index, (uint8_t*)data, sizeof(uint32_t)); }
-
282 
-
283  inline int8_t readLong(uint8_t index, int32_t *data)
-
284  { return this->read(index, (uint8_t*)data, sizeof(int32_t)); }
-
285 
-
292  inline int8_t readLongLong(uint8_t index, uint64_t *data)
-
293  { return this->read(index, (uint8_t*)data, sizeof(uint64_t)); }
-
294 
-
295  inline int8_t readLongLong(uint8_t index, int64_t *data)
-
296  { return this->read(index, (uint8_t*)data, sizeof(int64_t)); }
-
297 
-
304  inline int8_t readFloat(uint8_t index, float *data)
-
305  { return this->read(index, (uint8_t*)data, sizeof(float)); }
-
306 
-
313  uint8_t readByte(uint8_t index);
-
314 
-
321  uint16_t readShort(uint8_t index);
-
322 
-
329  uint32_t readLong(uint8_t index);
-
330 
-
337  uint64_t readLongLong(uint8_t index);
-
338 
-
345  float readFloat(uint8_t index);
-
346 };
-
347 
-
348 
-
349 #endif //MUCOMBASE_H
+
173  inline int8_t linkVariable(uint8_t index, int64_t *var)
+
174  { return this->linkVariable(index, (uint8_t*)var, sizeof(int64_t)); }
+
175 
+
176  inline int8_t linkVariable(uint8_t index, float *var)
+
177  { return this->linkVariable(index, (uint8_t*)var, sizeof(float)); }
+
178 
+
179 
+
186  inline void invokeFunction(uint8_t index, uint8_t* data, uint8_t cnt)
+
187  { this->writeRaw(MUCOM_EXECUTE_REQUEST, index, data, cnt); }
+
188 
+
194  inline void invokeFunction(uint8_t index)
+
195  { uint8_t dummy; this->writeRaw(MUCOM_EXECUTE_REQUEST, index, &dummy, 1); }
+
196 
+
197 
+
204  inline void write(uint8_t index, uint8_t *data, uint8_t cnt)
+
205  { this->writeRaw(MUCOM_WRITE_REQUEST, index, data, cnt); }
+
206 
+
212  inline void writeByte(uint8_t index, uint8_t data)
+
213  { this->write(index, (uint8_t*)&data, sizeof(uint8_t)); }
+
214 
+
220  inline void writeShort(uint8_t index, uint16_t data)
+
221  { this->write(index, (uint8_t*)&data, sizeof(uint16_t)); }
+
222 
+
228  inline void writeLong(uint8_t index, uint32_t data)
+
229  { this->write(index, (uint8_t*)&data, sizeof(uint32_t)); }
+
230 
+
236  inline void writeLongLong(uint8_t index, uint64_t data)
+
237  { this->write(index, (uint8_t*)&data, sizeof(uint64_t)); }
+
238 
+
244  inline void writeFloat(uint8_t index, float data)
+
245  { this->write(index, (uint8_t*)&data, sizeof(float)); }
+
246 
+
247 
+
254  int8_t read(uint8_t index, uint8_t *data, uint8_t cnt);
+
255 
+
262  inline int8_t readByte(uint8_t index, uint8_t *data)
+
263  { return this->read(index, (uint8_t*)data, sizeof(uint8_t)); }
+
264 
+
265  inline int8_t readByte(uint8_t index, int8_t *data)
+
266  { return this->read(index, (uint8_t*)data, sizeof(int8_t)); }
+
267 
+
274  inline int8_t readShort(uint8_t index, uint16_t *data)
+
275  { return this->read(index, (uint8_t*)data, sizeof(uint16_t)); }
+
276 
+
277  inline int8_t readShort(uint8_t index, int16_t *data)
+
278  { return this->read(index, (uint8_t*)data, sizeof(int16_t)); }
+
279 
+
286  inline int8_t readLong(uint8_t index, uint32_t *data)
+
287  { return this->read(index, (uint8_t*)data, sizeof(uint32_t)); }
+
288 
+
289  inline int8_t readLong(uint8_t index, int32_t *data)
+
290  { return this->read(index, (uint8_t*)data, sizeof(int32_t)); }
+
291 
+
298  inline int8_t readLongLong(uint8_t index, uint64_t *data)
+
299  { return this->read(index, (uint8_t*)data, sizeof(uint64_t)); }
+
300 
+
301  inline int8_t readLongLong(uint8_t index, int64_t *data)
+
302  { return this->read(index, (uint8_t*)data, sizeof(int64_t)); }
+
303 
+
310  inline int8_t readFloat(uint8_t index, float *data)
+
311  { return this->read(index, (uint8_t*)data, sizeof(float)); }
+
312 
+
319  uint8_t readByte(uint8_t index);
+
320 
+
327  uint16_t readShort(uint8_t index);
+
328 
+
335  uint32_t readLong(uint8_t index);
+
336 
+
343  uint64_t readLongLong(uint8_t index);
+
344 
+
351  float readFloat(uint8_t index);
+
352 };
+
353 
+
354 
+
355 #endif //MUCOMBASE_H
~muComBase(void)
Destructor of the base class.
Definition: muComBase.cpp:66
-
void invokeFunction(uint8_t index)
Invoke a function at the communication partner.
Definition: muComBase.h:188
-
void writeShort(uint8_t index, uint16_t data)
Write a short (16 bit) to the communication partner.
Definition: muComBase.h:214
-
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:198
-
int8_t readLongLong(uint8_t index, uint64_t *data)
Read a long long from the communication partner.
Definition: muComBase.h:292
-
void invokeFunction(uint8_t index, uint8_t *data, uint8_t cnt)
Invoke a function at the communication partner.
Definition: muComBase.h:180
-
void writeByte(uint8_t index, uint8_t data)
Write a byte (8 bit) to the communication partner.
Definition: muComBase.h:206
-
int8_t readShort(uint8_t index, uint16_t *data)
Read a short from the communication partner.
Definition: muComBase.h:268
-
void writeLong(uint8_t index, uint32_t data)
Write a long (32 bit) to the communication partner.
Definition: muComBase.h:222
-
int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size)
Link a variable or a buffer to the muCom interface.
Definition: muComBase.cpp:213
-
int8_t readFloat(uint8_t index, float *data)
Read a float from the communication partner.
Definition: muComBase.h:304
+
void invokeFunction(uint8_t index)
Invoke a function at the communication partner.
Definition: muComBase.h:194
+
void writeShort(uint8_t index, uint16_t data)
Write a short (16 bit) to the communication partner.
Definition: muComBase.h:220
+
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:204
+
int8_t readLongLong(uint8_t index, uint64_t *data)
Read a long long from the communication partner.
Definition: muComBase.h:298
+
void invokeFunction(uint8_t index, uint8_t *data, uint8_t cnt)
Invoke a function at the communication partner.
Definition: muComBase.h:186
+
void writeByte(uint8_t index, uint8_t data)
Write a byte (8 bit) to the communication partner.
Definition: muComBase.h:212
+
int8_t readShort(uint8_t index, uint16_t *data)
Read a short from the communication partner.
Definition: muComBase.h:274
+
void writeLong(uint8_t index, uint32_t data)
Write a long (32 bit) to the communication partner.
Definition: muComBase.h:228
+
int8_t linkVariable(uint8_t index, uint8_t *var, uint8_t size)
Link a variable or a buffer to the muCom interface.
Definition: muComBase.cpp:215
+
int8_t readFloat(uint8_t index, float *data)
Read a float from the communication partner.
Definition: muComBase.h:310
uint8_t handle(void)
Handle the muCom interface.
Definition: muComBase.cpp:85
-
int8_t read(uint8_t index, uint8_t *data, uint8_t cnt)
Read data from the communication partner.
Definition: muComBase.cpp:265
-
void writeLongLong(uint8_t index, uint64_t data)
Write a long long (64 bit) to the communication partner.
Definition: muComBase.h:230
+
int8_t read(uint8_t index, uint8_t *data, uint8_t cnt)
Read data from the communication partner.
Definition: muComBase.cpp:267
+
void writeLongLong(uint8_t index, uint64_t data)
Write a long long (64 bit) to the communication partner.
Definition: muComBase.h:236
muComBase(uint8_t num_var, uint8_t num_func)
Constructor of the base class.
Definition: muComBase.cpp:47
-
void writeFloat(uint8_t index, float data)
Write a float to the communication partner.
Definition: muComBase.h:238
-
uint32_t getLastCommTime(void)
Get timestamp of last successful communication.
Definition: muComBase.h:108
-
int8_t readByte(uint8_t index, uint8_t *data)
Read a byte from the communication partner.
Definition: muComBase.h:256
-
int8_t readLong(uint8_t index, uint32_t *data)
Read a long from the communication partner.
Definition: muComBase.h:280
+
void writeFloat(uint8_t index, float data)
Write a float to the communication partner.
Definition: muComBase.h:244
+
uint32_t getLastCommTime(void)
Get timestamp of last successful communication.
Definition: muComBase.h:114
+
int8_t readByte(uint8_t index, uint8_t *data)
Read a byte from the communication partner.
Definition: muComBase.h:262
+
int8_t readLong(uint8_t index, uint32_t *data)
Read a long from the communication partner.
Definition: muComBase.h:286
Base muCom class.
Definition: muComBase.h:58
-
int8_t linkFunction(uint8_t index, muComFunc function)
Link function to the muCom interface.
Definition: muComBase.cpp:199
+
int8_t linkFunction(uint8_t index, muComFunc function)
Link function to the muCom interface.
Definition: muComBase.cpp:201
Internal structure to store references to linked variables.
Definition: muComBase.h:47
void setTimeout(int16_t timeout)
Set timeout for read requests.
Definition: muComBase.cpp:74
diff --git a/src/muCom.h b/src/muCom.h index 5863ed0..94c31be 100644 --- a/src/muCom.h +++ b/src/muCom.h @@ -38,6 +38,11 @@ class muCom : public muComBase inline uint32_t _getTimestamp(void) { return millis(); } + inline void _disableInterrupts(void) + { noInterrupts(); } + + inline void _enableInterrupts(void) + { interrupts(); } public: muCom(Stream &ser, uint8_t num_var, uint8_t num_func); diff --git a/src/muComBase.cpp b/src/muComBase.cpp index 4663860..3d22a0c 100644 --- a/src/muComBase.cpp +++ b/src/muComBase.cpp @@ -167,10 +167,12 @@ uint8_t muComBase::handle(void) //Check index, whether a variable is linked and whether the read size is not greater than the linked variable size if((this->_rcv_buf[0] < this->_linked_var_num) && (this->_linked_var[this->_rcv_buf[0]].addr != NULL) && (dataCnt <= this->_linked_var[this->_rcv_buf[0]].size)) { + this->_disableInterrupts(); for(tmp = 0; tmp < dataCnt; tmp++) { this->_linked_var[this->_rcv_buf[0]].addr[tmp] = this->_rcv_buf[tmp + 1]; } + this->_enableInterrupts(); } break; diff --git a/src/muComBase.h b/src/muComBase.h index 06d2217..9b5e7d0 100644 --- a/src/muComBase.h +++ b/src/muComBase.h @@ -85,6 +85,12 @@ class muComBase //Internal function to get the current timestamp in ms virtual uint32_t _getTimestamp(void) = 0; + //Internal function to disable interrupts + virtual void _disableInterrupts(void) = 0; + + //Internal function to enable interrupts + virtual void _enableInterrupts(void) = 0; + public: /** From 0545199790c25914ef8fc5c91d4737836644c60a Mon Sep 17 00:00:00 2001 From: kcl93 Date: Sat, 13 Feb 2021 00:01:22 +0100 Subject: [PATCH 05/14] Using memcpy somehow saves 2 bytes in flash (and might be faster too) --- extras/html/mu_com_8h_source.html | 4 +- extras/html/mu_com_base_8h_source.html | 397 ++++++++++++------------- src/muComBase.cpp | 8 +- src/muComBase.h | 1 - 4 files changed, 203 insertions(+), 207 deletions(-) diff --git a/extras/html/mu_com_8h_source.html b/extras/html/mu_com_8h_source.html index 2feb300..766e568 100644 --- a/extras/html/mu_com_8h_source.html +++ b/extras/html/mu_com_8h_source.html @@ -89,8 +89,8 @@
51 
52 #endif //MUCOM_H
-
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:204
-
Base muCom class.
Definition: muComBase.h:58
+
void write(uint8_t index, uint8_t *data, uint8_t cnt)
Write a data array to a remote variable.
Definition: muComBase.h:203
+
Base muCom class.
Definition: muComBase.h:57
File containing the main class for the muCom interface when being used for an Arduino.
Definition: muCom.h:21