wg014.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2008, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #include <ethercat_hardware/wg014.h>
00036 #include <iomanip>
00037 
00038 #include <ros/console.h>
00039 
00040 PLUGINLIB_DECLARE_CLASS(ethercat_hardware, 6805014, WG014, EthercatDevice);
00041 
00042 void WG014::construct(EtherCAT_SlaveHandler *sh, int &start_address)
00043 {
00044   EthercatDevice::construct(sh, start_address);
00045   sh->set_fmmu_config( new EtherCAT_FMMU_Config(0) );
00046   sh->set_pd_config( new EtherCAT_PD_Config(0) );
00047 
00048   fw_major_ = (sh->get_revision() >> 8) & 0xff;
00049   fw_minor_ = sh->get_revision() & 0xff;
00050   board_major_ = ((sh->get_revision() >> 24) & 0xff) - 1;
00051   board_minor_ = (sh->get_revision() >> 16) & 0xff;
00052 }
00053 
00054 WG014::~WG014()
00055 {
00056   delete sh_->get_fmmu_config();
00057   delete sh_->get_pd_config();
00058 }
00059 
00060 int WG014::initialize(pr2_hardware_interface::HardwareInterface *, bool)
00061 {
00062   ROS_DEBUG("Device #%02d: WG014 (%#08x)", sh_->get_ring_position(), sh_->get_product_code());
00063   return 0;
00064 }
00065 
00066 void WG014::diagnostics(diagnostic_updater::DiagnosticStatusWrapper &d, unsigned char *)
00067 {
00068   stringstream str;
00069   str << "EtherCAT Device #" << setw(2) << setfill('0') << sh_->get_ring_position() << " (WG014)";
00070   d.name = str.str();
00071   d.summary(0, "OK");
00072   char serial[32];
00073   snprintf(serial, sizeof(serial), "%d-%05d-%05d", sh_->get_product_code()/ 100000 , sh_->get_product_code() % 100000, sh_->get_serial());
00074   d.hardware_id = serial;
00075 
00076   d.clear();
00077   d.addf("Product code", "WG014 (%d), Ports %s, PCB Revision %c.%02d",
00078          sh_->get_product_code(), 
00079          ((fw_minor_==1) ? "J1-J3" : // WG014 has two ET1100 devices...
00080           (fw_minor_==2) ? "J4-J6" : // One ET1100 handles port J1 to J3. The other, J4 to J6.
00081           "J?-J?"),                  // The firmware minor revision deferentiates the two.
00082          'A' + board_major_, board_minor_);
00083   d.addf("Serial Number", "%s", serial);
00084 
00085   EthercatDevice::ethercatDiagnostics(d, 4); // WG014 has 4 ports
00086 }


ethercat_hardware
Author(s): Rob Wheeler (email: wheeler@willowgarage.com), Maintained by Derek King (email: dking@willowgarage.com)
autogenerated on Thu Apr 24 2014 15:43:45