SVHFirmwareInfo.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of the SCHUNK SVH Driver suite.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
12 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
13 //
14 // -- END LICENSE BLOCK ------------------------------------------------
15 
16 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 #ifndef SVHFIRMWAREINFO_H
28 #define SVHFIRMWAREINFO_H
29 
30 namespace driver_svh {
31 
36 {
38  std::string svh;
44  std::string text;
45 
47  bool operator == (const SVHFirmwareInfo& other) const
48  {
49  return (version_major == other.version_major && version_minor == other.version_minor);
50  }
51 };
52 
54 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, SVHFirmwareInfo& data)
55 {
56  // Stream operator can not handle arrays (due to missing size information) to make things easy we just copy the data around. Feel free to do something else
57  // Todo: The conversion in this direction is not properly working, as the readout is working fine so far this is a fix for later.
58  // It is probably something that has to do with the data types and how that is interpreted by the arrayBuilder
59  std::vector<int8_t> text(48);
60  std::vector<int8_t> svh(4);
61  svh.insert(svh.begin(),data.svh.begin(),data.svh.end());
62  text.insert(text.begin(),data.text.begin(),data.text.end());
63 
64  ab << svh
65  << data.version_major
66  << data.version_minor
67  << text;
68  return ab;
69 }
70 
71 
72 
74 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHFirmwareInfo& data)
75 {
76  // Stream operator can not handle arrays (due to missing size information) to make things easy we just copy the data around. Feel free to do something else
77  std::vector<uint8_t> text(48);
78  std::vector<uint8_t> svh(4);
79 
80  ab >> svh
81  >> data.version_major
82  >> data.version_minor
83  >> text;
84 
85 
86  data.text = std::string(text.begin(),text.end());
87  data.svh = std::string(svh.begin(),svh.end());
88 // std::copy (text.begin(),text.end(),data.text);
89 // std::copy (svh.begin(),svh.end(),data.svh);
90 
91  return ab;
92 }
93 
95 inline std::ostream& operator << (std::ostream& o, const SVHFirmwareInfo& fw)
96 {
97  o << fw.svh.c_str() << " " << fw.version_major << "." << fw.version_minor << " : " << fw.text.c_str() << endl;
98  return o;
99 }
100 
101 
102 
103 }
104 
105 
106 
107 #endif // SVHFIRMWAREINFO_H
bool operator==(const SVHFirmwareInfo &other) const
Compares two SVHFirmware objects.
uint16_t version_minor
Minor version number.
std::string svh
4 bytes identifier
icl_comm::ArrayBuilder & operator>>(icl_comm::ArrayBuilder &ab, SVHControlCommand &data)
overload stream operator to easily deserialize control commands for one channel
ThreadStream & endl(ThreadStream &stream)
The SVHFirmwareInfo holds the data of a firmware response from the hardware.
icl_comm::ArrayBuilder & operator<<(icl_comm::ArrayBuilder &ab, const SVHControlCommand &data)
uint16_t version_major
Major version number.
std::string text
48 bytes! of text (free)
unsigned short uint16_t


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Mon Jun 10 2019 15:04:59