SVHSerialPacket.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of the SCHUNK SVH Driver suite.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
00012 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00013 //
00014 // -- END LICENSE BLOCK ------------------------------------------------
00015 
00016 //----------------------------------------------------------------------
00028 //----------------------------------------------------------------------
00029 #include <driver_svh/SVHSerialPacket.h>
00030 
00031 namespace driver_svh {
00032 
00033 icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, const SVHSerialPacket& data)
00034 {
00035   ab << data.index << data.address << static_cast<uint16_t>(data.data.size()) << data.data;
00036   return ab;
00037 }
00038 
00039 icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHSerialPacket& data)
00040 {
00041   // Disregard the size when deserializing as we get that anyway
00042   uint16_t size ;
00043    ab >> data.index >> data.address >> size >> data.data;
00044   return ab;
00045 }
00046 
00047 std::ostream& operator << (std::ostream& o, const SVHSerialPacket& sp)
00048 {
00049   o << "index: " << static_cast<int>(sp.index) << " address: " << "0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(sp.address) << " Data: ";
00050   for (size_t i = 0; i < sp.data.size(); i++)
00051   {
00052     o << "0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast<int>(sp.data[i]) << " ";
00053   }
00054   // Reset Output stream to decimal output .. otherwise it may confuse people and the stream operators have the tendency to hang on to these hints
00055   std::cout << std::dec ;
00056   return o;
00057 }
00058 
00059 }
00060 


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Thu Jun 6 2019 18:29:08