get_error.cpp
Go to the documentation of this file.
00001 
00060 #include <utility>
00061 #include <iostream>
00062 #include <iomanip>
00063 #include "ipa_canopen_core/canopen.h"
00064 #include <sstream>
00065 
00066 int main(int argc, char *argv[])
00067 {
00068 
00069     if (argc != 4) {
00070         std::cout << "Arguments:" << std::endl
00071         << "(1) device file" << std::endl
00072         << "(2) CAN deviceID" << std::endl
00073            << "(3) Baud Rate" << std::endl
00074         << "Example: ./get_error /dev/pcan32 12 500K" << std::endl;
00075         return -1;
00076     }
00077 
00078     canopen::NMTmsg.ID = 0;
00079     canopen::NMTmsg.MSGTYPE = 0x00;
00080     canopen::NMTmsg.LEN = 2;
00081 
00082     canopen::syncMsg.ID = 0x80;
00083     canopen::syncMsg.MSGTYPE = 0x00;
00084 
00085     canopen::syncMsg.LEN = 0x00;
00086 
00087     std::string deviceFile = std::string(argv[1]);
00088     canopen::baudRate = std::string(argv[3]);
00089 
00090     if (!canopen::openConnection(deviceFile, canopen::baudRate)){
00091         std::cout << "Cannot open CAN device; aborting." << std::endl;
00092 
00093         exit(EXIT_FAILURE);
00094     }
00095     else{
00096         std::cout << "Connection to CAN bus established" << std::endl;
00097         std::cout << "Baud Rate:" << canopen::baudRate << std::endl;
00098     }
00099 
00100     uint16_t CANid = std::stoi(std::string(argv[2]));
00101     canopen::syncInterval = std::chrono::milliseconds((100));
00102 
00103 
00104     canopen::devices[ CANid ] = canopen::Device(CANid);
00105     std::this_thread::sleep_for(std::chrono::milliseconds(100));
00106 
00107     std::string chainName = "test_chain";
00108     std::vector <uint8_t> ids;
00109     ids.push_back(CANid);
00110     std::vector <std::string> j_names;
00111     j_names.push_back("joint_1");
00112     canopen::deviceGroups[ chainName ] = canopen::DeviceGroup(ids, j_names);
00113 
00114     canopen::init(deviceFile,chainName, canopen::syncInterval);
00115 
00116     std::this_thread::sleep_for(std::chrono::milliseconds(100));
00117 
00118 
00119     std::shared_ptr<TPCANRdMsg> m;
00120 
00121     /***************************************************************/
00122     //          Manufacturer specific errors register
00123     /***************************************************************/
00124 
00125     std::vector<char> dev_name = canopen::devices[CANid].getManufacturerDevName();
00126 
00127     std::cout << dev_name[0] << std::endl;
00128 
00129 //    /**************************
00130 //     * Hardware and Software Information
00131 //    *************************/
00132 
00133 //    std::vector<uint16_t> vendor_id = canopen::obtainVendorID(CANid);
00134 //    uint16_t rev_number = canopen::obtainRevNr(CANid);
00135 //    std::vector<uint16_t> product_code = canopen::obtainProdCode(CANid);
00136 //    std::vector<char> manufacturer_device_name = canopen::obtainManDevName(CANid);
00137 //    std::vector<char> manufacturer_hw_version =  canopen::obtainManHWVersion(CANid);
00138 //    std::vector<char> manufacturer_sw_version =  canopen::obtainManSWVersion(CANid);
00139 
00140 //        /****
00141 //         *Printing the data
00142 //         */
00143 
00144 //        std::cout << "vendor_id=0x";
00145 
00146 //        for (auto it : vendor_id)
00147 //        {
00148 //           std::cout <<  std::hex << it;
00149 //        }
00150 
00151 //        std::cout << std::endl;
00152 
00153 //        std::cout << "revision_number: "<< std::hex << int(rev_number) << std::dec << std::endl;
00154 //        std::cout << "device_name:";
00155 
00156 //        for (auto it : manufacturer_device_name)
00157 //        {
00158 //           std::cout << it;
00159 //        }
00160 
00161 //        std::cout << std::endl;
00162 
00163 //        std::cout << "hardware_version:";
00164 
00165 //        for (auto it : manufacturer_hw_version)
00166 //        {
00167 //           std::cout << it;
00168 //        }
00169 
00170 //        std::cout << std::endl;
00171 
00172 //        std::cout << "software_version:";
00173 
00174 //        for (auto it : manufacturer_sw_version)
00175 //        {
00176 //           std::cout << it;
00177 //        }
00178 
00179 //        std::cout << std::endl;
00180 
00181 
00182 }


ipa_canopen_core
Author(s): Tobias Sing, Thiago de Freitas
autogenerated on Thu Aug 27 2015 13:32:20