iCub-main
Loading...
Searching...
No Matches
ethResource.h
Go to the documentation of this file.
1
2// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
3
4/*
5 * Copyright (C) 2017 iCub Facility - Istituto Italiano di Tecnologia
6 * Author: Alberto Cardellino, Marco Accame
7 * email: alberto.cardellino@iit.it, 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// - include guard ----------------------------------------------------------------------------------------------------
23
24#ifndef _ETHRESOURCE_H_
25#define _ETHRESOURCE_H_
26
27#include <mutex>
28
29#include <abstractEthResource.h>
30#include <hostTransceiver.hpp>
31
32#include <ethMonitorPresence.h>
33#include <EoBoards.h>
34
35#include <ethManager.h>
36
37
38//#include "can_string_eth.h" // its inclusion in here produces multiple definition of CanFrame
39class can_string_eth;
40
41namespace eth {
42
44 {
45
46 public:
47
50
51 bool open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal);
52 bool close();
53
54
55 const Properties & getProperties();
56
57 // FAKE: its size is 0 and it returen nullptr.
58 const void * getUDPtransmit(eOipv4addressing_t &destination, size_t &sizeofpacket, uint16_t &numofrops);
59
60 // FAKE: it just returns true.
61 bool processRXpacket(const void *data, size_t size);
62
63 // FAKE: it just returns true.
64 bool getRemoteValue(const eOprotID32_t id32, void *value, const double timeout = 0.100, const unsigned int retries = 0);
65
66 bool getRemoteValues(const std::vector<eOprotID32_t> &id32s, const std::vector<void*> &values, const double timeout = 0.500);
67
68 // FAKE: it just returns true or ... does the same
69 bool setRemoteValue(const eOprotID32_t id32, void *value);
70
71 // FAKE: it just returns true.
72 bool setcheckRemoteValue(const eOprotID32_t id32, void *value, const unsigned int retries = 10, const double waitbeforecheck = 0.001, const double timeout = 0.050);
73
74 // FAKE: it just returns true.
75 bool getLocalValue(const eOprotID32_t id32, void *value);
76
77 // FAKE: it just returns true.
78 bool setLocalValue(eOprotID32_t id32, const void *value, bool overrideROprotection = false);
79
80
81 // FAKE: it just returns true.
82 bool verifyEPprotocol(eOprot_endpoint_t ep);
83
84 // move it ???
85 bool CANPrintHandler(eOmn_info_basic_t* infobasic);
86
87
88 // FAKE make the internal serviceCommand() return always true ...
89 bool serviceVerifyActivate(eOmn_serv_category_t category, const eOmn_serv_parameter_t* param, double timeout = 0.500);
90 bool serviceSetRegulars(eOmn_serv_category_t category, vector<eOprotID32_t> &id32vector, double timeout = 0.500);
91 bool serviceStart(eOmn_serv_category_t category, double timeout = 0.500);
92 bool serviceStop(eOmn_serv_category_t category, double timeout = 0.500);
93
94 // FAKE: they both return true
95 bool Tick();
96 bool Check();
97
98
99 bool isFake();
100
102
103
104 private:
105
106 bool isInRunningMode;
107
108 std::mutex objLock;
109
110
111
112 bool verifiedEPprotocol[eoprot_endpoints_numberof];
113 bool verifiedBoardPresence;
114 bool askedBoardVersion;
115
116 eoprot_version_t boardMNprotocolversion;
117 eObrd_ethtype_t detectedBoardType;
118
119 bool verifiedBoardTransceiver; // transceiver capabilities (size of rop, ropframe, etc.) + MN protocol version
120 bool txrateISset;
121 bool cleanedBoardBehaviour; // the board is in config mode and does not have any regulars
122 uint16_t usedNumberOfRegularROPs;
123
124 can_string_eth* c_string_handler[16];
125
126 eth::TheEthManager *ethManager;
127
128 eth::EthMonitorPresence monitorpresence;
129
130 HostTransceiver transceiver;
131
132 bool regularsAreSet;
133
134 eOmn_appl_config_t txconfig;
135
136 Properties properties;
137
138 private:
139
140 enum { defTXrateOfRegularROPs = 3, defcycletime = 1000, defmaxtimeRX = 400, defmaxtimeDO = 300, defmaxtimeTX = 300 };
141
142
143 bool verifyBoard();
144 bool setTimingOfRunningCycle();
145 bool verifyBoardPresence();
146 bool verifyBoardTransceiver();
147 bool cleanBoardBehaviour(void);
148 bool askBoardVersion(void);
149 // we keep isRunning() and we add a field in the reply of serviceStart()/Stop() which tells if the board is in run mode or not.
150 bool isRunning(void);
151
152 // lock of the object: on / off
153 bool lock(bool on);
154
155 bool serviceCommand(eOmn_serv_operation_t operation, eOmn_serv_category_t category, const eOmn_serv_parameter_t* param, double timeout, int times);
156
157 bool verbosewhenok;
158
159 bool testMultipleASK();
160 };
161
162
163} // namespace eth
164
165
166#endif // include-guard
167
168
169// - end-of-file (leave a blank line after)----------------------------------------------------------------------------
170
171
@ data
bool getRemoteValues(const std::vector< eOprotID32_t > &id32s, const std::vector< void * > &values, const double timeout=0.500)
const void * getUDPtransmit(eOipv4addressing_t &destination, size_t &sizeofpacket, uint16_t &numofrops)
bool processRXpacket(const void *data, size_t size)
HostTransceiver * getTransceiver()
bool getLocalValue(const eOprotID32_t id32, void *value)
bool serviceSetRegulars(eOmn_serv_category_t category, vector< eOprotID32_t > &id32vector, double timeout=0.500)
bool open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal)
bool serviceStop(eOmn_serv_category_t category, double timeout=0.500)
bool verifyEPprotocol(eOprot_endpoint_t ep)
bool getRemoteValue(const eOprotID32_t id32, void *value, const double timeout=0.100, const unsigned int retries=0)
bool setLocalValue(eOprotID32_t id32, const void *value, bool overrideROprotection=false)
bool setRemoteValue(const eOprotID32_t id32, void *value)
bool setcheckRemoteValue(const eOprotID32_t id32, void *value, const unsigned int retries=10, const double waitbeforecheck=0.001, const double timeout=0.050)
bool serviceVerifyActivate(eOmn_serv_category_t category, const eOmn_serv_parameter_t *param, double timeout=0.500)
const Properties & getProperties()
bool serviceStart(eOmn_serv_category_t category, double timeout=0.500)
bool CANPrintHandler(eOmn_info_basic_t *infobasic)
grid on