iCub-main
Loading...
Searching...
No Matches
EthBoard.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 iCub Facility - Istituto Italiano di Tecnologia
3 * Author: Marco Accame, Alessandro Scalzo
4 * email: marco.accame@iit.it, alessandro.scalzo@iit.it
5 * website: www.robotcub.org
6 * Permission is granted to copy, distribute, and/or modify this program
7 * under the terms of the GNU General Public License, version 2 or any
8 * later version published by the Free Software Foundation.
9 *
10 * A copy of the license can be found at
11 * http://www.robotcub.org/icub/license/gpl.txt
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details
17*/
18
19
20#ifndef __ETHBOARD_H__
21#define __ETHBOARD_H__
22
23
24#include <string>
25#include <vector>
26
27using namespace std;
28
29#include "EoCommon.h"
30#include "EoUpdaterProtocol.h"
31#include "EoBoards.h"
32
33// this struct contains the ultimate source of information for a given board
35{
36 uint8_t protversion; // the updater protocol used by the running process which is specified by:
37 uint64_t macaddress; // the mac address (only 6 bytes out of 8)
38 eObrd_ethtype_t boardtype; // the type of eth board
39 uint32_t capabilities; // it contains a mask of eOuprot_proc_capabilities_t which tells what the remote board can do
40 eOuprot_proctable_t processes; // it contains the properties of the processes in the remote board
41 uint8_t boardinfo32[32]; // if boardinfo32[0] is not 0xff then boardinfo32[1] contains a descriptive string of the remote board (30 characters max).
42 bool maintenanceIsActive;// tells if the maintenance is active (hence if the processes.runningnow is the eUpdater).
44 eOversion_t versionOfRunning; // we keep this info (which for protversion is also inside processes.info[processes.runningnow].version) because ...
45 // in the case of protversion 0 we dont have any info about which process is running now.
47 eOuprot_procinfo_t extraprocesses[2]; // this buffer is used to to transport the information related to the extraprocesses running multi-core processors
48
50 {
51 reset();
52 }
53
54 void reset(void)
55 {
56 protversion = 0;
57 macaddress = 0;
58 boardtype = eobrd_ethtype_unknown;
59 capabilities = 0;
60 applicationdetails = 0xff;
61 memset(&processes, 0, sizeof(processes));
62 processes.numberofthem = 0;
63 processes.def2run = uprot_proc_None;
64 processes.runningnow = uprot_proc_None;
65 processes.startup = uprot_proc_None;
66 processes.info[0].type = processes.info[1].type = processes.info[2].type = uprot_proc_None;
67 memset(boardinfo32, 0, sizeof(boardinfo32));
68 boardinfo32[0] = 0xff;
69 maintenanceIsActive = false;
70 versionOfRunning.major = versionOfRunning.minor = 0;
71 moreinfostring.clear();
72 extraprocesses[0].type = extraprocesses[1].type = uprot_proc_None;
73 }
74};
75
76
78{
79
80public:
81
83 eOipv4addr_t _ipv4;
86
87public:
88
89 EthBoard(boardInfo2_t &info2, eOipv4addr_t ipv4);
90
91 ~EthBoard();
92
93 void setSelected(bool selected);
94
95 bool isSelected();
96
97 void setIPV4(eOipv4addr_t ipv4);
98
99 eOipv4addr_t getIPV4();
100
101 string getIPV4string();
102
104
105 void setInfo(boardInfo2_t &info2);
106
107 bool isInMaintenance();
108
109 bool isInApplication();
110
111 void setMoreInfo(string &moreinfo);
112
113 const string getMoreInfo(void);
114
115 string getInfoOnEEPROM(void);
116
117 string getVersionfRunning(void);
118
119 string getDatefRunning(void);
120
121 string getCompilationDateOfRunning(void);
122
123 // we dont publish any other methods for what is inside _info2 .... use getInfo().
124
125};
126
127
128
130{
131public:
132 vector<EthBoard> theboards;
133
134#if defined(WIN32)
135 enum {
136 ipv4selected = EO_COMMON_IPV4ADDR(0, 0, 0, 0),
137 ipv4all = EO_COMMON_IPV4ADDR(255, 255, 255, 255)
138 };
139#else
140 static const eOipv4addr_t ipv4all;
141 static const eOipv4addr_t ipv4selected;
142#endif
143
144public:
145 EthBoardList();
146
148
149 // if force is true: it does not check if the mac or the ipv4 is already inside and just adds a new entry
150 // if force is false: it does a number of checks... in order of priority:
151 // 1. if it finds the same info2.macaddress inside an item list: it does not add a new item and refreshes the item matching the mac with info2
152 // 2. the mac is surely not in the list. if it finds the same ipv4 inside an item list: it adds a new entry (but if the item list has mac = 0,
153 // it refreshes the item).
154 int add(boardInfo2_t &info2, eOipv4addr_t ipv4, bool force = false);
155
156 int rem(eOipv4addr_t ipv4);
157
158 int clear();
159
160 int size();
161
162 // it selects on/off the board w/ a given ip address. if ipv4 is 0 the rule applies to all
163 void select(bool on, eOipv4addr_t ipv4);
164
165 // tells how many have that ip address. if 0, it tells how many are selected
166 int numberof(eOipv4addr_t ipv4);
167
168 // retrieve a vector of pointers with a given ip address. if ipv4 is 0, then it retrieves all the selected
169 // if 0xffffffff we retrieve them all
170 // we have a vector of pointer so that we can modify the boards (but dont delete them, use rem() or clear() instead).
171 vector<EthBoard *> get(eOipv4addr_t ipv4);
172
173 EthBoard& operator[](int i);
174};
175
176#endif
177
178
vector< EthBoard > theboards
Definition EthBoard.h:132
static const eOipv4addr_t ipv4all
Definition EthBoard.h:140
int numberof(eOipv4addr_t ipv4)
Definition EthBoard.cpp:279
vector< EthBoard * > get(eOipv4addr_t ipv4)
Definition EthBoard.cpp:310
int rem(eOipv4addr_t ipv4)
Definition EthBoard.cpp:239
void select(bool on, eOipv4addr_t ipv4)
Definition EthBoard.cpp:347
int add(boardInfo2_t &info2, eOipv4addr_t ipv4, bool force=false)
Definition EthBoard.cpp:186
EthBoard & operator[](int i)
Definition EthBoard.cpp:366
static const eOipv4addr_t ipv4selected
Definition EthBoard.h:141
string _ipv4string
Definition EthBoard.h:84
void setMoreInfo(string &moreinfo)
Definition EthBoard.cpp:90
string getCompilationDateOfRunning(void)
Definition EthBoard.cpp:150
string getVersionfRunning(void)
Definition EthBoard.cpp:107
bool _selected
Definition EthBoard.h:85
bool isInApplication()
Definition EthBoard.cpp:85
boardInfo2_t & getInfo()
Definition EthBoard.cpp:70
void setIPV4(eOipv4addr_t ipv4)
Definition EthBoard.cpp:52
eOipv4addr_t _ipv4
Definition EthBoard.h:83
boardInfo2_t _info2
Definition EthBoard.h:82
string getInfoOnEEPROM(void)
Definition EthBoard.cpp:100
string getDatefRunning(void)
Definition EthBoard.cpp:133
bool isSelected()
Definition EthBoard.cpp:47
string getIPV4string()
Definition EthBoard.cpp:65
const string getMoreInfo(void)
Definition EthBoard.cpp:95
void setInfo(boardInfo2_t &info2)
Definition EthBoard.cpp:75
void setSelected(bool selected)
Definition EthBoard.cpp:42
eOipv4addr_t getIPV4()
Definition EthBoard.cpp:60
bool isInMaintenance()
Definition EthBoard.cpp:80
grid on
eOversion_t versionOfRunning
Definition EthBoard.h:44
void reset(void)
Definition EthBoard.h:54
eObrd_ethtype_t boardtype
Definition EthBoard.h:38
uint8_t applicationdetails
Definition EthBoard.h:43
uint8_t protversion
Definition EthBoard.h:36
string moreinfostring
Definition EthBoard.h:46
uint8_t boardinfo32[32]
Definition EthBoard.h:41
uint32_t capabilities
Definition EthBoard.h:39
uint64_t macaddress
Definition EthBoard.h:37
eOuprot_procinfo_t extraprocesses[2]
Definition EthBoard.h:47
bool maintenanceIsActive
Definition EthBoard.h:42
eOuprot_proctable_t processes
Definition EthBoard.h:40