iCub-main
Loading...
Searching...
No Matches
BoardInfo.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) 2012 RobotCub Consortium
5 * Author: Alessandro Scalzo alessandro.scalzo@iit.it
6 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7 *
8 */
9
10#ifndef __ETHUPDATER_BOARDINFO_H__
11#define __ETHUPDATER_BOARDINFO_H__
12
13
14#include <string>
15using namespace std;
16
17#include "EoCommon.h"
18#include "EoUpdaterProtocol.h"
19#include "EoBoards.h"
20
21
22typedef struct
23{
24 uint8_t protversion;
25 uint64_t macaddress;
26 uint8_t boardtype;
27 uint32_t capabilities; // very useful field. it allows to enable / disable some buttons of the GUI
28 eOuprot_proctable_t processes;
29 uint8_t boardinfo32[32];
31
32
34{
35public:
36 BoardInfo(ACE_UINT32 address,
37 ACE_UINT32 mask,
38 ACE_UINT64 mac,
39 ACE_UINT8 version_major,
40 ACE_UINT8 version_minor,
41 ACE_UINT8 protocol_version,
42 ACE_UINT32 protocol_capabilities)
43 {
44 mSelected=false;
45
46 mAddress=address;
47 mMask=mask;
48 mMac=mac;
49
50 mProtocolVersion = protocol_version;
51 mProtocolCapabilities = protocol_capabilities;
52
53 mVersionMajor=version_major;
54 mVersionMinor=version_minor;
55
56 mBoardType = string("N/A");
57
58 mRunningProcess = string("N/A");
59
60 mInfo32 = string("N/A");
61
62 mReleasedOn = string("N/A");
63 mBuiltOn = string("N/A");
64
65 mSuccess=0;
66 }
67
68
69 BoardInfo(ACE_UINT32 address, boardInfo_t &info)
70 {
71 mSelected = false;
72
73 mAddress = address;
74
75 mInfo = info;
76
77 mProtocolVersion = info.protversion;
78 mProtocolCapabilities = info.capabilities;
79
80 mMask = 0xFFFFFF00;
81 mMac = info.macaddress;
82
83 eOuprot_process_t runningnow = eouprot_raw2process(info.processes.runningnow);
84 mRunningProcess = from_process_to_string(runningnow);
85 mBoardType = from_boardtype_to_string(info.boardtype);
86 mInfo32 = (0xff == info.boardinfo32[0]) ? (string("N/A: PAGE32 IS UNFORMATTED")) : (string((const char*) &info.boardinfo32[1]));
87
88 uint8_t index = eouprot_process2index(runningnow);
89 if(255 == index)
90 { // error ...
91 mVersionMajor = 0;
92 mVersionMinor = 0;
93 mReleasedOn = string("N/A");
94 mBuiltOn = string("N/A");
95 }
96 else
97 {
98 mVersionMajor = info.processes.info[index].version.major;
99 mVersionMinor = info.processes.info[index].version.minor;
100 mReleasedOn = from_date_to_string(info.processes.info[index].date);
101 mBuiltOn = from_date_to_string(info.processes.info[index].compilationdate);
102 }
103
104 mSuccess=0;
105 }
106
107 virtual ~BoardInfo(){}
108
110
111 ACE_UINT32 mAddress;
112 ACE_UINT32 mMask;
113 ACE_UINT64 mMac;
114
117 ACE_UINT8 mVersionMajor;
118 ACE_UINT8 mVersionMinor;
119
120 ACE_UINT16 mSuccess;
121
124 string mInfo32;
125 string mBuiltOn;
127
128
130
131private:
132
133 string from_boardtype_to_string(uint8_t type)
134 {
135 // marco.accame.TODO: use what in EoCommon.c .......
136 string ret(eoboards_type2string2((eObrd_type_t)type, eobool_true));
137 return ret;
138 }
139
140 string from_process_to_string(eOuprot_process_t type)
141 {
142 string ret(eouprot_process2string(type));
143 return ret;
144 }
145
146 string from_date_to_string(eOdate_t date)
147 {
148 char strtmp[64];
149 eo_common_date_to_string(date, strtmp, sizeof(strtmp));
150 string ret(strtmp);
151 return ret;
152 }
153
154};
155
156#endif
BoardInfo(ACE_UINT32 address, ACE_UINT32 mask, ACE_UINT64 mac, ACE_UINT8 version_major, ACE_UINT8 version_minor, ACE_UINT8 protocol_version, ACE_UINT32 protocol_capabilities)
Definition BoardInfo.h:36
string mRunningProcess
Definition BoardInfo.h:123
ACE_UINT8 mVersionMinor
Definition BoardInfo.h:118
boardInfo_t mInfo
Definition BoardInfo.h:129
ACE_UINT32 mMask
Definition BoardInfo.h:112
ACE_UINT8 mProtocolVersion
Definition BoardInfo.h:115
ACE_UINT32 mAddress
Definition BoardInfo.h:111
bool mSelected
Definition BoardInfo.h:109
string mBoardType
Definition BoardInfo.h:122
BoardInfo(ACE_UINT32 address, boardInfo_t &info)
Definition BoardInfo.h:69
ACE_UINT32 mProtocolCapabilities
Definition BoardInfo.h:116
ACE_UINT8 mVersionMajor
Definition BoardInfo.h:117
ACE_UINT64 mMac
Definition BoardInfo.h:113
ACE_UINT16 mSuccess
Definition BoardInfo.h:120
string mReleasedOn
Definition BoardInfo.h:126
virtual ~BoardInfo()
Definition BoardInfo.h:107
string mBuiltOn
Definition BoardInfo.h:125
string mInfo32
Definition BoardInfo.h:124
uint8_t boardtype
Definition BoardInfo.h:26
uint64_t macaddress
Definition BoardInfo.h:25
uint8_t protversion
Definition BoardInfo.h:24
uint32_t capabilities
Definition BoardInfo.h:27
eOuprot_proctable_t processes
Definition BoardInfo.h:28