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",
"");
133 QCommandLineOption boardAddressesOption(QStringList() <<
"A" <<
"addresses",
"List of board addresses (e.g., 'CAN1:1 CAN2:1')",
"addresses_list");
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);
163 parser.addOption(boardAddressesOption);
167 std::vector<std::pair<int, int>> boardAddresses;
169 if (parser.isSet(boardAddressesOption)) {
170 qDebug() <<
"boardAddressesOption is set!";
171 QString addressesValue = parser.value(boardAddressesOption);
172 qDebug() <<
"Value from --addresses:" << addressesValue;
173 QStringList addressList = addressesValue.split(QRegularExpression(
"[ ,]"), Qt::SkipEmptyParts);
174 qDebug() <<
"Split address list size:" << addressList.size();
176 for (
const QString& arg : addressList) {
177 qDebug() <<
" Processing arg:" << arg;
178 if (arg.startsWith(
"CAN", Qt::CaseInsensitive)) {
179 QStringList parts = arg.split(
":");
180 if (parts.size() == 2) {
181 bool ok_bus, ok_addr;
182 int bus = parts[0].mid(3).toInt(&ok_bus);
183 int addr = parts[1].toInt(&ok_addr);
184 if (ok_bus && ok_addr) {
185 boardAddresses.push_back({bus, addr});
186 qDebug() <<
" -> Parsed and added: bus" << bus <<
"addr" << addr;
188 qDebug() <<
" -> FAILED to parse bus/addr to int.";
191 qDebug() <<
" -> FAILED: split on ':' did not produce 2 parts.";
194 qDebug() <<
" -> FAILED: does not start with 'CAN'.";
197 qDebug() <<
"Final boardAddresses vector size:" << boardAddresses.size();
201 bool noGui = parser.isSet(noGuiOption);
202 bool adminMode = parser.isSet(adminOption);
204 QString iniFile = parser.value(iniFileOption);
206 bool bPrintUsage=
false;
209 if(parser.isSet(verbosityOption))
211 QString vv = parser.value(verbosityOption);
216 if(parser.isSet(addressOption)){
217 address = parser.value(addressOption);
222 if(parser.isSet(portOption)){
223 port = parser.value(portOption).toInt();
233 rf.setDefaultContext(
"firmwareUpdater");
234 rf.setDefaultConfigFile(iniFile.toLatin1().data());
236 if(!rf.configure(argc, argv)){
249 bool discover = parser.isSet(discoverOption);
250 bool program = parser.isSet(programOption);
251 bool verify = parser.isSet(verifyOption);
252 bool query = parser.isSet(queryOption);
253 QString device = parser.value(deviceOption);
254 QString
id = parser.value(idOption);
255 QString
board = parser.value(boardOption);
256 QString
file = parser.value(fileOption);
257 QString canLine = parser.value(ethCanLineOption);
258 QString canId = parser.value(ethCanIdOption);
259 QString sensorModel = parser.value(setStrainGainsSpecificOffsetOption);
261 if(parser.isSet(setStrainGainsSpecificOffsetOption)){
262 if(
verbosity >= 1) qDebug() <<
"Sensor model:" << sensorModel;
265 QString targetFW = parser.value(verifyOption);
267 bool forceMaintenance = parser.isSet(ethForceMaintenance);
268 bool forceApplication = parser.isSet(ethForceApplication);
269 bool eraseEEprom = parser.isSet(eraseEEpromOption);
270 bool loadDatFile = parser.isSet(loadDatFileOption);
271 bool saveDatFile = parser.isSet(saveDatFileOption);
272 bool setSn = parser.isSet(setStrainSnOption);
273 QString serialNumber = parser.value(setStrainSnOption);
274 bool setGains = parser.isSet(setStrainGainsOffsetOption);
275 bool setGainsSpecific = parser.isSet(setStrainGainsSpecificOffsetOption);
276 QString saveVersion = parser.value(getCanBoardVersionOption);
277 bool getVersion = parser.isSet(getCanBoardVersionOption);
278 bool changeCanID = parser.isSet(changeCanIdOption);
279 bool changeIp = parser.isSet(changeBoardIpOption);
282 QString canIdNew = parser.value(changeCanIdOption);
283 QString newIp = parser.value(changeBoardIpOption);
317 if(
verbosity >= 1) qDebug() <<
"specify at least one option amongst discover / verify / program / forcemaintenance / forceapplication";
325 if(
verbosity >= 1) qDebug() <<
"specify only one option amongst discover / verify / program / forcemaintenance / forceapplication";
334 if(device.isEmpty()){
335 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
336 }
else if(
id.isEmpty()){
337 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
356 if(
verbosity >= 1) qDebug() <<
"Need a device";
358 else if (device.contains(
"ETH"))
363 if(
verbosity >= 1) qDebug() <<
"Need an IP address";
365 else if((canLine.isEmpty()) && (canId.isEmpty()))
370 else if((!canLine.isEmpty()) && (!canId.isEmpty()))
378 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
384 if((canLine.isEmpty()) || (canId.isEmpty()))
386 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
406 if(
verbosity >= 1) qDebug() <<
"Need a device";
408 else if (device.contains(
"ETH"))
413 if(
verbosity >= 1) qDebug() <<
"Need an ip address";
415 else if(targetFW.isEmpty())
417 if(
verbosity >= 1) qDebug() <<
"Need a target fw version";
419 else if((canLine.isEmpty()) && (canId.isEmpty()))
424 else if((!canLine.isEmpty()) && (!canId.isEmpty()))
432 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
438 if(targetFW.isEmpty())
440 if(
verbosity >= 1) qDebug() <<
"Need a target fw version";
442 else if((canLine.isEmpty()) || (canId.isEmpty()))
444 if(
verbosity >= 1) qDebug() <<
"Must have both can line and address";
459 if(device.isEmpty()){
460 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
461 }
else if(
id.isEmpty()){
462 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
463 }
else if(
board.isEmpty() && device.contains(
"ETH")){
464 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
465 }
else if(
file.isEmpty()){
466 if(
verbosity >= 1) qDebug() <<
"Need a file path to be set";
469 else if (!boardAddresses.empty()) {
471 qDebug() <<
"Multi-board programming requested for addresses:" << boardAddresses.size();
474 for (
const auto& b : canBoards) {
475 qDebug() <<
"Discovered CAN board bus:" << b.bus <<
"pid:" << b.pid;
477 qDebug() <<
"Discovered CAN boards:" << canBoards.size();
481 if (selectedBoards.size() == 0) {
482 qDebug() <<
"ERROR: No CAN boards selected for programming. Aborting.";
486 for (
const auto& b : selectedBoards) {
487 qDebug() <<
"CAN board bus:" << b.bus <<
"pid:" << b.pid <<
"selected:" << b.selected;
489 QString resultString;
490 QList<sBoard> resultCanBoards;
492 if (
verbosity >= 1) qDebug() << resultString;
496 else if(canLine.isEmpty() && canId.isEmpty()){
511 if(device.isEmpty()){
512 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
513 }
else if(
id.isEmpty()){
514 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
515 }
else if(
board.isEmpty()){
516 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
529 if(device.isEmpty()){
530 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
531 }
else if(
id.isEmpty()){
532 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
533 }
else if(
board.isEmpty()){
534 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
546 if(device.isEmpty()){
547 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
548 }
else if(
id.isEmpty()){
549 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
550 }
else if(
file.isEmpty()){
551 if(
verbosity >= 1) qDebug() <<
"Need a file path to be set";
553 if(!device.contains(
"ETH") && canLine.isEmpty()){
554 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
555 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
556 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
568 if(device.isEmpty()){
569 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
570 }
else if(
id.isEmpty()){
571 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
573 if(!device.contains(
"ETH") && canLine.isEmpty()){
574 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
575 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
576 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
577 }
else if(!device.contains(
"ETH") && serialNumber.isEmpty()){
578 if(
verbosity >= 1) qDebug() <<
"Need a serial number to be set";
590 if(device.isEmpty()){
591 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
592 }
else if(
id.isEmpty()){
593 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
595 if(!device.contains(
"ETH") && canLine.isEmpty()){
596 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
597 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
598 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
610 if(device.isEmpty()){
611 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
612 }
else if(
id.isEmpty()){
613 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
615 if(!device.contains(
"ETH") && canLine.isEmpty()){
616 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
617 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
618 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
621 if(sensorModel==
"FT58")
638 if(device.isEmpty()){
639 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
640 }
else if(
id.isEmpty()){
641 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
643 if(!device.contains(
"ETH") && canLine.isEmpty()){
644 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
645 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
646 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
649 if(saveVersion ==
"y") save =
true;
661 if(device.isEmpty()){
662 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
663 }
else if(
id.isEmpty()){
664 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
666 if(!device.contains(
"ETH") && canLine.isEmpty()){
667 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
668 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
669 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
680 if(device.isEmpty()){
681 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
682 }
else if(
id.isEmpty()){
683 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
685 if(!device.contains(
"ETH") && canLine.isEmpty()){
686 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
687 }
else if(!device.contains(
"ETH") && canId.isEmpty()){
688 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
699 if(device.isEmpty()){
700 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
701 }
else if(
id.isEmpty()){
702 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
704 if(!device.contains(
"ETH") ||
board.isEmpty() || newIp.isEmpty()){
705 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";
717 if(device.isEmpty()){
718 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
719 }
else if(
id.isEmpty()){
720 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
730 if(device.isEmpty()){
731 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
732 }
else if(
id.isEmpty()){
733 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
734 }
else if(
board.isEmpty() && device.contains(
"ETH")){
735 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
736 }
else if(
file.isEmpty()){
737 if(
verbosity >= 1) qDebug() <<
"Need a file path to be set";
738 }
else if(canLine.isEmpty() && canId.isEmpty()){
744 if(canLine.isEmpty()){
745 if(
verbosity >= 1) qDebug() <<
"Need a can line to be set";
746 }
else if(canId.isEmpty()){
747 if(
verbosity >= 1) qDebug() <<
"Need a can id to be set";
752 }
else if(forceApplication || forceMaintenance){
753 if(device.isEmpty()){
754 if(
verbosity >= 1) qDebug() <<
"Need a device to be set";
755 }
else if(
id.isEmpty()){
756 if(
verbosity >= 1) qDebug() <<
"Need an id to be set";
757 }
else if(
board.isEmpty()){
758 if(
verbosity >= 1) qDebug() <<
"Need a board to be set";
760 if(forceApplication){
777#ifdef UPDATER_RELEASE
793 actionResult = actionValue;
846 yError(
"ETH board is not present or not in maintenace mode!!\n");
852 for(
int i = 0 ; i< ethl.
size(); i++){
853 if(ethl[i].getIPV4string() ==
board.toStdString()) index = i;
857 if(ret) yInfo() <<
"Cahnge board IP Succeded !!!";
858 else yError() <<
"Cahnge board IP Failed !!!";
867 QList <sBoard> canBoards;
872 if(device.contains(
"SOCKETCAN"))
875 if (canId.toInt() <1 || canId.toInt() >= 15 || canIdNew.toInt() <1 || canIdNew.toInt() >= 15){
876 yError(
"Invalid board address!\n");
882 if(canBoards.count() > 0)
885 yInfo() <<
"Cahnge CAN ID message sent !!!";
888 yError() <<
"No CAN board found, stopped!";
892 else if(device.contains(
"ETH"))
898 yError(
"ETH board is not present or not in maintenace mode!!\n");
902 if(canBoards.count() > 0)
906 if(ret) yInfo() <<
"Cahnge CAN ID Succeded !!!";
907 else yError() <<
"Cahnge CAN ID Failed !!!";
910 yError() <<
"No CAN board found, stopped!";
920 QList <sBoard> canBoards;
924 if(device.contains(
"SOCKETCAN"))
926 if (canId.toInt() <1 || canId.toInt() >= 15){
927 yError(
"Invalid board address!\n");
935 else if(device.contains(
"ETH"))
940 yError(
"ETH board is not present or not in maintenace mode!!\n");
946 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
949 string prefix =
"Application ";
951 if(!canBoards[0].applicationisrunning && save)
954 myfile.open (
"firmware-info.txt", std::ios_base::app);
955 prefix =
" Bootloader ";
956 myfile << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor <<
"\n";
958 yInfo() << prefix <<
" version : " << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor;
960 catch (std::ifstream::failure
e) {
961 yError() <<
"Exception opening file";
964 }
else if(canBoards[0].applicationisrunning && save)
967 myfile.open (
"firmware-info.txt", std::ios_base::app);
968 prefix =
" Application ";
969 myfile << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor <<
"." << canBoards[0].appl_vers_build <<
"\n";
971 yInfo() << prefix <<
" version : " << canBoards[0].appl_vers_major <<
"." << canBoards[0].appl_vers_minor <<
"." << canBoards[0].appl_vers_build;
973 catch (std::ifstream::failure
e) {
974 yError() <<
"Exception opening file";
980 yError() <<
"No CAN board found, stopped!";
995 QList <sBoard> canBoards;
999 std::vector<strain2_ampl_discretegain_t> gains(0);
1000 std::vector<int16_t> targets(0);
1002 std::vector<strain2_ampl_discretegain_t> ampsets = {
1014 for(
int i = 0; i < 6; i++){ targets.push_back(0); gains.push_back(ampsets[i]);}
1016 if(device.contains(
"SOCKETCAN"))
1018 if (canId.toInt() <1 || canId.toInt() >= 15){
1019 yError(
"Invalid board address!\n");
1027 else if(device.contains(
"ETH"))
1029 QString result, ret;
1032 yError(
"ETH board is not present or not in maintenace mode!!\n");
1038 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1042 yDebug() <<
"strain2-amplifier-tuning: STEP-1. imposing gains which are different of each channel";
1045 static_cast<icubCanProto_boardType_t
>(canBoards[0].type),
1046 gains, targets, &msg);
1048 yarp::os::Time::delay(0.2);
1050 yInfo() <<
"Gains Saved!";
1053 yError() <<
"No STRAIN2 board found, stopped!";
1057 unsigned int adc[6];
1059 bool failCh =
false;
1061 for(
int i=0; i<6; i++){
1066 unsigned int z =
static_cast<int>(adc[i])-32768;
1067 sprintf(tempbuf,
"%d",
z);
1068 int t = std::stoi(tempbuf);
1069 if(t < -500 || t > 500) failCh =
true;
1070 yDebug() << i <<
" " << std::stoi(tempbuf);
1071 yarp::os::Time::delay(0.2);
1075 yError() <<
"Strange value on Channels ADC readings...";
1078 yInfo() <<
"Good values in ADC channels reading!";
1099 QList <sBoard> canBoards;
1103 QByteArray
string = serialNumber.toLatin1();
1104 char * sn =
string.data();
1106 if(device.contains(
"SOCKETCAN"))
1108 if (canId.toInt() <1 || canId.toInt() >= 15){
1109 yError(
"Invalid board address!\n");
1116 else if(device.contains(
"ETH"))
1118 QString result, ret;
1121 yError(
"ETH board is not present or not in maintenace mode!!\n");
1128 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1135 yInfo() <<
"Serial Number Saved!";
1139 yError() <<
"No STRAIN2 board found, stopped!";
1161 QList <sBoard> canBoards;
1168 unsigned int calib_matrix[3][6][6];
1170 unsigned int full_scale_const[3][6];
1175 yError(
"File not found!\n");
1180 if(device.contains(
"SOCKETCAN"))
1182 if (canId.toInt() <1 || canId.toInt() >= 15){
1183 yError(
"Invalid board address!\n");
1191 else if(device.contains(
"ETH"))
1193 QString result, ret;
1196 yError(
"ETH board is not present or not in maintenace mode!!\n");
1203 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1206 if(canBoards.count() > 0)
1208 int boardtype = canBoards[0].type;
1209 int regset = canBoards[0].strainregsetinuse;
1213 filestr.open (
file.toLatin1().data(), fstream::in);
1214 if (!filestr.is_open()){
1215 yError(
"Error opening calibration file!\n");
1223 filestr.getline (buffer,256);
1224 filestr.getline (buffer,256);
1225 sscanf (buffer,
"%d",&file_version);
1228 if( ( (icubCanProto_boardType__strain2 == boardtype) || (icubCanProto_boardType__strain2c == boardtype) ) && (3 != file_version))
1230 yError(
"Wrong file. Calibration version not supported for strain2: %d\n", file_version);
1233 else if((icubCanProto_boardType__strain == boardtype) && (2 != file_version))
1235 yError(
"Wrong file. Calibration version not supported: %d\n", file_version);
1239 if(3 == file_version)
1242 filestr.getline (buffer,256);
1243 filestr.getline (buffer,256);
1244 if(0 != strcmp(buffer,
"strain2"))
1246 yError(
"Wrong file. Board type not supported: %s\n", buffer);
1251 filestr.getline (buffer,256);
1252 filestr.getline (buffer,256);
1253 sprintf(sn,
"%s", buffer);
1258 filestr.getline (buffer,256);
1261 filestr.getline (buffer,256);
1263 unsigned int t08[6] = {0};
1264 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]);
1265 for(
int j=0; j<6; j++) amp_registers[i].
data[j] = t08[j];
1281 filestr.getline (buffer,256);
1282 filestr.getline (buffer,256);
1283 sprintf(sn,
"%s", buffer);
1287 filestr.getline (buffer,256);
1290 filestr.getline (buffer,256);
1291 sscanf (buffer,
"%d",&
offset[i]);
1299 filestr.getline (buffer,256);
1300 for (i=0;i<36; i++){
1303 filestr.getline (buffer,256);
1304 sscanf (buffer,
"%x",&calib_matrix[index][ri][ci]);
1310 filestr.getline (buffer,256);
1311 filestr.getline (buffer,256);
1313 sscanf (buffer,
"%d",&cc);
1317 filestr.getline (buffer,256);
1319 filestr.getline (buffer,256);
1320 sscanf (buffer,
"%d",&calib_bias[i]);
1325 filestr.getline (buffer,256);
1327 filestr.getline (buffer,256);
1328 sscanf (buffer,
"%d",&full_scale_const[index][i]);
1336 yInfo() <<
"Calibration file loaded!";
1340 yError() <<
"No STRAIN2 board found, stopped!";
1361 QList <sBoard> canBoards;
1368 uint16_t amp_offsets[6];
1369 unsigned int full_scale_const[3][6];
1370 unsigned int matrix[3][6][6];
1371 unsigned int calib_const[3];
1382 char path[256] = { 0 };
1383 std::string filename;
1389 if(device.contains(
"SOCKETCAN"))
1391 if (canId.toInt() <1 || canId.toInt() >= 15){
1392 yError(
"Invalid board address!\n");
1399 else if(device.contains(
"ETH"))
1401 QString result, ret;
1404 yError(
"ETH board is not present or not in maintenace mode!!\n");
1411 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1415 filename +=
"calibrationData";
1416 filename += serial_no;
1419 filestr.open (filename.c_str(), fstream::out);
1421 for(
int i=0; i<6; i++)
1428 for(
int mi=0;mi<1;mi++){
1438 if(icubCanProto_boardType__strain2 == canBoards[0].type || icubCanProto_boardType__strain2c == canBoards[0].type)
1441 filestr<<
"File version:"<<endl;
1444 filestr<<
"Board type:"<<endl;
1445 filestr<<
"strain2"<<endl;
1447 filestr<<
"Serial number:"<<endl;
1448 sprintf (buffer,
"%s",serial_no);
1449 filestr<<buffer<<endl;
1451 filestr<<
"Amplifier registers:"<<endl;
1453 sprintf (buffer,
"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x",
1454 amp_registers[i].
data[0], amp_registers[i].
data[1], amp_registers[i].
data[2],
1455 amp_registers[i].
data[3], amp_registers[i].
data[4], amp_registers[i].
data[5]);
1456 filestr<<buffer<<endl;
1462 filestr<<
"File version:"<<endl;
1466 filestr<<
"Serial number:"<<endl;
1467 sprintf (buffer,
"%s",serial_no);
1468 filestr<<buffer<<endl;
1471 filestr<<
"Offsets:"<<endl;
1473 sprintf (buffer,
"%d",
offset[i]);
1474 filestr<<buffer<<endl;
1481 filestr<<
"Calibration matrix:"<<endl;
1482 for (i=0;i<36; i++){
1483 sprintf (buffer,
"%x",matrix[index][i/6][i%6]);
1484 filestr<<buffer<<endl;
1489 filestr<<
"Matrix gain:"<<endl;
1490 sprintf (buffer,
"%d",calib_const[index]);
1491 filestr<<buffer<<endl;
1495 filestr<<
"Tare:"<<endl;
1497 sprintf (buffer,
"%d",calib_bias[i]);
1498 filestr<<buffer<<endl;
1502 filestr<<
"Full scale values:"<<endl;
1504 sprintf (buffer,
"%d",full_scale_const[index][i]);
1505 filestr<<buffer<<endl;
1508 yInfo() <<
"Calibration file saved!";
1511 yError() <<
"No STRAIN2 board found, stopped!";
1520 int boards = core->
connectTo(device,
id);
1522 if(device.contains(
"ETH")){
1532 int boards = core->
connectTo(device,
id);
1534 if(device.contains(
"ETH")){
1547 if(device.contains(
"ETH")){
1548 int boards = core->
connectTo(device,
id);
1550 char board_ipaddr[16];
1553 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s", ethBoard.
getIPV4string().c_str());
1555 if(
board.contains(board_ipaddr)){
1558 if(canBoards.count() > 0){
1559 int selectedCount = 0;
1560 for(
int j=0;j<canBoards.count();j++){
1561 sBoard b = canBoards.at(j);
1562 if(b.
bus == canLine.toInt() && b.
pid == canId.toInt()){
1565 canBoards.replace(j,b);
1570 if(selectedCount > 0){
1573 if(
verbosity >= 1) qDebug() << retString;
1574 return ret ? 0 : -1;
1576 if(
verbosity >= 1) qDebug() <<
"No board selected";
1580 if(
verbosity >= 1) qDebug() << retString;
1590 if(canBoards.count() > 0){
1591 int selectedCount = 0;
1592 for(
int j=0;j<canBoards.count();j++){
1593 sBoard b = canBoards.at(j);
1594 if(b.
bus == canLine.toInt() && b.
pid == canId.toInt()){
1597 canBoards.replace(j,b);
1601 if(selectedCount > 0){
1604 if(
verbosity >= 1) qDebug() << retString;
1605 return ret ? 0 : -1;
1607 if(
verbosity >= 1) qDebug() <<
"No board selected";
1611 if(
verbosity >= 1) qDebug() << retString;
1621 int boards = core->
connectTo(device,
id);
1623 if(device.contains(
"ETH")){
1624 char board_ipaddr[16];
1627 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s", ethBoard.
getIPV4string().c_str());
1629 if(
board.contains(board_ipaddr)){
1631 QString resultString;
1634 if(
verbosity >= 1) qDebug() << resultString;
1637 if(
verbosity >= 1) qDebug() <<
"Update Done";
1646 if(
verbosity >= 1) qDebug() <<
"No boards found";
1654 if(device.contains(
"ETH")){
1655 int boards = core->
connectTo(device,
id);
1658 char board_ipaddr[16];
1661 char board_version[16];
1662 char board_date[24];
1663 char board_built[24];
1664 char board_type[24];
1665 char running_process[24];
1666 char board_info[32];
1667 char appl_version[32] = {0};
1669 memset(board_ipaddr,0,
sizeof(board_ipaddr));
1670 memset(board_mac,0,
sizeof(board_mac));
1671 memset(board_version,0,
sizeof(board_version));
1672 memset(board_date,0,
sizeof(board_date));
1673 memset(board_built,0,
sizeof(board_built));
1674 memset(board_type,0,
sizeof(board_type));
1675 memset(running_process,0,
sizeof(running_process));
1676 memset(board_info,0,
sizeof(board_info));
1679 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1683 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s",
board.getIPV4string().c_str());
1685 ACE_UINT64 mac =
board.getInfo().macaddress;
1687 snprintf(board_mac,
sizeof(board_mac),
"%02X-%02X-%02X-%02X-%02X-%02X",
1688 (uint8_t)(mac >> 40) & 0xff,
1689 (uint8_t)(mac >> 32) & 0xff,
1690 (uint8_t)(mac >> 24) & 0xff,
1691 (uint8_t)(mac >> 16) & 0xff,
1692 (uint8_t)(mac >> 8 ) & 0xff,
1693 (uint8_t)(mac ) & 0xff
1697 snprintf(board_version,
sizeof(board_version),
"%s",
board.getVersionfRunning().c_str());
1698 snprintf(board_type,
sizeof(board_type),
"%s", eoboards_type2string2(eoboards_ethtype2type(
board.getInfo().boardtype), eobool_true));
1699 snprintf(running_process,
sizeof(running_process),
"%s", eouprot_process2string((eOuprot_process_t)
board.getInfo().processes.runningnow));
1700 snprintf(board_info,
sizeof(board_info),
"%s",
board.getInfoOnEEPROM().c_str());
1701 snprintf(board_date,
sizeof(board_date),
"%s",
board.getDatefRunning().c_str());
1702 snprintf(board_built,
sizeof(board_date),
"%s",
board.getCompilationDateOfRunning().c_str());
1703 snprintf(appl_version,
sizeof(appl_version),
"%d.%d",
board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor);
1705 if(
true == slimprint)
1707 char IPslimstring[512] = {0};
1708 snprintf(IPslimstring,
sizeof(IPslimstring),
"%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
1709 board.getIPV4string().c_str(),
1710 eoboards_type2string2(eoboards_ethtype2type(
board.getInfo().boardtype), eobool_true),
1711 board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor,
1712 board.getInfo().processes.info[1].version.major,
board.getInfo().processes.info[1].version.minor,
1713 board.getInfo().processes.info[0].version.major,
board.getInfo().processes.info[0].version.minor);
1715 qDebug() << IPslimstring;
1719 if(
verbosity >= 1) qDebug() <<
"************** Device " << i <<
" ******************";
1720 if(
verbosity >= 1) qDebug() <<
"Ip: "<< board_ipaddr;
1721 if(
verbosity >= 1) qDebug() <<
"Mac: "<< board_mac;
1722 if(
verbosity >= 1) qDebug() <<
"Version: "<< board_version;
1723 if(
verbosity >= 1) qDebug() <<
"Appl Ver: "<< appl_version;
1724 if(
verbosity >= 1) qDebug() <<
"Type: "<< board_type;
1725 if(
verbosity >= 1) qDebug() <<
"Process: "<< running_process;
1726 if(
verbosity >= 1) qDebug() <<
"Info: "<< board_info;
1727 if(
verbosity >= 1) qDebug() <<
"Date: "<< board_date;
1728 if(
verbosity >= 1) qDebug() <<
"Built: "<< board_built;
1733 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1739 if(canBoards.count() <= 0){
1740 if(
verbosity >= 1) qDebug() << retString;
1759 int boards = core->
connectTo(device,
id);
1761 if(device.contains(
"ETH")){
1762 if(forceMaintenance){
1765 }
else if(forceApplication){
1772 if(canBoards.count() <= 0){
1773 if(
verbosity >= 1) qDebug() << retString;
1779 if(
verbosity >= 1) qDebug() <<
"for board" <<
board <<
"You have to put the device in maintenace mode to perform this operation.";
1784 if(
verbosity >= 1) qDebug() <<
"No boards Found";
1792 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1793 for(
int i=0;i<canBoards.count();i++){
1796 char board_type [50]; memset (board_type, 0,
sizeof(board_type));
1797 char board_process [50]; memset (board_process, 0,
sizeof(board_process));
1798 char board_status [50]; memset (board_status, 0,
sizeof(board_status));
1799 char board_add_info [50]; memset (board_add_info, 0,
sizeof(board_add_info));
1800 char board_firmware_version [32]; memset (board_firmware_version, 0,
sizeof(board_firmware_version));
1801 char board_appl_minor [10]; memset (board_appl_minor, 0,
sizeof(board_appl_minor));
1802 char board_appl_build [10]; memset (board_appl_build, 0,
sizeof(board_appl_build));
1803 char board_serial [50]; memset (board_serial, 0,
sizeof(board_serial));
1804 char board_protocol [10]; memset (board_protocol, 0,
sizeof(board_protocol));
1806 snprintf(board_type,
sizeof(board_type),
"%s", eoboards_type2string2((eObrd_type_t)
board.type, eobool_true));
1808 switch (
board.status)
1811 strcpy(board_status,
"RUNNING");
1814 strcpy(board_status,
"WAITING");
1817 strcpy(board_status,
"WAITING_ACK");
1820 strcpy(board_status,
"DOWNLOADING");
1823 strcpy(board_status,
"OK");
1826 strcpy(board_status,
"ERR");
1829 strcpy(board_status,
"UNKNOWN");
1833 if(
true ==
board.applicationisrunning){
1834 strcpy(board_process,
"canApplication");
1836 strcpy(board_process,
"canBootloader");
1839 strncpy (board_add_info,
board.add_info,32);
1841 if(-1 ==
board.appl_vers_build){
1842 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d",
board.appl_vers_major,
board.appl_vers_minor);
1844 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d.%d",
board.appl_vers_major,
board.appl_vers_minor,
board.appl_vers_build);
1847 snprintf (board_appl_minor,
sizeof(board_appl_minor),
"%d",
board.appl_vers_minor);
1848 snprintf (board_appl_build,
sizeof(board_appl_build),
"%d",
board.appl_vers_build);
1849 snprintf (board_serial,
sizeof(board_serial),
"%s",
board.serial);
1851 if((0 ==
board.prot_vers_major) && (0 ==
board.prot_vers_minor))
1853 snprintf (board_protocol,
sizeof(board_protocol),
"N/A");
1857 snprintf (board_protocol,
sizeof(board_protocol),
"%d.%d",
board.prot_vers_major,
board.prot_vers_minor);
1860 if(
true == slimprint)
1862 char CANslimstring[512] = {0};
1863 char IPstr[24] = {0};
1864 if(
false == onIPboard.isEmpty())
1866 snprintf(IPstr,
sizeof(IPstr),
"%s:", onIPboard.toStdString().c_str());
1868 snprintf(CANslimstring,
sizeof(CANslimstring),
"%sCAN%d:%d: type = %s, application = %s",
1872 eoboards_type2string2((eObrd_type_t)
board.type, eobool_true),
1873 board_firmware_version);
1875 qDebug() << CANslimstring;
1879 if(
verbosity >= 1) qDebug() <<
"************** Board " << i <<
" ******************";
1880 if(
verbosity >= 1) qDebug() <<
"Type: " << board_type;
1882 if(
verbosity >= 1) qDebug() <<
"Address: " <<
"CAN_" <<
board.bus;
1883 if(
verbosity >= 1) qDebug() <<
"Process: " << board_process;
1884 if(
verbosity >= 1) qDebug() <<
"Status: " << board_status;
1885 if(
verbosity >= 1) qDebug() <<
"Info: " << board_add_info;
1886 if(
verbosity >= 1) qDebug() <<
"Firmware Version: " << board_firmware_version;
1887 if(
verbosity >= 1) qDebug() <<
"Serial: " << board_serial;
1888 if(
verbosity >= 1) qDebug() <<
"Protocol: " << board_protocol;
1892 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1899 tempFile = QDir::homePath() +
"/firmwareUpdater.singleton";
1901 tempFile = QDir::homePath() +
"/.firmwareUpdater.singleton";
1904 QFileInfo fInfo(tempFile);
1910 f.open(QIODevice::WriteOnly);
1916 LPCSTR a = (
const char*)fInfo.filePath().utf16();
1917 BOOL b = SetFileAttributes(a,FILE_ATTRIBUTE_HIDDEN);
1929 tempFile = QDir::homePath() +
"/firmwareUpdater.singleton";
1931 tempFile = QDir::homePath() +
"/.firmwareUpdater.singleton";
1934 QFileInfo fInfo(tempFile);
1935 if(!fInfo.exists()){
1948 if(device.contains(
"ETH"))
1950 int boards = core->
connectTo(device,
id);
1954 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
1961 if(targetIPaddr.toStdString() ==
board.getIPV4string())
1965 char board_ipaddr[16] = {0};
1966 char appl_version[32] = {0};
1968 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s",
board.getIPV4string().c_str());
1969 snprintf(appl_version,
sizeof(appl_version),
"%d.%d",
board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor);
1971 if(targetFWvers == appl_version)
1974 if(
verbosity >= 1) qDebug() <<
"MATCHED";
1979 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED";
1992 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (IP = " << targetIPaddr <<
" not in found boards)";
1994 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2000 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (found no board)";
2007 if(canBoards.count() <= 0)
2010 if(
verbosity >= 1) qDebug() << retString;
2014 ret =
verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2028 int boards = core->
connectTo(device,
id);
2032 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2039 if(targetIPaddr.toStdString() ==
board.getIPV4string())
2044 char board_ipaddr[16] = {0};
2045 char appl_version[32] = {0};
2047 snprintf(board_ipaddr,
sizeof(board_ipaddr),
"%s",
board.getIPV4string().c_str());
2048 snprintf(appl_version,
sizeof(appl_version),
"%d.%d",
board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor);
2050 if(targetFWvers == appl_version)
2053 if(
verbosity >= 1) qDebug() <<
"ETH FOUND + FW MATCHED";
2058 if(
verbosity >= 1) qDebug() <<
"ETH FOUND + FW NOT MATCHED";
2071 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (IP = " << targetIPaddr <<
" not in found boards)";
2073 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2079 if(
verbosity >= 1) qDebug() <<
"NOT MATCHED (found no board)";
2107 if(canBoards.count() <= 0)
2110 if(
verbosity >= 1) qDebug() << retString;
2114 ret =
verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2121int verifyCanDevices(QList<sBoard> canBoards,
const QString &targetCANline,
const QString &targetCANaddr,
const QString &targetFWvers)
2127 for(
int i=0;i<canBoards.count();i++)
2131 if(
verbosity >= 1) qDebug() <<
"---------------------------------------------------------";
2135 snprintf(line,
sizeof(line),
"%d",
board.bus);
2137 snprintf(addr,
sizeof(addr),
"%d",
board.pid);
2142 if((targetCANline.toStdString() ==
string(line)) && (targetCANaddr.toStdString() ==
string(addr)) )
2147 if(
verbosity >= 1) qDebug() <<
"CAN ADDRESS: FOUND";
2151 if(
true ==
board.applicationisrunning)
2153 char board_firmware_version [32] = {0};
2154 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d.%d",
board.appl_vers_major,
board.appl_vers_minor,
board.appl_vers_build);
2157 if(
string(board_firmware_version) == targetFWvers.toStdString())
2160 if(
verbosity >= 1) qDebug() <<
"CAN FW VERSION: MATCHES";
2168 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2178 const bool forceMaintenance =
true;
2180 int boards = core->
connectTo(device,
id);
2184 if(device.contains(
"ETH"))
2186 if(forceMaintenance)
2196 if(canBoards.count() <= 0)
2198 if(
verbosity >= 1) qDebug() << retString;
2199 qDebug() << QString(
"%1: no can board beneath").arg(
board);
2203 ret =
verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2209 if(
verbosity >= 1) qDebug() <<
"You have to put the device in maintenace mode to perform this operation.";
2216 if(
verbosity >= 1) qDebug() <<
"No boards Found";
2217 qDebug() <<
board <<
": cannot find it";
2228 const bool slimprint =
true;
2232 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2234 int boards = core->
connectTo(device,
id);
2241 if(targetIPaddr.toStdString() ==
board.getIPV4string())
2246 if(
true == slimprint)
2248 char IPslimstring[512] = {0};
2249 snprintf(IPslimstring,
sizeof(IPslimstring),
"%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
2250 board.getIPV4string().c_str(),
2251 eoboards_type2string2(eoboards_ethtype2type(
board.getInfo().boardtype), eobool_true),
2252 board.getInfo().processes.info[2].version.major,
board.getInfo().processes.info[2].version.minor,
2253 board.getInfo().processes.info[1].version.major,
board.getInfo().processes.info[1].version.minor,
2254 board.getInfo().processes.info[0].version.major,
board.getInfo().processes.info[0].version.minor);
2256 qDebug() << IPslimstring;
2271 char notfound[512] = {0};
2272 snprintf(notfound,
sizeof(notfound),
"%s: not found",
2273 targetIPaddr.toStdString().c_str());
2275 qDebug() << notfound;
2277 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2288 const bool forceMaintenance =
true;
2290 char notfound[256] = {0};
2292 int boards = core->
connectTo(device,
id);
2296 if(device.contains(
"ETH"))
2298 if(forceMaintenance)
2308 if(canBoards.count() <= 0)
2310 if(
verbosity >= 1) qDebug() << retString;
2311 qDebug() <<
board <<
": no can board beneath";
2321 if(
verbosity >= 1) qDebug() <<
"You have to put the device in maintenace mode to perform this operation.";
2328 if(
verbosity >= 1) qDebug() <<
"No boards Found";
2329 qDebug() <<
board <<
": cannot find it";
2336int queryCanDevices(QList<sBoard> canBoards,
const QString onIPboard,
const QString &targetCANline,
const QString &targetCANaddr)
2341 const bool slimprint =
true;
2343 for(
int i=0;i<canBoards.count();i++)
2347 if(
verbosity >= 1) qDebug() <<
"---------------------------------------------------------";
2351 snprintf(line,
sizeof(line),
"%d",
board.bus);
2353 snprintf(addr,
sizeof(addr),
"%d",
board.pid);
2356 if((targetCANline.toStdString() ==
string(line)) && (targetCANaddr.toStdString() ==
string(addr)) )
2361 char board_firmware_version[32] = {0};
2363 if(
true ==
board.applicationisrunning)
2365 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d.%d",
board.appl_vers_major,
board.appl_vers_minor,
board.appl_vers_build);
2369 snprintf (board_firmware_version,
sizeof(board_firmware_version),
"%d.%d",
board.appl_vers_major,
board.appl_vers_minor);
2372 if(
true == slimprint)
2374 char CANslimstring[512] = {0};
2375 char IPstr[24] = {0};
2376 if(
false == onIPboard.isEmpty())
2378 snprintf(IPstr,
sizeof(IPstr),
"%s:", onIPboard.toStdString().c_str());
2380 snprintf(CANslimstring,
sizeof(CANslimstring),
"%sCAN%d:%d: type = %s, application = %s",
2383 eoboards_type2string2((eObrd_type_t)
board.type, eobool_true),
2384 board_firmware_version);
2386 qDebug() << CANslimstring;
2396 char notfound[512] = {0};
2397 char IPstr[24] = {0};
2398 if(
false == onIPboard.isEmpty())
2400 snprintf(IPstr,
sizeof(IPstr),
"%s:", onIPboard.toStdString().c_str());
2402 snprintf(notfound,
sizeof(notfound),
"%sCAN%s:%s: not found",
2404 targetCANline.toStdString().c_str(), targetCANaddr.toStdString().c_str());
2406 qDebug() << notfound;
2409 if(
verbosity >= 1) qDebug() <<
"-------------------------------------------------------------";
2419 char notfound[256] = {0};
2423 if(canBoards.count() <= 0)
2426 if(
verbosity >= 1) qDebug() << retString;
2427 snprintf(notfound,
sizeof(notfound),
"<%s>: no can boards beneath", device.toStdString().c_str());
2428 qDebug() << notfound;
QList< sBoard > getSelectedCanBoards()
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)
void selectCanBoardsByAddresses(const std::vector< std::pair< int, int > > &addresses)
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.