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
00123
00124
00125 std::vector<char> dev_name = canopen::devices[CANid].getManufacturerDevName();
00126
00127 std::cout << dev_name[0] << std::endl;
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 }