iCub-main
Loading...
Searching...
No Matches
ethParser.cpp
Go to the documentation of this file.
1// -*- Mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3
4/*
5 * Copyright (C) 2017 iCub Facility - Istituto Italiano di Tecnologia
6 * Author: Marco Accame
7 * email: marco.accame@iit.it
8 * website: www.robotcub.org
9 * Permission is granted to copy, distribute, and/or modify this program
10 * under the terms of the GNU General Public License, version 2 or any
11 * later version published by the Free Software Foundation.
12 *
13 * A copy of the license can be found at
14 * http://www.robotcub.org/icub/license/gpl.txt
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details
20*/
21
22
23// --------------------------------------------------------------------------------------------------------------------
24// - public interface
25// --------------------------------------------------------------------------------------------------------------------
26
27#include "ethParser.h"
28
29
30
31// --------------------------------------------------------------------------------------------------------------------
32// - external dependencies
33// --------------------------------------------------------------------------------------------------------------------
34
35
36#include <yarp/os/Log.h>
37#include <yarp/os/LogStream.h>
38using yarp::os::Log;
39
40#include <yarp/os/Bottle.h>
41#include <yarp/os/Value.h>
42
43using namespace yarp::os;
44
45
46// --------------------------------------------------------------------------------------------------------------------
47// - pimpl: private implementation (see scott meyers: item 22 of effective modern c++, item 31 of effective c++
48// --------------------------------------------------------------------------------------------------------------------
49
50
51
52// --------------------------------------------------------------------------------------------------------------------
53// - the class
54// --------------------------------------------------------------------------------------------------------------------
55
56
57bool eth::parser::print(const pc104Data &pc104data)
58{
59
60 yDebug() << "eth::parser::print(pc104Data) for PC104:";
61
62 yDebug() << "PC104/PC104IpAddress:PC104IpPort = " << pc104data.addressingstring;
63 yDebug() << "PC104/PC104TXrate = " << pc104data.txrate;
64 yDebug() << "PC104/PC104RXrate = " << pc104data.rxrate;
65
66 return true;
67}
68
69bool eth::parser::print(const boardData &boarddata)
70{
71
72 yDebug() << "eth::parser::print(boardData) for BOARD" << boarddata.settings.name;
73
74 yDebug() << "ETH_BOARD/ETH_BOARD_PROPERTIES:";
75 yDebug() << "ETH_BOARD/ETH_BOARD_PROPERTIES/IpAddress = " << boarddata.properties.ipv4string;
76 yDebug() << "ETH_BOARD/ETH_BOARD_PROPERTIES/IpPort = " << boarddata.properties.ipv4addressing.port;
77 yDebug() << "ETH_BOARD/ETH_BOARD_PROPERTIES/Type = " << boarddata.properties.typestring;
78 yDebug() << "ETH_BOARD/ETH_BOARD_PROPERTIES/maxSizeRXpacket = " << boarddata.properties.maxSizeRXpacket;
79 yDebug() << "ETH_BOARD/ETH_BOARD_PROPERTIES/maxSizeROP = " << boarddata.properties.maxSizeROP;
80
81 yDebug() << "ETH_BOARD/ETH_BOARD_SETTINGS:";
82 yDebug() << "ETH_BOARD/ETH_BOARD_SETTINGS/Name = " << boarddata.settings.name;
83 yDebug() << "ETH_BOARD/ETH_BOARD_SETTINGS/RUNNINGMODE/(period, maxTimeOfRXactivity, maxTimeOfDOactivity, maxTimeOfTXactivity, TXrateOfRegularROPs) = " <<
84 boarddata.settings.txconfig.cycletime << boarddata.settings.txconfig.maxtimeRX << boarddata.settings.txconfig.maxtimeDO << boarddata.settings.txconfig.maxtimeTX << boarddata.settings.txconfig.txratedivider;
85 yDebug() << "ETH_BOARD/ETH_BOARD_ACTIONS/MONITOR_ITS_PRESENCE";
86 yDebug() << "ETH_BOARD/ETH_BOARD_ACTIONS/MONITOR_ITS_PRESENCE/(enabled, timeout, periodOfMissingReport) = " <<
88
89 return true;
90}
91
92bool eth::parser::read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)
93{
94 pc104data.setdefault();
95
96 Bottle groupDEBUG = cfgtotal.findGroup("DEBUG");
97 if ((! groupDEBUG.isNull()) && (groupDEBUG.check("embBoardsConnected")))
98 {
99 pc104data.embBoardsConnected = groupDEBUG.find("embBoardsConnected").asBool();
100 }
101
102 if(!pc104data.embBoardsConnected)
103 {
104 yDebug() << "ATTENTION: NO EMBEDDED BOARDS CONNECTED. YOU ARE IN DEBUG MODE";
105 }
106
107 // localaddress
108
109 Bottle groupPC104 = Bottle(cfgtotal.findGroup("PC104"));
110 if (groupPC104.isNull())
111 {
112 yError() << "eth::parser::read() cannot find PC104 group in config files";
113 return false;
114 }
115
116 Value *value;
117
118 if (!groupPC104.check("PC104IpAddress", value))
119 {
120 yError() << "eth::parser::read(): missing PC104/PC104IpAddress in config files";
121 return false;
122 }
123 if (!groupPC104.check("PC104IpPort", value))
124 {
125 yError() << "eth::parser::read(): missing PC104/PC104IpPort in config files";
126 return false;
127 }
128
129 Bottle paramIPaddress(groupPC104.find("PC104IpAddress").asString());
130 uint16_t port = groupPC104.find("PC104IpPort").asInt32(); // .get(1).asInt32();
131 char strIP[64] = {0};
132
133
134 snprintf(strIP, sizeof(strIP), "%s", paramIPaddress.toString().c_str());
135 // strIP is now "10.0.1.104" ... i want to remove the "".... VERY IMPORTANT: use \" in sscanf
136 int ip1, ip2, ip3, ip4;
137 sscanf(strIP, "\"%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4);
138
139 pc104data.localaddressing.addr = eo_common_ipv4addr(ip1, ip2, ip3, ip4);
140 pc104data.localaddressing.port = port;
141
142 char ss[30];
143 snprintf(ss, sizeof(ss), "%d.%d.%d.%d:%d", ip1, ip2, ip3, ip4, port);
144
145 pc104data.addressingstring = ss;
146
147
148 // txrate
149 if(cfgtotal.findGroup("PC104").check("PC104TXrate"))
150 {
151 int value = cfgtotal.findGroup("PC104").find("PC104TXrate").asInt32();
152 if(value > 0)
153 {
154 pc104data.txrate = value;
155 }
156 }
157 else
158 {
159 yWarning () << "eth::parser::read() cannot find ETH/PC104TXrate. thus using default value" << pc104data.txrate;
160 }
161
162 // rxrate
163 if(cfgtotal.findGroup("PC104").check("PC104RXrate"))
164 {
165 int value = cfgtotal.findGroup("PC104").find("PC104RXrate").asInt32();
166 if(value > 0)
167 {
168 pc104data.rxrate = value;
169 }
170 }
171 else
172 {
173 yWarning () << "eth::parser::read() cannot find ETH/PC104RXrate. thus using default value" << pc104data.rxrate;
174 }
175
176 // now i print all the found values
177
178 //print(pc104data);
179
180 return true;
181}
182
183
184bool eth::parser::read(yarp::os::Searchable &cfgtotal, boardData &boarddata)
185{
186 Bottle groupEthBoard = Bottle(cfgtotal.findGroup("ETH_BOARD"));
187 if(groupEthBoard.isNull())
188 {
189 yError() << "eth::parser::read() cannot find ETH_BOARD group in config files";
190 return false;
191 }
192 Bottle groupEthBoardProps = Bottle(groupEthBoard.findGroup("ETH_BOARD_PROPERTIES"));
193 if(groupEthBoardProps.isNull())
194 {
195 yError() << "eth::parser::read() cannot find ETH_BOARD_PROPERTIES group in config files";
196 return false;
197 }
198 Bottle groupEthBoardSettings = Bottle(groupEthBoard.findGroup("ETH_BOARD_SETTINGS"));
199 if(groupEthBoardSettings.isNull())
200 {
201 yError() << "eth::parser::read() cannot find ETH_BOARD_PROPERTIES group in config files";
202 return false;
203 }
204
205 // -> ETH_BOARD/ETH_BOARD_PROPERTIES
206
207 boarddata.properties.reset();
208
209 // IpAddress:
210 if(true == groupEthBoardProps.check("IpAddress"))
211 {
212 Bottle paramIPboard(groupEthBoardProps.find("IpAddress").asString());
213 char str[64] = {0};
214 strcpy(str, paramIPboard.toString().c_str());
215 int ip1, ip2, ip3, ip4;
216 sscanf(str, "\"%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4);
217 boarddata.properties.ipv4addressing.addr = eo_common_ipv4addr(ip1, ip2, ip3, ip4);
218 }
219 else
220 {
221 yError() << "eth::parser::read() cannot find ETH_BOARD_PROPERTIES/IpAddress group in config files";
222 return false;
223 }
224
225 char ipinfo[20] = {0};
226 eo_common_ipv4addr_to_string(boarddata.properties.ipv4addressing.addr, ipinfo, sizeof(ipinfo));
227 boarddata.properties.ipv4string = ipinfo;
228
229
230 // IpPort:
231 if(true == groupEthBoardProps.check("IpPort"))
232 {
233 boarddata.properties.ipv4addressing.port = groupEthBoardProps.find("IpPort").asInt32();;
234 }
235 else
236 {
237 boarddata.properties.ipv4addressing.port = 12345;
238 yWarning() << "eth::parser::read() cannot find ETH_BOARD_PROPERTIES/IpPort group in config files." << " using:" << boarddata.properties.ipv4addressing.port;
239 }
240
241 snprintf(ipinfo, sizeof(ipinfo), ":%d", boarddata.properties.ipv4addressing.port);
242 boarddata.properties.ipv4addressingstring = boarddata.properties.ipv4string + ipinfo;
243
244
245 // Type:
246 Bottle b_ETH_BOARD_PROPERTIES_Type = groupEthBoardProps.findGroup("Type");
247 std::string Type = b_ETH_BOARD_PROPERTIES_Type.get(1).asString();
248 const char *strType = Type.c_str();
249 // 1. compare with the exceptions which may be in some old xml files ("EMS4", "MC4PLUS", "MC2PLUS"), and then then call proper functions
250 if(0 == strcmp(strType, "EMS4"))
251 {
252 boarddata.properties.type = eobrd_ethtype_ems4;
253 }
254 else if(0 == strcmp(strType, "MC4PLUS"))
255 {
256 boarddata.properties.type = eobrd_ethtype_mc4plus;
257 }
258 else if(0 == strcmp(strType, "MC2PLUS"))
259 {
260 boarddata.properties.type = eobrd_ethtype_mc2plus;
261 }
262 else
263 {
264 eObrd_type_t brd = eobrd_unknown;
265 if(eobrd_unknown == (brd = eoboards_string2type2(strType, eobool_true)))
266 {
267 brd = eoboards_string2type2(strType, eobool_false);
268 }
269
270 // if not found in compact or extended string format, we accept that the board is unknown
271
272 boarddata.properties.type = eoboards_type2ethtype(brd);
273 }
274 char boardTypeString[30];
275 snprintf(boardTypeString, sizeof(boardTypeString), "%s", eoboards_type2string2(eoboards_ethtype2type(boarddata.properties.type), eobool_true));
276
277 boarddata.properties.typestring = boardTypeString;
278
279 // maxSizeRXpacket:
280 if(true == groupEthBoardProps.check("maxSizeRXpacket"))
281 {
282 boarddata.properties.maxSizeRXpacket = groupEthBoardProps.find("maxSizeRXpacket").asInt32();
283 //yDebug() << "eth::parser::read() has detected capacityofTXpacket =" << boarddata.properties.maxSizeRXpacket << "for BOARD w/ IP" << boarddata.properties.ipv4string;
284 }
285 else
286 {
287 boarddata.properties.maxSizeRXpacket = 768;
288 yWarning() << "eth::parser::read() in BOARD w/ IP" << boarddata.properties.ipv4string << "cannot find: capacityofTXpacket. using:" << boarddata.properties.maxSizeRXpacket;
289 }
290
291 // maxSizeROP:
292 if(true == groupEthBoardProps.check("maxSizeROP"))
293 {
294 boarddata.properties.maxSizeROP = groupEthBoardProps.find("maxSizeROP").asInt32();
295 //yDebug() << "eth::parser::read() has detected maxSizeOfROP =" << boarddata.properties.maxSizeROP << "for BOARD w/ IP" << boarddata.properties.ipv4string;
296 }
297 else
298 {
299 boarddata.properties.maxSizeROP = 384;
300 yWarning() << "eth::parser::read() in BOARD w/ IP" << boarddata.properties.ipv4string << "cannot find: maxSizeROP. using:" << boarddata.properties.maxSizeROP;
301 }
302
303
304
305 // <- ETH_BOARD/ETH_BOARD_PROPERTIES
306
307
308 // -> ETH_BOARD/ETH_BOARD_SETTINGS
309
310 Bottle paramNameBoard(groupEthBoardSettings.find("Name").asString());
311 char xmlboardname[64] = {0};
312 snprintf(xmlboardname, sizeof(xmlboardname), "%s", paramNameBoard.toString().c_str());
313
314
315 if(0 != strlen(xmlboardname))
316 {
317 boarddata.settings.name = xmlboardname;
318 }
319 else
320 {
321 boarddata.settings.name = "NOT-NAMED";
322 }
323
324
325 // -> ETH_BOARD/ETH_BOARD_SETTINGS/RUNNINGMODE
326
327 Bottle groupEthBoardSettings_RunningMode = Bottle(groupEthBoardSettings.findGroup("RUNNINGMODE"));
328 if(groupEthBoardSettings_RunningMode.isNull())
329 {
330 yWarning() << "eth::parser::read(): cannot find ETH_BOARD_PROPERTIES/RUNNINGMODE group in config files for BOARD w/ IP" << boarddata.properties.ipv4string << " and will use default values";
331 yWarning() << "Default values for ETH_BOARD_PROPERTIES/RUNNINGMODE group: (period, maxTimeOfRXactivity, maxTimeOfDOactivity, maxTimeOfTXactivity, TXrateOfRegularROPs) = " <<
332 boarddata.settings.txconfig.cycletime << boarddata.settings.txconfig.maxtimeRX << boarddata.settings.txconfig.maxtimeDO << boarddata.settings.txconfig.maxtimeTX << boarddata.settings.txconfig.txratedivider;
333 }
334 else
335 {
336
337 if(true == groupEthBoardSettings_RunningMode.check("period"))
338 {
339 int tmp = groupEthBoardSettings_RunningMode.find("period").asInt32();
340
341 if(1000 != tmp)
342 {
343 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "ETH_BOARD_SETTINGS::RUNNINGMODE::period can be only 1000 (so far) and it was:" << tmp;
344 tmp = 1000;
345 }
346 boarddata.settings.txconfig.cycletime = tmp;
347 }
348
349 if(true == groupEthBoardSettings_RunningMode.check("maxTimeOfRXactivity"))
350 {
351 int tmp = groupEthBoardSettings_RunningMode.find("maxTimeOfRXactivity").asInt32();
352
353 if((tmp < 5) || (tmp > 990))
354 {
355 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "ETH_BOARD_SETTINGS::RUNNINGMODE::maxTimeOfRXactivity must be in [5, 990] (so far) and it was:" << tmp << "Using default value";
356 tmp = 400;
357 }
358
359 boarddata.settings.txconfig.maxtimeRX = tmp;
360 }
361
362 if(true == groupEthBoardSettings_RunningMode.check("maxTimeOfDOactivity"))
363 {
364 int tmp = groupEthBoardSettings_RunningMode.find("maxTimeOfDOactivity").asInt32();
365
366 if((tmp < 5) || (tmp > 990))
367 {
368 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "ETH_BOARD_SETTINGS::RUNNINGMODE::maxtimeOfDOactivity must be in [5, 990] (so far) and it was:" << tmp << "Using default value";
369 tmp = 300;
370 }
371
372 boarddata.settings.txconfig.maxtimeDO = tmp;
373 }
374
375 if(true == groupEthBoardSettings_RunningMode.check("maxTimeOfTXactivity"))
376 {
377 int tmp = groupEthBoardSettings_RunningMode.find("maxTimeOfTXactivity").asInt32();
378
379 if((tmp < 5) || (tmp > 990))
380 {
381 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "ETH_BOARD_SETTINGS::RUNNINGMODE::maxTimeOfTXactivity must be in [5, 990] (so far) and it was:" << tmp << "Using default value";
382 tmp = 300;
383 }
384
385 boarddata.settings.txconfig.maxtimeTX = tmp;
386 }
387
388
389 if(true == groupEthBoardSettings_RunningMode.check("TXrateOfRegularROPs"))
390 {
391 int tmp = groupEthBoardSettings_RunningMode.find("TXrateOfRegularROPs").asInt32();
392
393 if(tmp <=0)
394 {
395 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "ETH_BOARD_SETTINGS::RUNNINGMODE::TXrateOfRegularROPs must be in [1, 20] and it was:" << tmp << "Using value = 1";
396 tmp = 1;
397 }
398 if(tmp >200)
399 {
400 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "ETH_BOARD_SETTINGS::RUNNINGMODE::TXrateOfRegularROPs must be in [1, 20] and it was:" << tmp << "Using value = 20";
401 tmp = 20;
402 }
403 boarddata.settings.txconfig.txratedivider = tmp;
404 }
405
406 // consistency check
407 if((boarddata.settings.txconfig.maxtimeRX+boarddata.settings.txconfig.maxtimeDO+boarddata.settings.txconfig.maxtimeTX) != boarddata.settings.txconfig.cycletime)
408 {
409 yWarning() << "eth::parser::read() for BOARD" << boarddata.properties.ipv4string << "In ETH_BOARD_SETTINGS::RUNNINGMODE sum(maxTimeOfRXactivity, maxTimeOfDOactivity, maxTimeOfTXactivity) != period !!! Using default values";
410
411 yError() << boarddata.settings.txconfig.maxtimeRX+boarddata.settings.txconfig.maxtimeDO+boarddata.settings.txconfig.maxtimeTX;
412 boarddata.settings.txconfig.cycletime = 1000;
413 boarddata.settings.txconfig.maxtimeRX = 400;
414 boarddata.settings.txconfig.maxtimeDO = 300;
415 boarddata.settings.txconfig.maxtimeTX = 300;
416 }
417
418
419 // set initial values.
420
421 // in here i store the final values of the parsing
422 // they muts have the default values already in here
423 struct parseLOGGING
424 {
425 struct IMM
426 {
427 bool sigOVRFL {true};
428 };
429 struct PER
430 {
431 double period {0.0};
432 bool sigSTATS {false};
433 };
434
435 IMM immediate {};
436 PER periodic {};
437
438 void setdefault()
439 {
440 immediate.sigOVRFL = true;
441 periodic.period = 0;
442 periodic.sigSTATS = false;
443 }
444 };
445
446 parseLOGGING pLOG {};
447
448 pLOG.setdefault();
449
450 //bool log_imm_sigOVF {true};
451 //bool log_per_sigSTA {false};
452 //float log_per_periodSEC = 0.0;
453
454 Bottle groupEthBoardSettings_RunningMode_Logging = Bottle(groupEthBoardSettings_RunningMode.findGroup("LOGGING"));
455 if(groupEthBoardSettings_RunningMode_Logging.isNull())
456 {
457 yWarning() << "eth::parser::read(): cannot find ETH_BOARD_PROPERTIES/RUNNINGMODE/LOGGING group in config files for BOARD w/ IP" << boarddata.properties.ipv4string << " and will use default values";
458 yWarning() << "Default values for ETH_BOARD_PROPERTIES/RUNNINGMODE/LOGGING group: (IMMEDIATE.emitRXDOTXoverflow = true, PERIODIC.period = 0, PERIODIC.emitRXDOTXstatistics = false";
459 }
460 else
461 {
462 // find groups: IMMEDIATE and PERIODIC
463
464 Bottle groupEthBoardSettings_RunningMode_Logging_Immediate = Bottle(groupEthBoardSettings_RunningMode_Logging.findGroup("IMMEDIATE"));
465 if(groupEthBoardSettings_RunningMode_Logging_Immediate.isNull())
466 {
467 // IMMEDIATE not found, so i keep default value
468 }
469 else
470 {
471 if(false == groupEthBoardSettings_RunningMode_Logging_Immediate.check("emitRXDOTXoverflow"))
472 {
473 // IMMEDIATE.emitRXDOTXoverflow not found, so i keep default
474 }
475 else
476 {
477 if(groupEthBoardSettings_RunningMode_Logging_Immediate.find("emitRXDOTXoverflow").isBool())
478 {
479 printf("x 33\n");
480 pLOG.immediate.sigOVRFL = groupEthBoardSettings_RunningMode_Logging_Immediate.find("emitRXDOTXoverflow").asBool();
481 }
482 }
483 }
484
485 Bottle groupEthBoardSettings_RunningMode_Logging_Periodic = Bottle(groupEthBoardSettings_RunningMode_Logging.findGroup("PERIODIC"));
486 if(groupEthBoardSettings_RunningMode_Logging_Periodic.isNull())
487 {
488 printf("x 4\n");
489 // PERIODIC not found, so i keep default value
490 }
491 else
492 {
493
494 if(false == groupEthBoardSettings_RunningMode_Logging_Periodic.check("period"))
495 {
496 // PERIODIC.period not found, so i keep default
497 }
498 else
499 {
500 // i get it and i filter in range [0, 600)
501 if(true == groupEthBoardSettings_RunningMode_Logging_Periodic.find("period").isFloat64())
502 {
503 double tmp = groupEthBoardSettings_RunningMode_Logging_Periodic.find("period").asFloat64();
504 pLOG.periodic.period = (tmp<0.0) ? (0.0) : ( (tmp < 600.0) ? tmp : 600.0 );
505 }
506 }
507
508 if(false == groupEthBoardSettings_RunningMode_Logging_Periodic.check("emitRXDOTXstatistics"))
509 {
510 // PERIODIC.emitRXDOTXstatistics not found, so i keep default
511 }
512 else
513 {
514 pLOG.periodic.sigSTATS = groupEthBoardSettings_RunningMode_Logging_Periodic.find("emitRXDOTXstatistics").asBool();
515 }
516
517 }
518
519 yInfo() << "ETH_BOARD_PROPERTIES/RUNNINGMODE/LOGGING group for BOARD w/ IP" << boarddata.properties.ipv4string << " has values: " <<
520 "IMMEDIATE.emitRXDOTXoverflow = " << pLOG.immediate.sigOVRFL << " PERIODIC.period = " << pLOG.periodic.period << " PERIODIC.emitRXDOTXstatistics = " << pLOG.periodic.sigSTATS;
521
522 }
523
524
525 // now i apply the resulting values to the compact struct
526 constexpr uint16_t maskOverflow = (0x0001 << eomn_appl_log_asynchro_exectime_overflow);
527 constexpr uint16_t maskStatistics = (0x0001 << eomn_appl_log_periodic_exectime_statistics);
528 boarddata.settings.txconfig.logging.flags = 0;
529 if(true == pLOG.immediate.sigOVRFL) { boarddata.settings.txconfig.logging.flags |= maskOverflow; }
530 if(true == pLOG.periodic.sigSTATS) { boarddata.settings.txconfig.logging.flags |= maskStatistics; }
531 boarddata.settings.txconfig.logging.period10ms = static_cast<uint16_t>(100.0*pLOG.periodic.period); // period is uint16_t and keeps units of 10 ms to be able to manage up to 10 minutes
532
533 }
534
535
536 // <- ETH_BOARD/ETH_BOARD_SETTINGS/RUNNINGMODE
537
538
539 // <- ETH_BOARD/ETH_BOARD_SETTINGS
540
541
542 // -> ETH_BOARD/ETH_BOARD_ACTIONS
543 // -> ETH_BOARD/ETH_BOARD_ACTIONS/MONITOR_ITS_PRESENCE
544
545
546 // do we have a proper section ETH_BOARD_ACTIONS/MONITOR_ITS_PRESENCE? if so we change its config
547
548 Bottle groupEthBoardActions = Bottle(groupEthBoard.findGroup("ETH_BOARD_ACTIONS"));
549 if(!groupEthBoardActions.isNull())
550 {
551 Bottle groupEthBoardActions_Monitor = Bottle(groupEthBoardActions.findGroup("MONITOR_ITS_PRESENCE"));
552 if(!groupEthBoardActions_Monitor.isNull())
553 {
554 Bottle groupEthBoardActions_Monitor_enabled = groupEthBoardActions_Monitor.findGroup("enabled");
555 std::string Ena = groupEthBoardActions_Monitor_enabled.get(1).asString();
556 const char *strEna = Ena.c_str();
557
558 if(0 == strcmp(strEna, "true"))
559 {
560 boarddata.actions.monitorpresence_enabled = true;
561 }
562 else
563 {
564 boarddata.actions.monitorpresence_enabled = false;
565 }
566
567 if(true == groupEthBoardActions_Monitor.check("timeout"))
568 {
569 double presenceTimeout = groupEthBoardActions_Monitor.find("timeout").asFloat64();
570
571 if(presenceTimeout <= 0)
572 {
573 presenceTimeout = 0;
574 boarddata.actions.monitorpresence_enabled = false;
575 }
576
577 if(presenceTimeout > 0.100)
578 {
579 presenceTimeout = 0.100;
580 }
581
582 boarddata.actions.monitorpresence_timeout = presenceTimeout;
583
584 }
585
586
587 if(true == groupEthBoardActions_Monitor.check("periodOfMissingReport"))
588 {
589 double reportMissingPeriod = groupEthBoardActions_Monitor.find("periodOfMissingReport").asFloat64();
590
591 if(reportMissingPeriod <= 0)
592 {
593 reportMissingPeriod = 0.0;
594 }
595
596 if(reportMissingPeriod > 600)
597 {
598 reportMissingPeriod = 600;
599 }
600
601 boarddata.actions.monitorpresence_periodofmissingreport = reportMissingPeriod;
602 }
603 }
604 }
605
606 // <- ETH_BOARD/ETH_BOARD_ACTIONS/MONITOR_ITS_PRESENCE
607 // <- ETH_BOARD/ETH_BOARD_ACTIONS
608
609 return true;
610}
611
612
613// - end-of-file (leave a blank line after)----------------------------------------------------------------------------
614
615
bool read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)
Definition ethParser.cpp:92
bool print(const pc104Data &pc104data)
Definition ethParser.cpp:57
double monitorpresence_periodofmissingreport
Definition ethParser.h:74
boardActions actions
Definition ethParser.h:89
boardProperties properties
Definition ethParser.h:87
boardSettings settings
Definition ethParser.h:88
std::uint16_t maxSizeRXpacket
Definition ethParser.h:41
eOipv4addressing_t ipv4addressing
Definition ethParser.h:39
std::string ipv4addressingstring
Definition ethParser.h:43
eOmn_appl_config_t txconfig
Definition ethParser.h:59
eOipv4addressing_t localaddressing
Definition ethParser.h:101
std::string addressingstring
Definition ethParser.h:104
std::uint16_t rxrate
Definition ethParser.h:103
std::uint16_t txrate
Definition ethParser.h:102