iCub-main
Loading...
Searching...
No Matches
fakeEthResource.h
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3/*
4 * Copyright (C) 2017 iCub Facility - Istituto Italiano di Tecnologia
5 * Author: Valentina Gaggero
6 * email: valentina.gaggero@iit.it
7 * website: www.robotcub.org
8 * Permission is granted to copy, distribute, and/or modify this program
9 * under the terms of the GNU General Public License, version 2 or any
10 * later version published by the Free Software Foundation.
11 *
12 * A copy of the license can be found at
13 * http://www.robotcub.org/icub/license/gpl.txt
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details
19*/
20
21// - include guard ----------------------------------------------------------------------------------------------------
22
23#ifndef _FAKEETHRESOURCE_H_
24#define _FAKEETHRESOURCE_H_
25
26
27#include <mutex>
28
30
31#include <ethManager.h>
32
33
34namespace eth {
35
37 {
38
39 public:
40
43
44
45 bool open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal) override;
46 bool close();
47
48 const Properties & getProperties();
49
50 const void * getUDPtransmit(eOipv4addressing_t &destination, size_t &sizeofpacket, uint16_t &numofrops);
51
52
53 bool processRXpacket(const void *data, const size_t size);
54
55
56 bool getRemoteValue(const eOprotID32_t id32, void *value, const double timeout = 0.100, const unsigned int retries = 0);
57
58 bool getRemoteValues(const std::vector<eOprotID32_t> &id32s, const std::vector<void*> &values, const double timeout = 0.500);
59
60 bool setRemoteValue(const eOprotID32_t id32, void *value);
61
62 bool setcheckRemoteValue(const eOprotID32_t id32, void *value, const unsigned int retries = 10, const double waitbeforecheck = 0.001, const double timeout = 0.050);
63
64 bool getLocalValue(const eOprotID32_t id32, void *value);
65
66 bool setLocalValue(const eOprotID32_t id32, const void *value, bool overrideROprotection = false);
67
68 bool verifyEPprotocol(eOprot_endpoint_t ep);
69
70 bool CANPrintHandler(eOmn_info_basic_t* infobasic);
71
72
73 bool serviceVerifyActivate(eOmn_serv_category_t category, const eOmn_serv_parameter_t* param, double timeout = 0.500);
74
75 bool serviceSetRegulars(eOmn_serv_category_t category, vector<eOprotID32_t> &id32vector, double timeout = 0.500);
76
77 bool serviceStart(eOmn_serv_category_t category, double timeout = 0.500);
78
79 bool serviceStop(eOmn_serv_category_t category, double timeout = 0.500);
80
81 bool Tick();
82 bool Check();
83
84// bool addSetMessage(eOprotID32_t id32, uint8_t* data);
85// bool addGetMessage(eOprotID32_t id32);
86// bool addGetMessage(eOprotID32_t id32, std::uint32_t signature);
87// bool addSetMessageAndCacheLocally(eOprotID32_t id32, uint8_t* data);
88// bool readSentValue(eOprotID32_t id32, uint8_t *data, uint16_t* size);
89// EOnv* getNVhandler(eOprotID32_t id32, EOnv* nv);
90
91
92 bool isFake();
93
95
96
97 private: //FAKE
98 eOipv4addressing_t ipv4addressing;
99 eOipv4addr_t ipv4addr;
100 string ipv4addrstring;
101 string boardName;
102 string boardTypeString;
103 eObrd_ethtype_t ethboardtype;
104 double lastRecvMsgTimestamp;
105 bool isInRunningMode;
106
107 std::mutex objLock;
108
109 bool verifiedEPprotocol[eoprot_endpoints_numberof];
110 bool verifiedBoardPresence;
111
112 bool verifiedBoardTransceiver; // transceiver capabilities (size of rop, ropframe, etc.) + MN protocol version
113 eOmn_comm_status_t boardCommStatus;
114 uint16_t usedNumberOfRegularROPs;
115
116 TheEthManager *ethManager;
117 HostTransceiver transceiver;
118
119 Properties properties;
120
121
122 private:
123
124
125 bool verifyBoard();
126
127
128
129 bool cleanBoardBehaviour(void);
130 // 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.
131 bool isRunning(void);
132
133 // lock of the object: on / off
134 bool lock(bool on);
135
136
137 bool verbosewhenok;
138 };
139
140
141} // namespace eth
142
143
144#endif // include-guard
145
146
147// - end-of-file (leave a blank line after)----------------------------------------------------------------------------
148
149
150
151
152
153
154
@ data
bool processRXpacket(const void *data, const size_t size)
bool serviceStart(eOmn_serv_category_t category, double timeout=0.500)
bool getRemoteValues(const std::vector< eOprotID32_t > &id32s, const std::vector< void * > &values, const double timeout=0.500)
bool getRemoteValue(const eOprotID32_t id32, void *value, const double timeout=0.100, const unsigned int retries=0)
const void * getUDPtransmit(eOipv4addressing_t &destination, size_t &sizeofpacket, uint16_t &numofrops)
HostTransceiver * getTransceiver()
bool serviceSetRegulars(eOmn_serv_category_t category, vector< eOprotID32_t > &id32vector, double timeout=0.500)
bool setRemoteValue(const eOprotID32_t id32, void *value)
bool serviceStop(eOmn_serv_category_t category, double timeout=0.500)
const Properties & getProperties()
bool setcheckRemoteValue(const eOprotID32_t id32, void *value, const unsigned int retries=10, const double waitbeforecheck=0.001, const double timeout=0.050)
bool open2(eOipv4addr_t remIP, yarp::os::Searchable &cfgtotal) override
bool verifyEPprotocol(eOprot_endpoint_t ep)
bool CANPrintHandler(eOmn_info_basic_t *infobasic)
bool setLocalValue(const eOprotID32_t id32, const void *value, bool overrideROprotection=false)
bool getLocalValue(const eOprotID32_t id32, void *value)
bool serviceVerifyActivate(eOmn_serv_category_t category, const eOmn_serv_parameter_t *param, double timeout=0.500)
grid on