SVHSerialPacket.cpp
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 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
30 
31 namespace driver_svh {
32 
33 icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, const SVHSerialPacket& data)
34 {
35  ab << data.index << data.address << static_cast<uint16_t>(data.data.size()) << data.data;
36  return ab;
37 }
38 
39 icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHSerialPacket& data)
40 {
41  // Disregard the size when deserializing as we get that anyway
42  uint16_t size ;
43  ab >> data.index >> data.address >> size >> data.data;
44  return ab;
45 }
46 
47 std::ostream& operator << (std::ostream& o, const SVHSerialPacket& sp)
48 {
49  o << "index: " << static_cast<int>(sp.index) << " address: " << "0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(sp.address) << " Data: ";
50  for (size_t i = 0; i < sp.data.size(); i++)
51  {
52  o << "0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(sp.data[i]) << " ";
53  }
54  // Reset Output stream to decimal output .. otherwise it may confuse people and the stream operators have the tendency to hang on to these hints
55  std::cout << std::dec ;
56  return o;
57 }
58 
59 }
60 
uint8_t address
Adress denotes the actual function of the package.
icl_comm::ArrayBuilder & operator>>(icl_comm::ArrayBuilder &ab, SVHControlCommand &data)
overload stream operator to easily deserialize control commands for one channel
std::vector< uint8_t > data
Payload of the package.
icl_comm::ArrayBuilder & operator<<(icl_comm::ArrayBuilder &ab, const SVHControlCommand &data)
uint8_t index
Continuosly incremented counter per package.
unsigned short uint16_t
The SerialPacket holds the (non generated) header and data of one message to the SVH-Hardware.


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