3#include <QCommandLineParser>
4#include <QCommandLineOption>
19using namespace yarp::os;
52void printCanDevices(QList<sBoard> canBoards, QString onIPboard,
bool slimprint);
61int verifyOnSecondLevel(
FirmwareUpdaterCore *core,QString device,QString
id,
const QString &targetIPaddr,
const QString &targetCANline,
const QString &targetCANaddr,
const QString &targetFWvers);
64int verifyCanDevices(QList<sBoard> canBoards,
const QString &targetCANline,
const QString &targetCANaddr,
const QString &targetFWvers);
70int queryCanDevices(QList<sBoard> canBoards,
const QString onIPboard,
const QString &targetCANline,
const QString &targetCANaddr);
82int main(
int argc,
char *argv[])
85 QApplication a(argc, argv);
87 QApplication::setStyle(
"motif");
94 yDebug() <<
"The application is busy";
95 qDebug() <<
"The application is busy. Check if an instance is already running, or if it is in zombie state. If none of them ... remove the file .firmwareUpdater.singleton";
100 QCommandLineParser parser;
101 parser.addVersionOption();
102 parser.setApplicationDescription(
"Firmware Updater Help");
103 parser.addHelpOption();
105 QCommandLineOption noGuiOption(QStringList() <<
"g" <<
"nogui",
"The application starts in console mode");
106 QCommandLineOption strainCalibOption(QStringList() <<
"0" <<
"strain-acquisition",
"The application starts the STRAIN acquisition mode");
107 QCommandLineOption adminOption(QStringList() <<
"a" <<
"admin",
"The application starts in admin mode");
108 QCommandLineOption iniFileOption(QStringList() <<
"f" <<
"from",
"Override the default ini file",
"config",
"firmwareupdater.ini");
109 QCommandLineOption addressOption(QStringList() <<
"s" <<
"address",
"Override the default address",
"address",
DEFAULT_IP_ADDRESS);
110 QCommandLineOption portOption(QStringList() <<
"p" <<
"port",
"Override the default port",
"port",
"3333");
111 QCommandLineOption discoverOption(QStringList() <<
"d" <<
"discover",
"Discover devices");
112 QCommandLineOption deviceOption(QStringList() <<
"e" <<
"device",
"Choose Device (i.e. ETH or CFW2_CAN, ESD_CAN...)",
"device",
"");
113 QCommandLineOption idOption(QStringList() <<
"i" <<
"id",
"Choose a device id (i.e. eth1 or 1-2-3...)",
"id",
"");
114 QCommandLineOption boardOption(QStringList() <<
"t" <<
"eth_board",
"Choose a device board (i.e. 10.0.0.1)",
"eth_board",
"");
115 QCommandLineOption programOption(QStringList() <<
"r" <<
"program",
"Program devices");
116 QCommandLineOption fileOption(QStringList() <<
"l" <<
"file",
"Path to a firmware file",
"file",
"");
117 QCommandLineOption ethCanLineOption(QStringList() <<
"c" <<
"can_line",
"Select a can line",
"can_line",
"");
118 QCommandLineOption ethCanIdOption(QStringList() <<
"n" <<
"can_id",
"Select a can id",
"can_id",
"");
119 QCommandLineOption ethForceMaintenance(QStringList() <<
"m" <<
"force-eth-maintenance",
"Force the board to go in maintenace mode",
"");
120 QCommandLineOption ethForceApplication(QStringList() <<
"o" <<
"force-eth-application",
"Force the board to go in application mode",
"");
121 QCommandLineOption eraseEEpromOption(QStringList() <<
"1" <<
"erase_eeprom" <<
"Erase EEPROM of STRAIN during FW update",
"");
122 QCommandLineOption verbosityOption(QStringList() <<
"x" <<
"verbosity",
"Choose a verbosity level [0, 1]",
"verbosity",
"");
123 QCommandLineOption verifyOption(QStringList() <<
"y" <<
"verify",
"Verify FW version [ma.mi / ma.mi.re]. returns 0 if address and FW both match, 1 if board is found but FW does not match, 2 if board is not even found",
"verify",
"");
124 QCommandLineOption queryOption(QStringList() <<
"q" <<
"query",
"Queries a given address for its type and FW version [ma.mi / ma.mi.re]. prints a result on stdout. it returns 1 if it does not find a board at address");
125 QCommandLineOption loadDatFileOption(QStringList() <<
"z" <<
"load-dat-file",
"Loads the calibration .dat file into STRAIN2 eeprom (pass the file.dat with -l or --file option)",
"",
"");
126 QCommandLineOption setStrainSnOption(QStringList() <<
"w" <<
"set-strain-sn",
"Sets the passed serialNumber (i.e. SN001) on STRAIN2",
"sn",
"");
127 QCommandLineOption setStrainGainsOffsetOption(QStringList() <<
"j" <<
"set-strain-gains",
"Sets on STRAIN2 default gains to (8,24,24,10,10,24) , adjust the offset and check if some channel saturates",
"",
"");
128 QCommandLineOption setStrainGainsSpecificOffsetOption(QStringList() <<
"3" <<
"set-strain-gains-specific",
"Sets on STRAIN2 default gains to (8,24,24,10,10,24) or to (8,10,10,10,10,10) depending on the sensor type, adjust the offset and check if some channel saturates",
"xx",
"");
129 QCommandLineOption getCanBoardVersionOption(QStringList() <<
"b" <<
"get-canboard-version",
"Gets Bootloader or Application version (<saveFile> must be y or n to save or not a file containing fw info)",
"saveFile",
"");
130 QCommandLineOption saveDatFileOption(QStringList() <<
"u" <<
"save-dat-file",
"Saves the calibration .dat file from STRAIN2 eeprom",
"",
"");
131 QCommandLineOption changeCanIdOption(QStringList() <<
"k" <<
"change-can-id",
"changes CAN ID",
"id-new",
"");
132 QCommandLineOption changeBoardIpOption(QStringList() <<
"2" <<
"change-ip-addr",
"changes board IP address",
"ip-new",
"");
135 parser.addOption(noGuiOption);
136 parser.addOption(strainCalibOption);
137 parser.addOption(adminOption);
138 parser.addOption(iniFileOption);
139 parser.addOption(addressOption);
140 parser.addOption(portOption);
141 parser.addOption(discoverOption);
142 parser.addOption(deviceOption);
143 parser.addOption(idOption);
144 parser.addOption(boardOption);
145 parser.addOption(programOption);
146 parser.addOption(fileOption);
147 parser.addOption(ethCanLineOption);
148 parser.addOption(ethCanIdOption);
149 parser.addOption(ethForceMaintenance);
150 parser.addOption(ethForceApplication);
151 parser.addOption(eraseEEpromOption);
152 parser.addOption(verbosityOption);
153 parser.addOption(verifyOption);
154 parser.addOption(queryOption);
155 parser.addOption(loadDatFileOption);
156 parser.addOption(setStrainSnOption);
157 parser.addOption(setStrainGainsOffsetOption);
158 parser.addOption(setStrainGainsSpecificOffsetOption);
159 parser.addOption(getCanBoardVersionOption);
160 parser.addOption(saveDatFileOption);
161 parser.addOption(changeCanIdOption);
162 parser.addOption(changeBoardIpOption);
166 bool noGui = parser.isSet(noGuiOption);
167 bool adminMode = parser.isSet(adminOption);
169 QString iniFile = parser.value(iniFileOption);
171 bool bPrintUsage=
false;
174 if(parser.isSet(verbosityOption))
176 QString vv = parser.value(verbosityOption);
181 if(parser.isSet(addressOption)){
182 address = parser.value(addressOption);
187 if(parser.isSet(portOption)){
188 port = parser.value(portOption).toInt();
198 rf.setDefaultContext(
"firmwareUpdater");
199 rf.setDefaultConfigFile(iniFile.toLatin1().data());
201 if(!rf.configure(argc, argv)){
214 bool discover = parser.isSet(discoverOption);
215 bool program = parser.isSet(programOption);
216 bool verify = parser.isSet(verifyOption);
217 bool query = parser.isSet(queryOption);
218 QString device = parser.value(deviceOption);
219 QString
id = parser.value(idOption);
220 QString
board = parser.value(boardOption);
221 QString
file = parser.value(fileOption);
222 QString canLine = parser.value(ethCanLineOption);
223 QString canId = parser.value(ethCanIdOption);
224 QString sensorModel = parser.value(setStrainGainsSpecificOffsetOption);
226 if(parser.isSet(setStrainGainsSpecificOffsetOption)){
227 if(
verbosity >= 1) qDebug() <<
"Sensor model:" << sensorModel;
230 QString targetFW = parser.value(verifyOption);
232 bool forceMaintenance = parser.isSet(ethForceMaintenance);
233 bool forceApplication = parser.isSet(ethForceApplication);
234 bool eraseEEprom = parser.isSet(eraseEEpromOption);
235 bool loadDatFile = parser.isSet(loadDatFileOption);
236 bool saveDatFile = parser.isSet(saveDatFileOption);
237 bool setSn = parser.isSet(setStrainSnOption);
238 QString serialNumber = parser.value(setStrainSnOption);
239 bool setGains = parser.isSet(setStrainGainsOffsetOption);
240 bool setGainsSpecific = parser.isSet(setStrainGainsSpecificOffsetOption);
241 QString saveVersion = parser.value(getCanBoardVersionOption);
242 bool getVersion = parser.isSet(getCanBoardVersionOption);
243 bool changeCanID = parser.isSet(changeCanIdOption);
244 bool changeIp = parser.isSet(changeBoardIpOption);
247 QString canIdNew = parser.value(changeCanIdOption);
248 QString newIp = parser.value(changeBoardIpOption);
282 if(
verbosity >= 1) qDebug() <<
"specify at least one option amongst discover / verify / program / forcemaintenance / forceapplication";
290 if(
verbosity >= 1) qDebug() <<
"specify only one option amongst discover / verify / program / forcemaintenance / forceapplication";
299 if(device.isEmpty()){
300 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
301 }
else if(
id.isEmpty()){
302 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
321 if(
verbosity >= 1) qDebug() <<
"Need a device";
323 else if (device.contains(
"ETH"))
328 if(
verbosity >= 1) qDebug() <<
"Need an IP address";
330 else if((canLine.isEmpty()) && (canId.isEmpty()))
335 else if((!canLine.isEmpty()) && (!canId.isEmpty()))
343 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
349 if((canLine.isEmpty()) || (canId.isEmpty()))
351 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
371 if(
verbosity >= 1) qDebug() <<
"Need a device";
373 else if (device.contains(
"ETH"))
378 if(
verbosity >= 1) qDebug() <<
"Need an ip address";
380 else if(targetFW.isEmpty())
382 if(
verbosity >= 1) qDebug() <<
"Need a target fw version";
384 else if((canLine.isEmpty()) && (canId.isEmpty()))
389 else if((!canLine.isEmpty()) && (!canId.isEmpty()))
397 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
403 if(targetFW.isEmpty())
405 if(
verbosity >= 1) qDebug() <<
"Need a target fw version";
407 else if((canLine.isEmpty()) || (canId.isEmpty()))
409 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
426 if(device.isEmpty()){
427 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
428 }
else if(
id.isEmpty()){
429 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
430 }
else if(
board.isEmpty() && device.contains(
"ETH")){
431 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
432 }
else if(
file.isEmpty()){
433 if(
verbosity >= 1) qDebug() <<
"Need a file path to be set";
434 }
else if(canLine.isEmpty() && canId.isEmpty()){
440 if(canLine.isEmpty()){
441 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
442 }
else if(canId.isEmpty()){
443 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
456 if(device.isEmpty()){
457 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
458 }
else if(
id.isEmpty()){
459 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
460 }
else if(
board.isEmpty()){
461 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
474 if(device.isEmpty()){
475 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
476 }
else if(
id.isEmpty()){
477 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
478 }
else if(
board.isEmpty()){
479 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
491 if(device.isEmpty()){
492 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
493 }
else if(
id.isEmpty()){
494 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
495 }
else if(
file.isEmpty()){
496 if(
verbosity >= 1) qDebug() <<
"Need a file path to be set";
498 if(!device.contains(
"ETH") && canLine.isEmpty()){
499 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
500 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
501 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
513 if(device.isEmpty()){
514 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
515 }
else if(
id.isEmpty()){
516 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
518 if(!device.contains(
"ETH") && canLine.isEmpty()){
519 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
520 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
521 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
522 }
else if(!device.contains(
"ETH") && serialNumber.isEmpty()){
523 if(
verbosity >= 1) qDebug() <<
"Need a serial number to be set";
535 if(device.isEmpty()){
536 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
537 }
else if(
id.isEmpty()){
538 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
540 if(!device.contains(
"ETH") && canLine.isEmpty()){
541 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
542 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
543 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
555 if(device.isEmpty()){
556 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
557 }
else if(
id.isEmpty()){
558 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
560 if(!device.contains(
"ETH") && canLine.isEmpty()){
561 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
562 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
563 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
566 if(sensorModel==
"FT58")
583 if(device.isEmpty()){
584 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
585 }
else if(
id.isEmpty()){
586 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
588 if(!device.contains(
"ETH") && canLine.isEmpty()){
589 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
590 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
591 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
594 if(saveVersion ==
"y") save =
true;
606 if(device.isEmpty()){
607 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
608 }
else if(
id.isEmpty()){
609 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
611 if(!device.contains(
"ETH") && canLine.isEmpty()){
612 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
613 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
614 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
625 if(device.isEmpty()){
626 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
627 }
else if(
id.isEmpty()){
628 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
630 if(!device.contains(
"ETH") && canLine.isEmpty()){
631 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
632 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
633 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
644 if(device.isEmpty()){
645 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
646 }
else if(
id.isEmpty()){
647 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
649 if(!device.contains(
"ETH") ||
board.isEmpty() || newIp.isEmpty()){
650 if(
verbosity >= 1) qDebug() <<
"\nNeed a ETH device, the old IP and the new one to be set\n i.e.FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -2 10.0.1.2";
662 if(device.isEmpty()){
663 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
664 }
else if(
id.isEmpty()){
665 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
675 if(device.isEmpty()){
676 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
677 }
else if(
id.isEmpty()){
678 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
679 }
else if(
board.isEmpty() && device.contains(
"ETH")){
680 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
681 }
else if(
file.isEmpty()){
682 if(
verbosity >= 1) qDebug() <<
"Need a file path to be set";
683 }
else if(canLine.isEmpty() && canId.isEmpty()){
689 if(canLine.isEmpty()){
690 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
691 }
else if(canId.isEmpty()){
692 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
697 }
else if(forceApplication || forceMaintenance){
698 if(device.isEmpty()){
699 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
700 }
else if(
id.isEmpty()){
701 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
702 }
else if(
board.isEmpty()){
703 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
705 if(forceApplication){
722#ifdef UPDATER_RELEASE
738 actionResult = actionValue;
791 yError(
"ETH board is not present or not in maintenace mode!!\n");
797 for(
int i = 0 ; i< ethl.
size(); i++){
798 if(ethl[i].getIPV4string() ==
board.toStdString()) index = i;
802 if(ret) yInfo() <<
"Cahnge board IP Succeded !!!";
803 else yError() <<
"Cahnge board IP Failed !!!";
812 QList <sBoard> canBoards;
817 if(device.contains(
"SOCKETCAN"))
820 if (canId.toInt() <1 || canId.toInt() >= 15 || canIdNew.toInt() <1 || canIdNew.toInt() >= 15){
821 yError(
"Invalid board address!\n");
827 if(canBoards.count() > 0)
830 yInfo() <<
"Cahnge CAN ID message sent !!!";
833 yError() <<
"No CAN board found, stopped!";
837 else if(device.contains(
"ETH"))
843 yError(
"ETH board is not present or not in maintenace mode!!\n");
847 if(canBoards.count() > 0)
851 if(ret) yInfo() <<
"Cahnge CAN ID Succeded !!!";
852 else yError() <<
"Cahnge CAN ID Failed !!!";
855 yError() <<
"No CAN board found, stopped!";
865 QList <sBoard> canBoards;
869 if(device.contains(
"SOCKETCAN"))
871 if (canId.toInt() <1 || canId.toInt() >= 15){
872 yError(
"Invalid board address!\n");
880 else if(device.contains(
"ETH"))
885 yError(
"ETH board is not present or not in maintenace mode!!\n");
891 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
894 string prefix =
"Application ";
896 if(!canBoards[0].applicationisrunning && save)
899 myfile.open (
"firmware-info.txt", std::ios_base::app);
900 prefix =
" Bootloader ";
901 myfile << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor <<
"\n";
903 yInfo() << prefix <<
" version : " << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor;
905 catch (std::ifstream::failure
e) {
906 yError() <<
"Exception opening file";
909 }
else if(canBoards[0].applicationisrunning && save)
912 myfile.open (
"firmware-info.txt", std::ios_base::app);
913 prefix =
" Application ";
914 myfile << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor <<
"." << canBoards[0].appl_vers_build <<
"\n";
916 yInfo() << prefix <<
" version : " << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor <<
"." << canBoards[0].appl_vers_build;
918 catch (std::ifstream::failure
e) {
919 yError() <<
"Exception opening file";
925 yError() <<
"No CAN board found, stopped!";
940 QList <sBoard> canBoards;
944 std::vector<strain2_ampl_discretegain_t> gains(0);
945 std::vector<int16_t> targets(0);
947 std::vector<strain2_ampl_discretegain_t> ampsets = {
959 for(
int i = 0; i < 6; i++){ targets.push_back(0); gains.push_back(ampsets[i]);}
961 if(device.contains(
"SOCKETCAN"))
963 if (canId.toInt() <1 || canId.toInt() >= 15){
964 yError(
"Invalid board address!\n");
972 else if(device.contains(
"ETH"))
977 yError(
"ETH board is not present or not in maintenace mode!!\n");
983 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
987 yDebug() <<
"strain2-amplifier-tuning: STEP-1. imposing gains which are different of each channel";
990 static_cast<icubCanProto_boardType_t
>(canBoards[0].type),
991 gains, targets, &msg);
993 yarp::os::Time::delay(0.2);
995 yInfo() <<
"Gains Saved!";
998 yError() <<
"No STRAIN2 board found, stopped!";
1002 unsigned int adc[6];
1004 bool failCh =
false;
1006 for(
int i=0; i<6; i++){
1011 unsigned int z =
static_cast<int>(adc[i])-32768;
1012 sprintf(tempbuf,
"%d",
z);
1013 int t = std::stoi(tempbuf);
1014 if(t < -500 || t > 500) failCh =
true;
1015 yDebug() << i <<
" " << std::stoi(tempbuf);
1016 yarp::os::Time::delay(0.2);
1020 yError() <<
"Strange value on Channels ADC readings...";
1023 yInfo() <<
"Good values in ADC channels reading!";
1044 QList <sBoard> canBoards;
1048 QByteArray
string = serialNumber.toLatin1();
1049 char * sn =
string.data();
1051 if(device.contains(
"SOCKETCAN"))
1053 if (canId.toInt() <1 || canId.toInt() >= 15){
1054 yError(
"Invalid board address!\n");
1061 else if(device.contains(
"ETH"))
1063 QString result, ret;
1066 yError(
"ETH board is not present or not in maintenace mode!!\n");
1073 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1080 yInfo() <<
"Serial Number Saved!";
1084 yError() <<
"No STRAIN2 board found, stopped!";
1106 QList <sBoard> canBoards;
1113 unsigned int calib_matrix[3][6][6];
1115 unsigned int full_scale_const[3][6];
1120 yError(
"File not found!\n");
1125 if(device.contains(
"SOCKETCAN"))
1127 if (canId.toInt() <1 || canId.toInt() >= 15){
1128 yError(
"Invalid board address!\n");
1136 else if(device.contains(
"ETH"))
1138 QString result, ret;
1141 yError(
"ETH board is not present or not in maintenace mode!!\n");
1148 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1151 if(canBoards.count() > 0)
1153 int boardtype = canBoards[0].type;
1154 int regset = canBoards[0].strainregsetinuse;
1158 filestr.open (
file.toLatin1().data(), fstream::in);
1159 if (!filestr.is_open()){
1160 yError(
"Error opening calibration file!\n");
1168 filestr.getline (buffer,256);
1169 filestr.getline (buffer,256);
1170 sscanf (buffer,
"%d",&file_version);
1173 if( ( (icubCanProto_boardType__strain2 == boardtype) || (icubCanProto_boardType__strain2c == boardtype) ) && (3 != file_version))
1175 yError(
"Wrong file. Calibration version not supported for strain2: %d\n", file_version);
1178 else if((icubCanProto_boardType__strain == boardtype) && (2 != file_version))
1180 yError(
"Wrong file. Calibration version not supported: %d\n", file_version);
1184 if(3 == file_version)
1187 filestr.getline (buffer,256);
1188 filestr.getline (buffer,256);
1189 if(0 != strcmp(buffer,
"strain2"))
1191 yError(
"Wrong file. Board type not supported: %s\n", buffer);
1196 filestr.getline (buffer,256);
1197 filestr.getline (buffer,256);
1198 sprintf(sn,
"%s", buffer);
1203 filestr.getline (buffer,256);
1206 filestr.getline (buffer,256);
1208 unsigned int t08[6] = {0};
1209 sscanf (buffer,
"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", &t08[0], &t08[1], &t08[2], &t08[3], &t08[4], &t08[5]);
1210 for(
int j=0; j<6; j++) amp_registers[i].
data[j] = t08[j];
1226 filestr.getline (buffer,256);
1227 filestr.getline (buffer,256);
1228 sprintf(sn,
"%s", buffer);
1232 filestr.getline (buffer,256);
1235 filestr.getline (buffer,256);
1236 sscanf (buffer,
"%d",&
offset[i]);
1244 filestr.getline (buffer,256);
1245 for (i=0;i<36; i++){
1248 filestr.getline (buffer,256);
1249 sscanf (buffer,
"%x",&calib_matrix[index][ri][ci]);
1255 filestr.getline (buffer,256);
1256 filestr.getline (buffer,256);
1258 sscanf (buffer,
"%d",&cc);
1262 filestr.getline (buffer,256);
1264 filestr.getline (buffer,256);
1265 sscanf (buffer,
"%d",&calib_bias[i]);
1270 filestr.getline (buffer,256);
1272 filestr.getline (buffer,256);
1273 sscanf (buffer,
"%d",&full_scale_const[index][i]);
1281 yInfo() <<
"Calibration file loaded!";
1285 yError() <<
"No STRAIN2 board found, stopped!";
1306 QList <sBoard> canBoards;
1313 uint16_t amp_offsets[6];
1314 unsigned int full_scale_const[3][6];
1315 unsigned int matrix[3][6][6];
1316 unsigned int calib_const[3];
1327 char path[256] = { 0 };
1328 std::string filename;
1334 if(device.contains(
"SOCKETCAN"))
1336 if (canId.toInt() <1 || canId.toInt() >= 15){
1337 yError(
"Invalid board address!\n");
1344 else if(device.contains(
"ETH"))
1346 QString result, ret;
1349 yError(
"ETH board is not present or not in maintenace mode!!\n");
1356 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1360 filename +=
"calibrationData";
1361 filename += serial_no;
1364 filestr.open (filename.c_str(), fstream::out);
1366 for(
int i=0; i<6; i++)
1373 for(
int mi=0;mi<1;mi++){
1383 if(icubCanProto_boardType__strain2 == canBoards[0].type || icubCanProto_boardType__strain2c == canBoards[0].type)
1386 filestr<<
"File version:"<<endl;
1389 filestr<<
"Board type:"<<endl;
1390 filestr<<
"strain2"<<endl;
1392 filestr<<
"Serial number:"<<endl;
1393 sprintf (buffer,
"%s",serial_no);
1394 filestr<<buffer<<endl;
1396 filestr<<
"Amplifier registers:"<<endl;
1398 sprintf (buffer,
"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
1399 amp_registers[i].
data[0], amp_registers[i].
data[1], amp_registers[i].
data[2],
1400 amp_registers[i].
data[3], amp_registers[i].
data[4], amp_registers[i].
data[5]);
1401 filestr<<buffer<<endl;
1407 filestr<<
"File version:"<<endl;
1411 filestr<<
"Serial number:"<<endl;
1412 sprintf (buffer,
"%s",serial_no);
1413 filestr<<buffer<<endl;
1416 filestr<<
"Offsets:"<<endl;
1418 sprintf (buffer,
"%d",
offset[i]);
1419 filestr<<buffer<<endl;
1426 filestr<<
"Calibration matrix:"<<endl;
1427 for (i=0;i<36; i++){
1428 sprintf (buffer,
"%x",matrix[index][i/6][i%6]);
1429 filestr<<buffer<<endl;
1434 filestr<<
"Matrix gain:"<<endl;
1435 sprintf (buffer,
"%d",calib_const[index]);
1436 filestr<<buffer<<endl;
1440 filestr<<
"Tare:"<<endl;
1442 sprintf (buffer,
"%d",calib_bias[i]);
1443 filestr<<buffer<<endl;
1447 filestr<<
"Full scale values:"<<endl;
1449 sprintf (buffer,
"%d",full_scale_const[index][i]);
1450 filestr<<buffer<<endl;
1453 yInfo() <<
"Calibration file saved!";
1456 yError() <<
"No STRAIN2 board found, stopped!";
1465 int boards = core->
connectTo(device,
id);
1467 if(device.contains(
"ETH")){
1477 int boards = core->
connectTo(device,
id);
1479 if(device.contains(
"ETH")){
1492 if(device.contains(
"ETH")){
1493 int boards = core->
connectTo(device,
id);
1495 char board_ipaddr[16];
1498 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s", ethBoard.
getIPV4string().c_str());
1500 if(
board.contains(board_ipaddr)){
1503 if(canBoards.count() > 0){
1504 int selectedCount = 0;
1505 for(
int j=0;j<canBoards.count();j++){
1506 sBoard b = canBoards.at(j);
1507 if(b.
bus == canLine.toInt() && b.
pid == canId.toInt()){
1510 canBoards.replace(j,b);
1515 if(selectedCount > 0){
1518 if(
verbosity >= 1) qDebug() << retString;
1519 return ret ? 0 : -1;
1521 if(
verbosity >= 1) qDebug() <<
"No board selected";
1525 if(
verbosity >= 1) qDebug() << retString;
1535 if(canBoards.count() > 0){
1536 int selectedCount = 0;
1537 for(
int j=0;j<canBoards.count();j++){
1538 sBoard b = canBoards.at(j);
1539 if(b.
bus == canLine.toInt() && b.
pid == canId.toInt()){
1542 canBoards.replace(j,b);
1546 if(selectedCount > 0){
1549 if(
verbosity >= 1) qDebug() << retString;
1550 return ret ? 0 : -1;
1552 if(
verbosity >= 1) qDebug() <<
"No board selected";
1556 if(
verbosity >= 1) qDebug() << retString;
1566 int boards = core->
connectTo(device,
id);
1568 if(device.contains(
"ETH")){
1569 char board_ipaddr[16];
1572 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s", ethBoard.
getIPV4string().c_str());
1574 if(
board.contains(board_ipaddr)){
1576 QString resultString;
1579 if(
verbosity >= 1) qDebug() << resultString;
1582 if(
verbosity >= 1) qDebug() <<
"Update Done";
1591 if(
verbosity >= 1) qDebug() <<
"No boards found";
1599 if(device.contains(
"ETH")){
1600 int boards = core->
connectTo(device,
id);
1603 char board_ipaddr[16];
1606 char board_version[16];
1607 char board_date[24];
1608 char board_built[24];
1609 char board_type[24];
1610 char running_process[24];
1611 char board_info[32];
1612 char appl_version[32] = {0};
1614 memset(board_ipaddr,0,
sizeof(board_ipaddr));
1615 memset(board_mac,0,
sizeof(board_mac));
1616 memset(board_version,0,
sizeof(board_version));
1617 memset(board_date,0,
sizeof(board_date));
1618 memset(board_built,0,
sizeof(board_built));
1619 memset(board_type,0,
sizeof(board_type));
1620 memset(running_process,0,
sizeof(running_process));
1621 memset(board_info,0,
sizeof(board_info));
1624 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1628 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s",
board.getIPV4string().c_str());
1630 ACE_UINT64 mac =
board.getInfo().macaddress;
1632 snprintf(board_mac,
sizeof(board_mac),
"%02X-%02X-%02X-%02X-%02X-%02X",
1633 (uint8_t)(mac >> 40) & 0xff,
1634 (uint8_t)(mac >> 32) & 0xff,
1635 (uint8_t)(mac >> 24) & 0xff,
1636 (uint8_t)(mac >> 16) & 0xff,
1637 (uint8_t)(mac >> 8 ) & 0xff,
1638 (uint8_t)(mac ) & 0xff
1642 snprintf(board_version,
sizeof(board_version),
"%s",
board.getVersionfRunning().c_str());
1643 snprintf(board_type,
sizeof(board_type),
"%s", eoboards_type2string2(eoboards_ethtype2type(
board.getInfo().boardtype), eobool_true));
1644 snprintf(running_process,
sizeof(running_process),
"%s", eouprot_process2string((eOuprot_process_t)
board.getInfo().processes.runningnow));
1645 snprintf(board_info,
sizeof(board_info),
"%s",
board.getInfoOnEEPROM().c_str());
1646 snprintf(board_date,
sizeof(board_date),
"%s",
board.getDatefRunning().c_str());
1647 snprintf(board_built,
sizeof(board_date),
"%s",
board.getCompilationDateOfRunning().c_str());
1648 snprintf(appl_version,
sizeof(appl_version),
"%d.%d",
board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor);
1650 if(
true == slimprint)
1652 char IPslimstring[512] = {0};
1653 snprintf(IPslimstring,
sizeof(IPslimstring),
"%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
1654 board.getIPV4string().c_str(),
1655 eoboards_type2string2(eoboards_ethtype2type(
board.getInfo().boardtype), eobool_true),
1656 board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor,
1657 board.getInfo().processes.info[1].version.major,
board.getInfo().processes.info[1].version.minor,
1658 board.getInfo().processes.info[0].version.major,
board.getInfo().processes.info[0].version.minor);
1660 qDebug() << IPslimstring;
1664 if(
verbosity >= 1) qDebug() <<
"************** Device " << i <<
" ******************";
1665 if(
verbosity >= 1) qDebug() <<
"Ip: "<< board_ipaddr;
1666 if(
verbosity >= 1) qDebug() <<
"Mac: "<< board_mac;
1667 if(
verbosity >= 1) qDebug() <<
"Version: "<< board_version;
1668 if(
verbosity >= 1) qDebug() <<
"Appl Ver: "<< appl_version;
1669 if(
verbosity >= 1) qDebug() <<
"Type: "<< board_type;
1670 if(
verbosity >= 1) qDebug() <<
"Process: "<< running_process;
1671 if(
verbosity >= 1) qDebug() <<
"Info: "<< board_info;
1672 if(
verbosity >= 1) qDebug() <<
"Date: "<< board_date;
1673 if(
verbosity >= 1) qDebug() <<
"Built: "<< board_built;
1678 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1684 if(canBoards.count() <= 0){
1685 if(
verbosity >= 1) qDebug() << retString;
1704 int boards = core->
connectTo(device,
id);
1706 if(device.contains(
"ETH")){
1707 if(forceMaintenance){
1710 }
else if(forceApplication){
1717 if(canBoards.count() <= 0){
1718 if(
verbosity >= 1) qDebug() << retString;
1724 if(
verbosity >= 1) qDebug() <<
"for board" <<
board <<
"You have to put the device in maintenace mode to perform this operation.";
1729 if(
verbosity >= 1) qDebug() <<
"No boards Found";
1737 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1738 for(
int i=0;i<canBoards.count();i++){
1741 char board_type [50]; memset (board_type, 0,
sizeof(board_type));
1742 char board_process [50]; memset (board_process, 0,
sizeof(board_process));
1743 char board_status [50]; memset (board_status, 0,
sizeof(board_status));
1744 char board_add_info [50]; memset (board_add_info, 0,
sizeof(board_add_info));
1745 char board_firmware_version [32]; memset (board_firmware_version, 0,
sizeof(board_firmware_version));
1746 char board_appl_minor [10]; memset (board_appl_minor, 0,
sizeof(board_appl_minor));
1747 char board_appl_build [10]; memset (board_appl_build, 0,
sizeof(board_appl_build));
1748 char board_serial [50]; memset (board_serial, 0,
sizeof(board_serial));
1749 char board_protocol [10]; memset (board_protocol, 0,
sizeof(board_protocol));
1751 snprintf(board_type,
sizeof(board_type),
"%s", eoboards_type2string2((eObrd_type_t)
board.type, eobool_true));
1753 switch (
board.status)
1756 strcpy(board_status,
"RUNNING");
1759 strcpy(board_status,
"WAITING");
1762 strcpy(board_status,
"WAITING_ACK");
1765 strcpy(board_status,
"DOWNLOADING");
1768 strcpy(board_status,
"OK");
1771 strcpy(board_status,
"ERR");
1774 strcpy(board_status,
"UNKNOWN");
1778 if(
true ==
board.applicationisrunning){
1779 strcpy(board_process,
"canApplication");
1781 strcpy(board_process,
"canBootloader");
1784 strncpy (board_add_info,
board.add_info,32);
1786 if(-1 ==
board.appl_vers_build){
1787 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d",
board.appl_vers_major,
board.appl_vers_minor);
1789 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d.%d",
board.appl_vers_major,
board.appl_vers_minor,
board.appl_vers_build);
1792 snprintf (board_appl_minor,
sizeof(board_appl_minor),
"%d",
board.appl_vers_minor);
1793 snprintf (board_appl_build,
sizeof(board_appl_build),
"%d",
board.appl_vers_build);
1794 snprintf (board_serial,
sizeof(board_serial),
"%s",
board.serial);
1796 if((0 ==
board.prot_vers_major) && (0 ==
board.prot_vers_minor))
1798 snprintf (board_protocol,
sizeof(board_protocol),
"N/A");
1802 snprintf (board_protocol,
sizeof(board_protocol),
"%d.%d",
board.prot_vers_major,
board.prot_vers_minor);
1805 if(
true == slimprint)
1807 char CANslimstring[512] = {0};
1808 char IPstr[24] = {0};
1809 if(
false == onIPboard.isEmpty())
1811 snprintf(IPstr,
sizeof(IPstr),
"%s:", onIPboard.toStdString().c_str());
1813 snprintf(CANslimstring,
sizeof(CANslimstring),
"%sCAN%d:%d: type = %s, application = %s",
1817 eoboards_type2string2((eObrd_type_t)
board.type, eobool_true),
1818 board_firmware_version);
1820 qDebug() << CANslimstring;
1824 if(
verbosity >= 1) qDebug() <<
"************** Board " << i <<
" ******************";
1825 if(
verbosity >= 1) qDebug() <<
"Type: " << board_type;
1827 if(
verbosity >= 1) qDebug() <<
"Address: " <<
"CAN_" <<
board.bus;
1828 if(
verbosity >= 1) qDebug() <<
"Process: " << board_process;
1829 if(
verbosity >= 1) qDebug() <<
"Status: " << board_status;
1830 if(
verbosity >= 1) qDebug() <<
"Info: " << board_add_info;
1831 if(
verbosity >= 1) qDebug() <<
"Firmware Version: " << board_firmware_version;
1832 if(
verbosity >= 1) qDebug() <<
"Serial: " << board_serial;
1833 if(
verbosity >= 1) qDebug() <<
"Protocol: " << board_protocol;
1837 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1844 tempFile = QDir::homePath() +
"/firmwareUpdater.singleton";
1846 tempFile = QDir::homePath() +
"/.firmwareUpdater.singleton";
1849 QFileInfo fInfo(tempFile);
1855 f.open(QIODevice::WriteOnly);
1861 LPCSTR a = (
const char*)fInfo.filePath().utf16();
1862 BOOL b = SetFileAttributes(a,FILE_ATTRIBUTE_HIDDEN);
1874 tempFile = QDir::homePath() +
"/firmwareUpdater.singleton";
1876 tempFile = QDir::homePath() +
"/.firmwareUpdater.singleton";
1879 QFileInfo fInfo(tempFile);
1880 if(!fInfo.exists()){
1893 if(device.contains(
"ETH"))
1895 int boards = core->
connectTo(device,
id);
1899 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1906 if(targetIPaddr.toStdString() ==
board.getIPV4string())
1910 char board_ipaddr[16] = {0};
1911 char appl_version[32] = {0};
1913 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s",
board.getIPV4string().c_str());
1914 snprintf(appl_version,
sizeof(appl_version),
"%d.%d",
board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor);
1916 if(targetFWvers == appl_version)
1919 if(
verbosity >= 1) qDebug() <<
"MATCHED";
1924 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED";
1937 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (IP = " << targetIPaddr <<
" not in found boards)";
1939 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1945 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (found no board)";
1952 if(canBoards.count() <= 0)
1955 if(
verbosity >= 1) qDebug() << retString;
1959 ret =
verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
1973 int boards = core->
connectTo(device,
id);
1977 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1984 if(targetIPaddr.toStdString() ==
board.getIPV4string())
1989 char board_ipaddr[16] = {0};
1990 char appl_version[32] = {0};
1992 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s",
board.getIPV4string().c_str());
1993 snprintf(appl_version,
sizeof(appl_version),
"%d.%d",
board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor);
1995 if(targetFWvers == appl_version)
1998 if(
verbosity >= 1) qDebug() <<
"ETH FOUND + FW MATCHED";
2003 if(
verbosity >= 1) qDebug() <<
"ETH FOUND + FW NOT MATCHED";
2016 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (IP = " << targetIPaddr <<
" not in found boards)";
2018 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2024 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (found no board)";
2052 if(canBoards.count() <= 0)
2055 if(
verbosity >= 1) qDebug() << retString;
2059 ret =
verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2066int verifyCanDevices(QList<sBoard> canBoards,
const QString &targetCANline,
const QString &targetCANaddr,
const QString &targetFWvers)
2072 for(
int i=0;i<canBoards.count();i++)
2076 if(
verbosity >= 1) qDebug() <<
"---------------------------------------------------------";
2080 snprintf(line,
sizeof(line),
"%d",
board.bus);
2082 snprintf(addr,
sizeof(addr),
"%d",
board.pid);
2087 if((targetCANline.toStdString() ==
string(line)) && (targetCANaddr.toStdString() ==
string(addr)) )
2092 if(
verbosity >= 1) qDebug() <<
"CAN ADDRESS: FOUND";
2096 if(
true ==
board.applicationisrunning)
2098 char board_firmware_version [32] = {0};
2099 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d.%d",
board.appl_vers_major,
board.appl_vers_minor,
board.appl_vers_build);
2102 if(
string(board_firmware_version) == targetFWvers.toStdString())
2105 if(
verbosity >= 1) qDebug() <<
"CAN FW VERSION: MATCHES";
2113 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2123 const bool forceMaintenance =
true;
2125 int boards = core->
connectTo(device,
id);
2129 if(device.contains(
"ETH"))
2131 if(forceMaintenance)
2141 if(canBoards.count() <= 0)
2143 if(
verbosity >= 1) qDebug() << retString;
2147 ret =
verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2153 if(
verbosity >= 1) qDebug() <<
"You have to put the device in maintenace mode to perform this operation.";
2160 if(
verbosity >= 1) qDebug() <<
"No boards Found";
2171 const bool slimprint =
true;
2175 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2177 int boards = core->
connectTo(device,
id);
2184 if(targetIPaddr.toStdString() ==
board.getIPV4string())
2189 if(
true == slimprint)
2191 char IPslimstring[512] = {0};
2192 snprintf(IPslimstring,
sizeof(IPslimstring),
"%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
2193 board.getIPV4string().c_str(),
2194 eoboards_type2string2(eoboards_ethtype2type(
board.getInfo().boardtype), eobool_true),
2195 board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor,
2196 board.getInfo().processes.info[1].version.major,
board.getInfo().processes.info[1].version.minor,
2197 board.getInfo().processes.info[0].version.major,
board.getInfo().processes.info[0].version.minor);
2199 qDebug() << IPslimstring;
2214 char notfound[512] = {0};
2215 snprintf(notfound,
sizeof(notfound),
"%s: not found",
2216 targetIPaddr.toStdString().c_str());
2218 qDebug() << notfound;
2220 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2231 const bool forceMaintenance =
true;
2233 char notfound[256] = {0};
2235 int boards = core->
connectTo(device,
id);
2239 if(device.contains(
"ETH"))
2241 if(forceMaintenance)
2251 if(canBoards.count() <= 0)
2253 if(
verbosity >= 1) qDebug() << retString;
2254 snprintf(notfound,
sizeof(notfound),
"%s: no can board beneath",
board.toStdString().c_str());
2255 qDebug() << notfound;
2265 if(
verbosity >= 1) qDebug() <<
"You have to put the device in maintenace mode to perform this operation.";
2272 if(
verbosity >= 1) qDebug() <<
"No boards Found";
2273 snprintf(notfound,
sizeof(notfound),
"%s: cannot find it",
board.toStdString().c_str());
2274 qDebug() << notfound;
2281int queryCanDevices(QList<sBoard> canBoards,
const QString onIPboard,
const QString &targetCANline,
const QString &targetCANaddr)
2286 const bool slimprint =
true;
2288 for(
int i=0;i<canBoards.count();i++)
2292 if(
verbosity >= 1) qDebug() <<
"---------------------------------------------------------";
2296 snprintf(line,
sizeof(line),
"%d",
board.bus);
2298 snprintf(addr,
sizeof(addr),
"%d",
board.pid);
2301 if((targetCANline.toStdString() ==
string(line)) && (targetCANaddr.toStdString() ==
string(addr)) )
2306 char board_firmware_version[32] = {0};
2308 if(
true ==
board.applicationisrunning)
2310 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d.%d",
board.appl_vers_major,
board.appl_vers_minor,
board.appl_vers_build);
2314 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d",
board.appl_vers_major,
board.appl_vers_minor);
2317 if(
true == slimprint)
2319 char CANslimstring[512] = {0};
2320 char IPstr[24] = {0};
2321 if(
false == onIPboard.isEmpty())
2323 snprintf(IPstr,
sizeof(IPstr),
"%s:", onIPboard.toStdString().c_str());
2325 snprintf(CANslimstring,
sizeof(CANslimstring),
"%sCAN%d:%d: type = %s, application = %s",
2328 eoboards_type2string2((eObrd_type_t)
board.type, eobool_true),
2329 board_firmware_version);
2331 qDebug() << CANslimstring;
2341 char notfound[512] = {0};
2342 char IPstr[24] = {0};
2343 if(
false == onIPboard.isEmpty())
2345 snprintf(IPstr,
sizeof(IPstr),
"%s:", onIPboard.toStdString().c_str());
2347 snprintf(notfound,
sizeof(notfound),
"%sCAN%s:%s: not found",
2349 targetCANline.toStdString().c_str(), targetCANaddr.toStdString().c_str());
2351 qDebug() << notfound;
2354 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2364 char notfound[256] = {0};
2368 if(canBoards.count() <= 0)
2371 if(
verbosity >= 1) qDebug() << retString;
2372 snprintf(notfound,
sizeof(notfound),
"<%s>: no can boards beneath", device.toStdString().c_str());
2373 qDebug() << notfound;
QList< sBoard > getCanBoardsFromDriver(QString driver, int networkId, QString *retString, bool force=false)
int connectTo(QString device, QString id)
void setSelectedCanBoards(QList< sBoard > selectedBoards, QString address, int deviceId=-1)
bool setEthBoardAddress(int index, QString newAddress)
bool uploadCanApplication(QString filename, QString *resultString, bool ee, QString address="", int deviceId=-1, QList< sBoard > *resultCanBoards=NULL)
QList< sBoard > getCanBoardsFromEth(QString address, QString *retString, int canID=CanPacket::everyCANbus, bool force=false)
void setSelectedEthBoard(int index, bool selected)
EthBoardList getEthBoardList()
bool isBoardInMaintenanceMode(QString ip)
bool setCanBoardAddress(int bus, int id, int canType, QString newAddress, QString ethAddress="", int deviceId=-1, QString *resultString=NULL)
bool uploadEthApplication(QString filename, QString *resultString)
bool init(Searchable &config, int port, QString address, int VerbositY)
cDownloader * getDownloader()
bool setVerbosity(int verb)
int strain_get_serial_number(int bus, int target_id, char *serial_number, string *errorstring=NULL)
int strain_set_matrix_gain(int bus, int target_id, unsigned int gain, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_get_offset(int bus, int target_id, char channel, unsigned int &offset, int regset=strain_regset_inuse, string *errorstring=NULL)
int change_card_address(int bus, int target_id, int new_id, int board_type)
int strain_get_full_scale(int bus, int target_id, unsigned char channel, unsigned int &full_scale, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_offset(int bus, int target_id, char channel, unsigned int offset, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_serial_number(int bus, int target_id, const char *serial_number, string *errorstring=NULL)
int strain_save_to_eeprom(int bus, int target_id, string *errorstring=NULL)
int strain_get_adc(int bus, int target_id, char channel, unsigned int &adc, int type, string *errorstring=NULL)
int get_serial_no(int bus, int target_id, char *board_info)
int strain_get_matrix_rc(int bus, int target_id, char r, char c, unsigned int &elem, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_full_scale(int bus, int target_id, unsigned char channel, unsigned int full_scale, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_calib_bias(int bus, int target_id, string *errorstring=NULL)
int strain_get_amplifier_regs(int bus, int target_id, unsigned char channel, strain2_ampl_regs_t &regs, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_get_amplifier_gain_offset(int bus, int target_id, unsigned char channel, float &gain, uint16_t &offset, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_matrix_rc(int bus, int target_id, char r, char c, unsigned int elem, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_amplifier_regs(int bus, int target_id, unsigned char channel, const strain2_ampl_regs_t &regs, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_calibrate_offset2(int bus, int target_id, icubCanProto_boardType_t boardtype, const std::vector< strain2_ampl_discretegain_t > &gains, const std::vector< int16_t > &targets, string *errorstring=NULL)
void drv_sleep(double time)
#define BOARD_WAITING_ACK
#define BOARD_DOWNLOADING
#define DEFAULT_IP_ADDRESS
int changeCanId(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, QString canIdNew)
int verifyOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
int queryOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr)
void checkForAction(bool &actionIsValid, action_t const &actionValue, action_t &actionResult)
void printCanDevices(QList< sBoard > canBoards, QString onIPboard, bool slimprint)
int programCanDevice(FirmwareUpdaterCore *, QString device, QString id, QString board, QString canLine, QString canId, QString file, bool eraseEEprom)
int verifyCanDevices(QList< sBoard > canBoards, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
int getCanBoardVersion(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, bool save)
int printSecondLevelDevices(FirmwareUpdaterCore *, QString device, QString id, bool slimprint)
int changeBoardIp(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString newipaddr)
int printThirdLevelDevices(FirmwareUpdaterCore *, QString device, QString id, QString board, bool forceMaintenance, bool forceApplication, bool slimprint)
int setBoardToApplication(FirmwareUpdaterCore *core, QString device, QString id, QString board)
int verifyOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, QString board, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
void removeApplicationLock()
int saveDatFileStrain2(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, bool eraseEEprom)
bool checkApplicationLock()
int setStrainSn(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, QString serialNumber)
int setBoardToMaintenance(FirmwareUpdaterCore *core, QString device, QString id, QString board)
int queryOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, const QString board, const QString &targetCANline, const QString &targetCANaddr)
int verifyOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetFWvers)
int verifyOnSecondLevel(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
int queryCanDevices(QList< sBoard > canBoards, const QString onIPboard, const QString &targetCANline, const QString &targetCANaddr)
int loadDatFileStrain2(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, QString file, bool eraseEEprom)
int programEthDevice(FirmwareUpdaterCore *, QString device, QString id, QString board, QString file)
@ action_setstrainft45gainsoffsets
@ action_forceapplication
@ action_setstraingainsspecificoffsets
@ action_setstrainft58gainsoffsets
@ action_setstraingainsoffsets
@ action_forcemaintenance
@ action_getcanboardversion
int queryOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr)
int setStrainGainsOffsets(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, SensorModel model)
Copyright (C) 2008 RobotCub Consortium.