ethercat_telegram.h
Go to the documentation of this file.
00001 // $Id: ethercat_telegram.h,v 1.28 2005/06/17 13:12:38 kgad Exp $
00002 //===========================================================================
00003 //      This file is part of "EtherCAT Master Library".
00004 //      Copyright (C) 2005 FMTC vzw, Diamant Building, A. Reyerslaan 80,
00005 //      B-1030 Brussels, Belgium.
00006 //
00007 //      EtherCAT Master Library is free software; you can redistribute it
00008 //      and/or modify it under the terms of the GNU General Public License
00009 //      as published by the Free Software Foundation; either version 2 or
00010 //      (at your option) any later version.
00011 //
00012 //      EtherCAT Master Code is distributed in the hope that it will be
00013 //      useful, but WITHOUT ANY WARRANTY; without even the implied
00014 //      warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015 //      PURPOSE. See the GNU General Public License for more details.
00016 //
00017 //      You should have received a copy of the GNU General Public License
00018 //      along with the EtherCAT Master Library; if not, write to the Free
00019 //      Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020 //      02111-1307 USA.
00021 //
00022 //      EtherCAT, the EtherCAT trade name and logo are the intellectual
00023 //      property of, and protected by Beckhoff. You can use "EtherCAT
00024 //      Master Library" for creating and/or selling or otherwise
00025 //      distributing an EtherCAT network master under the terms of the
00026 //      EtherCAT Master License.
00027 //
00028 //      You should have received a copy of the EtherCAT Master License
00029 //      along with the EtherCAT Master Library; if not, write to Beckhoff
00030 //      Automation GmbH, Eiserstrasse 5, D-33415 Verl, Germany.
00031 //===========================================================================
00032 
00033 #ifndef __ethercat_telegram_h__
00034 #define __ethercat_telegram_h__
00035 
00036 #include "ros_ethercat_eml/ethercat_defs.h"
00037 #include "ros_ethercat_eml/ethercat_datastruct.h"
00038 
00039 // Header size of telegram expressed as a number of bytes
00040 static const size_t ETHERCAT_TELEGRAM_HEADER_SIZE = 10;
00041 // Tail size of telegram expressed as a number of bytes
00042 static const size_t ETHERCAT_TELEGRAM_WKC_SIZE = 2;
00043 
00045 
00050 class EC_Telegram : public EC_DataStruct
00051 {
00052 public:
00053   // redefine pure virtual
00054   unsigned char * dump(unsigned char * a_buffer) const;
00056   const unsigned char * build(const unsigned char * a_buffer);
00057 
00059   void set_wkc(uint16_t a_wkc)
00060   {
00061     m_wkc = a_wkc;
00062   }
00064   void set_idx(uint8_t a_idx)
00065   {
00066     m_idx = a_idx;
00067   }
00069   uint16_t get_wkc(void) const
00070   {
00071     return m_wkc;
00072   }
00074   uint8_t get_idx(void) const
00075   {
00076     return m_idx;
00077   }
00079   const unsigned char * get_data(void) const
00080   {
00081     return m_data;
00082   }
00084   void set_data(const unsigned char * a_data)
00085   {
00086     m_data = a_data;
00087   }
00089   size_t get_datalen(void) const
00090   {
00091     return (length() -
00092             ETHERCAT_TELEGRAM_HEADER_SIZE -
00093             ETHERCAT_TELEGRAM_WKC_SIZE);
00094   }
00096   void set_datalen(size_t len)
00097   {
00098     m_data_length = len +
00099       ETHERCAT_TELEGRAM_HEADER_SIZE +
00100       ETHERCAT_TELEGRAM_WKC_SIZE;
00101   }
00102 
00104   void attach(EC_Telegram *a_telegram);
00105 
00107   EC_Telegram * next;
00109   EC_Telegram * previous;
00110 
00111 protected:
00112   EC_Telegram(size_t a_datasize = 0, const unsigned char * a_data = NULL);
00113   EC_Telegram(uint8_t a_idx, uint16_t a_wkc);
00114   EC_Telegram(size_t a_datasize, const unsigned char * a_data,
00115               uint8_t a_idx,
00116               uint16_t a_wkc);
00117 
00118   EC_Telegram(const EC_Telegram& a_telegram);
00119 
00121 
00124   virtual unsigned char * dump_header_head(unsigned char * a_buffer) const = 0;
00127 
00130   virtual const unsigned char * build_header_head(const unsigned char * a_buffer) = 0;
00131 
00132   virtual bool check_index(const unsigned char * buffer) const;
00133   virtual bool check_lennext(const unsigned char * buffer) const;
00134 
00135 protected:
00137   const unsigned char * m_data;
00138   // Length of data field
00139   //  size_t                  m_datalength;
00141   uint8_t m_idx;
00143   uint16_t m_wkc;
00145   static const uint16_t m_irq;
00146   virtual size_t header_length(void) const
00147   {
00148     return ETHERCAT_TELEGRAM_HEADER_SIZE;
00149   }
00150   virtual size_t tail_length(void) const
00151   {
00152     return ETHERCAT_TELEGRAM_WKC_SIZE;
00153   }
00154 
00155 private:
00156   virtual const unsigned char * build_body(const unsigned char * a_buffer);
00157 };
00158 
00159 #endif // __ethercat_telegram_h__


ros_ethercat_eml
Author(s): Tom Panis, Klaas Gadeyne, Bob Koninckx, Austin Hendrix, Manos Nikolaidis
autogenerated on Thu Jul 4 2019 20:01:49