include
schunk_svh_library
SVHFirmwareInfo.h
Go to the documentation of this file.
1
//
3
// © Copyright 2022 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
4
// © Copyright 2022 FZI Forschungszentrum Informatik, Karlsruhe, Germany
5
//
6
// This file is part of the Schunk SVH Library.
7
//
8
// The Schunk SVH Library is free software: you can redistribute it and/or
9
// modify it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 3 of the License, or (at your
11
// option) any later version.
12
//
13
// The Schunk SVH Library is distributed in the hope that it will be useful,
14
// but 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
// You should have received a copy of the GNU General Public License along with
19
// the Schunk SVH Library. If not, see <https://www.gnu.org/licenses/>.
20
//
22
23
//----------------------------------------------------------------------
33
//----------------------------------------------------------------------
34
#ifndef SVHFIRMWAREINFO_H
35
#define SVHFIRMWAREINFO_H
36
37
#include <iostream>
38
#include <string>
39
#include <vector>
40
41
#include <
schunk_svh_library/serial/ByteOrderConversion.h
>
42
43
namespace
driver_svh
{
44
48
struct
SVHFirmwareInfo
49
{
51
std::string
svh
;
53
uint16_t
version_major
;
55
uint16_t
version_minor
;
57
std::string
text
;
58
60
bool
operator==
(
const
SVHFirmwareInfo
& other)
const
61
{
62
return
(
version_major
== other.
version_major
&&
version_minor
== other.
version_minor
);
63
}
64
};
65
67
inline
driver_svh::ArrayBuilder
&
operator<<
(
driver_svh::ArrayBuilder
& ab,
SVHFirmwareInfo
& data)
68
{
69
// Stream operator can not handle arrays (due to missing size information) to make things easy we
70
// just copy the data around. Feel free to do something else Todo: The conversion in this
71
// direction is not properly working, as the readout is working fine so far this is a fix for
72
// later. It is probably something that has to do with the data types and how that is interpreted
73
// by the arrayBuilder
74
std::vector<int8_t> text(48);
75
std::vector<int8_t> svh(4);
76
svh.insert(svh.begin(), data.
svh
.begin(), data.
svh
.end());
77
text.insert(text.begin(), data.
text
.begin(), data.
text
.end());
78
79
ab << svh << data.
version_major
<< data.
version_minor
<< text;
80
return
ab;
81
}
82
83
85
inline
driver_svh::ArrayBuilder
&
operator>>
(
driver_svh::ArrayBuilder
& ab,
SVHFirmwareInfo
& data)
86
{
87
// Stream operator can not handle arrays (due to missing size information) to make things easy we
88
// just copy the data around. Feel free to do something else
89
std::vector<uint8_t> text(48);
90
std::vector<uint8_t> svh(4);
91
92
ab >> svh >> data.
version_major
>> data.
version_minor
>> text;
93
94
95
data.
text
= std::string(text.begin(), text.end());
96
data.
svh
= std::string(svh.begin(), svh.end());
97
// std::copy (text.begin(),text.end(),data.text);
98
// std::copy (svh.begin(),svh.end(),data.svh);
99
100
return
ab;
101
}
102
104
inline
std::ostream&
operator<<
(std::ostream& o,
const
SVHFirmwareInfo
& fw)
105
{
106
o << fw.
svh
.c_str() <<
" "
<< fw.
version_major
<<
"."
<< fw.
version_minor
<<
" : "
107
<< fw.
text
.c_str() << std::endl;
108
return
o;
109
}
110
111
112
}
// namespace driver_svh
113
114
115
#endif // SVHFIRMWAREINFO_H
driver_svh::ArrayBuilder
Definition:
ByteOrderConversion.h:146
driver_svh
Definition:
SVHControlCommand.h:39
ByteOrderConversion.h
driver_svh::SVHFirmwareInfo::operator==
bool operator==(const SVHFirmwareInfo &other) const
Compares two SVHFirmware objects.
Definition:
SVHFirmwareInfo.h:60
driver_svh::SVHFirmwareInfo
The SVHFirmwareInfo holds the data of a firmware response from the hardware.
Definition:
SVHFirmwareInfo.h:48
driver_svh::SVHFirmwareInfo::version_minor
uint16_t version_minor
Minor version number.
Definition:
SVHFirmwareInfo.h:55
driver_svh::SVHFirmwareInfo::version_major
uint16_t version_major
Major version number.
Definition:
SVHFirmwareInfo.h:53
driver_svh::operator>>
driver_svh::ArrayBuilder & operator>>(driver_svh::ArrayBuilder &ab, SVHControlCommand &data)
overload stream operator to easily deserialize control commands for one channel
Definition:
SVHControlCommand.h:143
driver_svh::operator<<
driver_svh::ArrayBuilder & operator<<(driver_svh::ArrayBuilder &ab, const SVHControlCommand &data)
Definition:
SVHControlCommand.h:134
driver_svh::SVHFirmwareInfo::text
std::string text
48 bytes! of text (free)
Definition:
SVHFirmwareInfo.h:57
driver_svh::SVHFirmwareInfo::svh
std::string svh
4 bytes identifier
Definition:
SVHFirmwareInfo.h:51
schunk_svh_library
Author(s): Georg Heppner, Lars Pfotzer, Felix Exner, Johannes Mangler, Stefan Scherzinger, Pascal Becker
autogenerated on Fri Apr 14 2023 02:53:52