Loading [MathJax]/extensions/tex2jax.js
iCub-main
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
main.cpp
Go to the documentation of this file.
1#include "mainwindow.h"
2#include <QApplication>
3#include <QCommandLineParser>
4#include <QCommandLineOption>
5#include <QFileInfo>
6#include <qdebug.h>
7#include <QDir>
8
10
11#undef UPDATER_RELEASE
12
13#ifdef Q_OS_WIN
14#include <Windows.h>
15#endif
16
17int verbosity = 1;
18
19using namespace yarp::os;
20
42
43enum class SensorModel
44{
45 ft45,
46 ft58
47};
48
49
52void printCanDevices(QList<sBoard> canBoards, QString onIPboard, bool slimprint);
53int printSecondLevelDevices(FirmwareUpdaterCore*,QString device,QString id, bool slimprint);
54int printThirdLevelDevices(FirmwareUpdaterCore*,QString device,QString id,QString board, bool forceMaintenance, bool forceApplication, bool slimprint);
55int programEthDevice(FirmwareUpdaterCore*,QString device,QString id,QString board,QString file);
56int programCanDevice(FirmwareUpdaterCore*, QString device, QString id, QString board, QString canLine, QString canId, QString file, bool eraseEEprom);
57int setBoardToApplication(FirmwareUpdaterCore *core,QString device,QString id,QString board);
58int setBoardToMaintenance(FirmwareUpdaterCore *core,QString device,QString id,QString board);
59//int eraseEthEEprom(FirmwareUpdaterCore *core,QString device,QString id,QString board);
60
61int verifyOnSecondLevel(FirmwareUpdaterCore *core,QString device,QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers);
62int verifyOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetFWvers);
63int verifyOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers);
64int verifyCanDevices(QList<sBoard> canBoards, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers);
65int verifyOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, QString board, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers);
66
67//int queryOnSecondLevel(FirmwareUpdaterCore *core,QString device,QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr);
68int queryOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr);
69int queryOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr);
70int queryCanDevices(QList<sBoard> canBoards, const QString onIPboard, const QString &targetCANline, const QString &targetCANaddr);
71int queryOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, const QString board, const QString &targetCANline, const QString &targetCANaddr);
72int loadDatFileStrain2(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,QString file,bool eraseEEprom);
73int saveDatFileStrain2(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,bool eraseEEprom);
74int setStrainSn(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId, QString serialNumber);
75int setStrainGainsOffsets(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,SensorModel model);
76int getCanBoardVersion(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,bool save);
77int changeCanId(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId, QString canIdNew);
78int changeBoardIp(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString newipaddr);
79
80void checkForAction(bool &actionIsValid, action_t const &actionValue, action_t &actionResult);
81
82int main(int argc, char *argv[])
83{
84 Network yarp;
85 QApplication a(argc, argv);
86
87 QApplication::setStyle("motif");
88
89
91
92#ifdef UPDATER_RELEASE
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";
96 return 0;
97 }
98#endif
99
100 QCommandLineParser parser;
101 parser.addVersionOption();
102 parser.setApplicationDescription("Firmware Updater Help");
103 parser.addHelpOption();
104
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
134
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
164 parser.process(a);
165
166 bool noGui = parser.isSet(noGuiOption);
167 bool adminMode = parser.isSet(adminOption);
168 //bool strainCalibMode = parser.isSet(strainCalibOption);
169 QString iniFile = parser.value(iniFileOption);
170 QString address = DEFAULT_IP_ADDRESS;
171 bool bPrintUsage=false;
172 int port = DEFAULT_IP_PORT;
173
174 if(parser.isSet(verbosityOption))
175 {
176 QString vv = parser.value(verbosityOption);
177 verbosity = vv.toInt();
178 }
179
180
181 if(parser.isSet(addressOption)){
182 address = parser.value(addressOption);
183 }else{
184 bPrintUsage=true;
185 }
186
187 if(parser.isSet(portOption)){
188 port = parser.value(portOption).toInt();
189 }else{
190 bPrintUsage=true;
191 }
192
193 if (bPrintUsage){
194 //qDebug() << "Usage: " << argv[0] << " --port n --address xxx.xxx.xxx.xxx\n";
195 }
196
197 ResourceFinder rf;
198 rf.setDefaultContext("firmwareUpdater");
199 rf.setDefaultConfigFile(iniFile.toLatin1().data());
200
201 if(!rf.configure(argc, argv)){
202 return false;
203 }
204
205 if(!core.init(rf, port, address, verbosity)){
206 return -1;
207 }
208 int ret = 1;
209 MainWindow w(&core,adminMode/*,strainCalibMode*/);
210 if(!noGui){
211 w.show();
212 ret = a.exec();
213 }else{
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);
225
226 if(parser.isSet(setStrainGainsSpecificOffsetOption)){
227 if(verbosity >= 1) qDebug() << "Sensor model:" << sensorModel;
228 }
229
230 QString targetFW = parser.value(verifyOption);
231
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);
245
246
247 QString canIdNew = parser.value(changeCanIdOption);
248 QString newIp = parser.value(changeBoardIpOption);
249
250
251
253
254 action_t action = action_none;
255
256 // check mutual exclusive actions: discover or query or verify or program or forceapplication or forcemaintenance
257
258 checkForAction(discover, action_discover, action);
259 checkForAction(query, action_query, action);
260 checkForAction(verify, action_verify, action);
261 checkForAction(program, action_program, action);
262 checkForAction(forceMaintenance, action_forcemaintenance, action);
263 checkForAction(forceApplication, action_forceapplication, action);
264 checkForAction(loadDatFile, action_loaddatfile, action);
265 checkForAction(setSn, action_setstrainsn, action);
267 checkForAction(setGainsSpecific, action_setstraingainsspecificoffsets, action);
268 checkForAction(getVersion, action_getcanboardversion, action);
269 checkForAction(saveDatFile, action_savedatfile, action);
270 checkForAction(changeCanID, action_changeCanId, action);
271 checkForAction(changeIp, action_changeBoardIp, action);
272
273 // now use a switch case
274
275 switch(action)
276 {
277 default:
278 case action_none:
279 {
280 ret = 1;
281
282 if(verbosity >= 1) qDebug() << "specify at least one option amongst discover / verify / program / forcemaintenance / forceapplication";
283
284 } break;
285
287 {
288 ret = 1;
289
290 if(verbosity >= 1) qDebug() << "specify only one option amongst discover / verify / program / forcemaintenance / forceapplication";
291
292 } break;
293
294 case action_discover:
295 {
296 ret = 1;
297 //yDebug() << "discover";
298
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";
303 }else{
304
305 if(board.isEmpty()){
306 ret = printSecondLevelDevices(&core,device,id, true);
307 }else{
308 ret = printThirdLevelDevices(&core,device,id,board,true,false, true);
309 }
310 }
311
312 } break;
313
314 case action_query:
315 {
316 ret = 1;
317 //yDebug() << "query";
318
319 if(device.isEmpty())
320 {
321 if(verbosity >= 1) qDebug() << "Need a device";
322 }
323 else if (device.contains("ETH"))
324 {
325 // second level eth (ipaddr + ethfwversion) or third level can_under_eth (ipaddr+canaddr + canfwversion) or ..
326 if(board.isEmpty())
327 {
328 if(verbosity >= 1) qDebug() << "Need an IP address";
329 }
330 else if((canLine.isEmpty()) && (canId.isEmpty()))
331 {
332 // we query the fw version of an eth board
333 ret = queryOnSecondLevel_ETHboard(&core, device, id, board);
334 }
335 else if((!canLine.isEmpty()) && (!canId.isEmpty()))
336 {
337 // we query the fw version of a can board below eth
338 // FirmwareUpdater --nogui --verbosity 1 --device ETH --id eth1 --eth_board 10.0.1.1 --can_line 2 --can_id 2 --query
339 ret = queryOnThirdLevel_CANunderETH(&core, device, id, board, canLine, canId);
340 }
341 else
342 {
343 if(verbosity >= 1) qDebug() << "Must have both can line and address";
344 }
345 }
346 else
347 {
348 // second level cfw2 or other can driver
349 if((canLine.isEmpty()) || (canId.isEmpty()))
350 {
351 if(verbosity >= 1) qDebug() << "Must have both can line and address";
352 }
353 else
354 {
355 // we query the fw version of a can board below cfw2
356 ret = queryOnSecondLevel_CANboard(&core, device, id, canLine, canId);
357 }
358
359 }
360
361 } break;
362
363
364 case action_verify:
365 {
366 ret = 2;
367 //yDebug() << "verify";
368
369 if(device.isEmpty())
370 {
371 if(verbosity >= 1) qDebug() << "Need a device";
372 }
373 else if (device.contains("ETH"))
374 {
375 // second level eth (ipaddr + ethfwversion) or third level can_under_eth (ipaddr+canaddr + canfwversion) or ..
376 if(board.isEmpty())
377 {
378 if(verbosity >= 1) qDebug() << "Need an ip address";
379 }
380 else if(targetFW.isEmpty())
381 {
382 if(verbosity >= 1) qDebug() << "Need a target fw version";
383 }
384 else if((canLine.isEmpty()) && (canId.isEmpty()))
385 {
386 // we evaluate the fw version of an eth board
387 ret = verifyOnSecondLevel_ETHboard(&core, device, id, board, targetFW);
388 }
389 else if((!canLine.isEmpty()) && (!canId.isEmpty()))
390 {
391 // we evaluate the fw version of a can board below eth
392 // FirmwareUpdater --nogui --verbosity 1 --device ETH --id eth1 --eth_board 10.0.1.1 --can_line 2 --can_id 2 --verify 1.3.7
393 ret = verifyOnThirdLevel_CANunderETH(&core, device, id, board, canLine, canId, targetFW);
394 }
395 else
396 {
397 if(verbosity >= 1) qDebug() << "Must have both can line and address";
398 }
399 }
400 else
401 {
402 // second level cfw2 or other can driver
403 if(targetFW.isEmpty())
404 {
405 if(verbosity >= 1) qDebug() << "Need a target fw version";
406 }
407 else if((canLine.isEmpty()) || (canId.isEmpty()))
408 {
409 if(verbosity >= 1) qDebug() << "Must have both can line and address";
410 }
411 else
412 {
413 // we evaluate the fw version of a can board below eth
414 ret = verifyOnSecondLevel_CANboard(&core, device, id, canLine, canId, targetFW);
415 }
416
417 }
418
419 } break;
420
421 case action_program:
422 {
423 ret = 1;
424 //yDebug() << "program";
425
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()){
435 ret = programEthDevice(&core,device,id,board,file);
436// if(eraseEEprom && ret == 0){
437// ret = eraseEthEEprom(&core,device,id,board);
438// }
439 }else{
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";
444 }else{
445 ret = programCanDevice(&core,device,id,board,canLine,canId,file,eraseEEprom);
446 }
447 }
448
449 } break;
450
452 {
453 ret = 1;
454 //yDebug() << "forcemaintenance";
455
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";
462 }else{
463
464 ret = setBoardToMaintenance(&core,device,id,board);
465 }
466
467 } break;
468
470 {
471 ret = 1;
472 //yDebug() << "forceapplication";
473
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";
480 }else{
481
482 ret = setBoardToApplication(&core,device,id,board);
483 }
484
485 } break;
486
488 {
489 ret = 1;
490
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";
497 }else{
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";
502 }else{
503 ret = loadDatFileStrain2(&core,device,id,board,canLine,canId,file,eraseEEprom);
504 }
505 }
506
507 } break;
508
510 {
511 ret = 1;
512
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";
517 }else{
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";
524 }else{
525 ret = setStrainSn(&core,device,id,board,canLine,canId,serialNumber);
526 }
527 }
528
529 } break;
530
532 {
533 ret = 1;
534
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";
539 }else{
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";
544 }else{
545 ret = setStrainGainsOffsets(&core,device,id,board,canLine,canId,SensorModel::ft45);
546 }
547 }
548
549 } break;
550
552 {
553 ret = 1;
554
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";
559 }else{
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";
564 }else{
565
566 if(sensorModel=="FT58")
567 {
568 ret = setStrainGainsOffsets(&core,device,id,board,canLine,canId,SensorModel::ft58);
569 }
570 else
571 {
572 ret = setStrainGainsOffsets(&core,device,id,board,canLine,canId,SensorModel::ft45);
573 }
574 }
575 }
576
577 } break;
578
580 {
581 ret = 1;
582
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";
587 }else{
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";
592 }else{
593 bool save;
594 if(saveVersion == "y") save = true;
595 else save = false;
596 ret = getCanBoardVersion(&core,device,id,board,canLine,canId,save);
597 }
598 }
599
600 } break;
601
603 {
604 ret = 1;
605
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";
610 }else{
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";
615 }else{
616 ret = saveDatFileStrain2(&core,device,id,board,canLine,canId,eraseEEprom);
617 }
618 }
619
620 } break;
621
623 {
624 ret = 1;
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";
629 }else{
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";
634 }else{
635 ret = changeCanId(&core,device,id,board,canLine,canId,canIdNew);
636 }
637 }
638
639 } break;
640
642 {
643 ret = 1;
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";
648 }else{
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";
651 }else{
652 ret = changeBoardIp(&core,device,id,board, newIp);
653 }
654 }
655
656 } break;
657
658 };
659#if 0
660// old code now substituted by the switch-case
661 if(discover){
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";
666 }else{
667
668 if(board.isEmpty()){
669 ret = printSecondLevelDevices(&core,device,id);
670 }else{
671 ret = printThirdLevelDevices(&core,device,id,board,forceMaintenance,forceApplication);
672 }
673 }
674 }else if(program){
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()){
684 ret = programEthDevice(&core,device,id,board,file);
685// if(eraseEEprom && ret == 0){
686// ret = eraseEthEEprom(&core,device,id,board);
687// }
688 }else{
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";
693 }else{
694 ret = programCanDevice(&core,device,id,board,canLine,canId,file,eraseEEprom);
695 }
696 }
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";
704 }else{
705 if(forceApplication){
706 ret = setBoardToApplication(&core,device,id,board);
707 }else {
708 ret = setBoardToMaintenance(&core,device,id,board);
709 }
710
711 }
712// if(eraseEEprom && ret == 0){
713// ret = eraseEthEEprom(&core,device,id,board);
714// }
715 }
716#endif
717
718 }
719
720
721
722#ifdef UPDATER_RELEASE
724#endif
725
726 return ret;
727}
728
729
730/**************************************************/
731
732void checkForAction(bool &actionIsValid, action_t const &actionValue, action_t &actionResult)
733{
734 if((actionIsValid) && (action_impossible != actionResult))
735 {
736 if(actionResult == action_none)
737 {
738 actionResult = actionValue;
739 }
740 else
741 {
742 actionResult = action_impossible;
743 }
744 }
745}
746
747//int eraseEthEEprom(FirmwareUpdaterCore *core,QString device,QString id,QString board)
748//{
749// int boards = core->connectTo(device,id);
750// if(boards > 0){
751// if(device.contains("ETH")){
752// core->setSelectedEthBoard(board,true);
753// core->eraseEthEprom();
754// }
755// }
756// return 0;
757//}
758
759/* // the chosen gains:
760 const strain2_ampl_discretegain_t ampsets[NUMofCHANNELS] =
761 {
762 ampl_gain08, ampl_gain24, ampl_gain24,
763 ampl_gain10, ampl_gain10, ampl_gain24
764 };
765
766 yDebug() << "strain2-amplifier-tuning: STEP-1. imposing gains which are different of each channel";
767
768 for(int channel=0; channel<NUMofCHANNELS; channel++)
769 {
770 yDebug() << "strain2-amplifier-tuning: STEP-1. on channel" << channel << "we impose gain =" << strain_amplifier_discretegain2float(ampsets[channel]);
771
772 strain_set_amplifier_discretegain(bus, target_id, channel, ampsets[channel], regset, errorstring);
773
774 // i wait some time
775 yarp::os::Time::delay(1.0);
776 }
777
778 */
779int changeBoardIp(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString newipaddr)
780{
781 // FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -2 10.0.1.2
782
783 QString retString;
784 bool ret;
785 string msg;
786 int index;
787 QString result;
788
789 ret = setBoardToMaintenance(core,device,id,board);
791 yError("ETH board is not present or not in maintenace mode!!\n");
792 return false;
793 }
794
795 EthBoardList ethl = core->getEthBoardList();
796
797 for(int i = 0 ; i< ethl.size(); i++){
798 if(ethl[i].getIPV4string() == board.toStdString()) index = i;
799 }
800
801 ret = core->setEthBoardAddress(index, newipaddr);
802 if(ret) yInfo() << "Cahnge board IP Succeded !!!";
803 else yError() << "Cahnge board IP Failed !!!";
804 return -1;
805}
806
807int changeCanId(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId, QString canIdNew)
808{
809 // FirmwareUpdater -g -e SOCKETCAN -i 0 -c 0 -n 1 -k 2
810 // FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -c 1 -n 1 -k 2
811
812 QList <sBoard> canBoards;
813 QString retString;
814 bool ret;
815 string msg;
816
817 if(device.contains("SOCKETCAN"))
818 {
819
820 if (canId.toInt() <1 || canId.toInt() >= 15 || canIdNew.toInt() <1 || canIdNew.toInt() >= 15){
821 yError("Invalid board address!\n");
822 return false;
823 }
824
825 canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
826
827 if(canBoards.count() > 0)
828 {
829 core->getDownloader()->change_card_address(canLine.toInt(),canId.toInt(),canIdNew.toInt(),canBoards[0].type);
830 yInfo() << "Cahnge CAN ID message sent !!!";
831
832 } else {
833 yError() << "No CAN board found, stopped!";
834 return false;
835 }
836 }
837 else if(device.contains("ETH"))
838 {
839
840 QString result;
841 ret = setBoardToMaintenance(core,device,id,board);
843 yError("ETH board is not present or not in maintenace mode!!\n");
844 return false;
845 }
846 canBoards = core->getCanBoardsFromEth(board,&result,canLine.toInt(),true);
847 if(canBoards.count() > 0)
848 {
849 core->setSelectedCanBoards(canBoards,board,-1);
850 ret = core->setCanBoardAddress(canLine.toInt(),canId.toInt(),canBoards[0].type,canIdNew,board,-1,&result);
851 if(ret) yInfo() << "Cahnge CAN ID Succeded !!!";
852 else yError() << "Cahnge CAN ID Failed !!!";
853
854 } else {
855 yError() << "No CAN board found, stopped!";
856 return false;
857 }
858 }
859
860 return -1;
861}
862
863int getCanBoardVersion(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,bool save)
864{
865 QList <sBoard> canBoards;
866 QString retString;
867 string msg;
868
869 if(device.contains("SOCKETCAN"))
870 {
871 if (canId.toInt() <1 || canId.toInt() >= 15){
872 yError("Invalid board address!\n");
873 return false;
874 }
875
876 canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
877
878
879 }
880 else if(device.contains("ETH"))
881 {
882 QString result, ret;
883 ret = setBoardToMaintenance(core,device,id,board);
885 yError("ETH board is not present or not in maintenace mode!!\n");
886 return false;
887 }
888 canBoards = core->getCanBoardsFromEth(board,&result,canLine.toInt(),true);
889 }
890
891 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
892 {
893 ofstream myfile;
894 string prefix = "Application ";
895
896 if(!canBoards[0].applicationisrunning && save)
897 {
898 try{
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";
902 myfile.close();
903 yInfo() << prefix << " version : " << canBoards[0].appl_vers_major << "." << canBoards[0].appl_vers_minor;
904 }
905 catch (std::ifstream::failure e) {
906 yError() << "Exception opening file";
907 return false;
908 }
909 }else if(canBoards[0].applicationisrunning && save)
910 {
911 try{
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";
915 myfile.close();
916 yInfo() << prefix << " version : " << canBoards[0].appl_vers_major << "." << canBoards[0].appl_vers_minor << "." << canBoards[0].appl_vers_build;
917 }
918 catch (std::ifstream::failure e) {
919 yError() << "Exception opening file";
920 return false;
921 }
922 }
923
924 } else {
925 yError() << "No CAN board found, stopped!";
926 return false;
927 }
928
929 return -1;
930}
931
932
933
934int setStrainGainsOffsets(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,SensorModel model)
935{
936 //10-2020 - davide.tome@iit.it
937 //This method is used to set the PGA gains to
938 // i.e. FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -c 1 -n 13 -z -w SN001
939
940 QList <sBoard> canBoards;
941 QString retString;
942 int ret;
943 string msg;
944 std::vector<strain2_ampl_discretegain_t> gains(0);
945 std::vector<int16_t> targets(0);
946
947 std::vector<strain2_ampl_discretegain_t> ampsets = {
950
951 if (model == SensorModel::ft45) {
954 } else {
957 }
958
959 for(int i = 0; i < 6; i++){ targets.push_back(0); gains.push_back(ampsets[i]);}
960
961 if(device.contains("SOCKETCAN"))
962 {
963 if (canId.toInt() <1 || canId.toInt() >= 15){
964 yError("Invalid board address!\n");
965 return false;
966 }
967
968 canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
969
970
971 }
972 else if(device.contains("ETH"))
973 {
974 QString result, ret;
975 ret = setBoardToMaintenance(core,device,id,board);
977 yError("ETH board is not present or not in maintenace mode!!\n");
978 return false;
979 }
980 canBoards = core->getCanBoardsFromEth(board,&result,canLine.toInt(),true);
981 }
982
983 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
984 {
985 string error = "e";
986
987 yDebug() << "strain2-amplifier-tuning: STEP-1. imposing gains which are different of each channel";
988
989 core->getDownloader()->strain_calibrate_offset2(canLine.toInt(), canId.toInt(),
990 static_cast<icubCanProto_boardType_t>(canBoards[0].type),
991 gains, targets, &msg);
992
993 yarp::os::Time::delay(0.2);
994 core->getDownloader()->strain_save_to_eeprom(canLine.toInt(),canId.toInt(), &msg);
995 yInfo() << "Gains Saved!";
996
997 } else {
998 yError() << "No STRAIN2 board found, stopped!";
999 return false;
1000 }
1001
1002 unsigned int adc[6];
1003 char tempbuf [250];
1004 bool failCh = false;
1005
1006 for(int i=0; i<6; i++){
1007
1008 if(i==0)ret = core->getDownloader()->strain_get_adc (canLine.toInt(),canId.toInt(), i, adc[i], 0, &msg);
1009 else ret |= core->getDownloader()->strain_get_adc (canLine.toInt(),canId.toInt(), i, adc[i], 0, &msg);
1010
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);
1017 }
1018
1019 if(failCh){
1020 yError() << "Strange value on Channels ADC readings...";
1021 return false;
1022 }else{
1023 yInfo() << "Good values in ADC channels reading!";
1024 }
1025
1026 /* if(device.contains("ETH")){
1027 ret = setBoardToApplication(core,device,id,board);
1028 if(core->isBoardInMaintenanceMode(board)){
1029 yError("ETH board not switched to application mode!!\n");
1030 return false;
1031 } else yInfo() << "ETH board ready!";
1032 } */
1033
1034
1035 return -1;
1036}
1037
1038int setStrainSn(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId, QString serialNumber)
1039{
1040 //10-2020 - davide.tome@iit.it
1041 //This method is used to set the SN in the STRAIN EEPROM
1042 // i.e. FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -c 1 -n 13 -z -w SN001
1043
1044 QList <sBoard> canBoards;
1045 QString retString;
1046 string msg;
1047
1048 QByteArray string = serialNumber.toLatin1();
1049 char * sn = string.data();
1050
1051 if(device.contains("SOCKETCAN"))
1052 {
1053 if (canId.toInt() <1 || canId.toInt() >= 15){
1054 yError("Invalid board address!\n");
1055 return false;
1056 }
1057
1058 canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1059
1060 }
1061 else if(device.contains("ETH"))
1062 {
1063 QString result, ret;
1064 ret = setBoardToMaintenance(core,device,id,board);
1065 if(!core->isBoardInMaintenanceMode(board)){
1066 yError("ETH board is not present or not in maintenace mode!!\n");
1067 return false;
1068 }
1069 canBoards = core->getCanBoardsFromEth(board,&result,canLine.toInt(),true);
1070 }
1071
1072
1073 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1074 {
1075
1076
1077 core->getDownloader()->strain_set_serial_number(canLine.toInt(),canId.toInt(), sn);
1078 core->getDownloader()->strain_save_to_eeprom(canLine.toInt(),canId.toInt(), &msg);
1079
1080 yInfo() << "Serial Number Saved!";
1081
1082
1083 } else {
1084 yError() << "No STRAIN2 board found, stopped!";
1085 return false;
1086 }
1087
1088 /* if(device.contains("ETH")){
1089 ret = setBoardToApplication(core,device,id,board);
1090 if(core->isBoardInMaintenanceMode(board)){
1091 yError("ETH board not switched to application mode!!\n");
1092 return false;
1093 } else yInfo() << "ETH board ready!";
1094 } */
1095
1096 return -1;
1097}
1098
1099int loadDatFileStrain2(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,QString file,bool eraseEEprom)
1100{
1101 //09-2020 - davide.tome@iit.it
1102 //This method is used to load a calibration file into the eeprom of the STRAIN2 using the dedicated CLI option -z/--load-dat-file (and -l/--file option to specify the file to be loaded)
1103 // i.e. FirmwareUpdater -g -e SOCKETCAN -i 0 -c 1 -n 13 -z -l calibrationDataSN003.dat
1104 // i.e. FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -c 1 -n 13 -z -l calibrationDataSN003.dat
1105
1106 QList <sBoard> canBoards;
1107 QString retString;
1108 char sn[256];
1109 int index = 0;
1110 unsigned int CHANNEL_COUNT = 6;
1111 strain2_ampl_regs_t amp_registers[6];
1112 unsigned int offset[6];
1113 unsigned int calib_matrix[3][6][6];
1114 int calib_bias[6];
1115 unsigned int full_scale_const[3][6];
1116 string msg;
1117
1118
1119 if (file==NULL){
1120 yError("File not found!\n");
1121 return false;
1122 }
1123
1124
1125 if(device.contains("SOCKETCAN"))
1126 {
1127 if (canId.toInt() <1 || canId.toInt() >= 15){
1128 yError("Invalid board address!\n");
1129 return false;
1130 }
1131
1132 canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1133
1134
1135 }
1136 else if(device.contains("ETH"))
1137 {
1138 QString result, ret;
1139 ret = setBoardToMaintenance(core,device,id,board);
1140 if(!core->isBoardInMaintenanceMode(board)){
1141 yError("ETH board is not present or not in maintenace mode!!\n");
1142 return false;
1143 }
1144 canBoards = core->getCanBoardsFromEth(board,&result,canLine.toInt(),true);
1145 }
1146
1147 //Flash the .dat file
1148 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1149 {
1150 int ret = core->getDownloader()->get_serial_no(canLine.toInt(),canId.toInt(),sn);
1151 if(canBoards.count() > 0)
1152 {
1153 int boardtype = canBoards[0].type;
1154 int regset = canBoards[0].strainregsetinuse;
1155
1156 int file_version=0;
1157 fstream filestr;
1158 filestr.open (file.toLatin1().data(), fstream::in);
1159 if (!filestr.is_open()){
1160 yError("Error opening calibration file!\n");
1161 return false;
1162 }
1163
1164 unsigned int i=0;
1165 char buffer[256];
1166
1167 //file version
1168 filestr.getline (buffer,256);
1169 filestr.getline (buffer,256);
1170 sscanf (buffer,"%d",&file_version);
1171
1172
1173 if( ( (icubCanProto_boardType__strain2 == boardtype) || (icubCanProto_boardType__strain2c == boardtype) ) && (3 != file_version))
1174 {
1175 yError("Wrong file. Calibration version not supported for strain2: %d\n", file_version);
1176 return false;
1177 }
1178 else if((icubCanProto_boardType__strain == boardtype) && (2 != file_version))
1179 {
1180 yError("Wrong file. Calibration version not supported: %d\n", file_version);
1181 return false;
1182 }
1183
1184 if(3 == file_version)
1185 {
1186 // Board type:
1187 filestr.getline (buffer,256);
1188 filestr.getline (buffer,256);
1189 if(0 != strcmp(buffer, "strain2"))
1190 {
1191 yError("Wrong file. Board type not supported: %s\n", buffer);
1192 return false;
1193 }
1194
1195 // Serial number:
1196 filestr.getline (buffer,256);
1197 filestr.getline (buffer,256);
1198 sprintf(sn,"%s", buffer);
1199 core->getDownloader()->strain_set_serial_number(canLine.toInt(),canId.toInt(), sn);
1200 //yDebug() << buffer;
1201
1202 // Amplifier registers:
1203 filestr.getline (buffer,256);
1204 for (i=0;i<CHANNEL_COUNT; i++)
1205 {
1206 filestr.getline (buffer,256);
1207 yDebug() << buffer;
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];
1211
1212 core->getDownloader()->strain_set_amplifier_regs(canLine.toInt(),canId.toInt(), i, amp_registers[i], regset);
1213
1214 // downloader.strain_set_offset (downloader.board_list[selected].bus, downloader.board_list[selected].pid, i, offset[i]);
1215 //core->getDownloader()->strain_set_offset (bus,id, i, offset[i]);
1216 //printf("0X%02x, 0X%02x, 0X%02x, 0X%02x, 0X%02x,0X%02x", amp_registers[i].data[0], amp_registers[i].data[1], amp_registers[i].data[2], amp_registers[i].data[3], amp_registers[i].data[4], amp_registers[i].data[5]);
1217 //fflush(stdout);
1218 drv_sleep(10);
1219 }
1220
1221 }
1222 else
1223 {
1224
1225 //serial number
1226 filestr.getline (buffer,256);
1227 filestr.getline (buffer,256);
1228 sprintf(sn,"%s", buffer);
1229 core->getDownloader()->strain_set_serial_number(canLine.toInt(),canId.toInt(), sn);
1230
1231 //offsets
1232 filestr.getline (buffer,256);
1233 for (i=0;i<CHANNEL_COUNT; i++)
1234 {
1235 filestr.getline (buffer,256);
1236 sscanf (buffer,"%d",&offset[i]);
1237 // downloader.strain_set_offset (downloader.board_list[selected].bus, downloader.board_list[selected].pid, i, offset[i]);
1238 core->getDownloader()->strain_set_offset (canLine.toInt(),canId.toInt(), i, offset[i], regset);
1239 drv_sleep(200);
1240 }
1241 }
1242
1243 //calibration matrix
1244 filestr.getline (buffer,256);
1245 for (i=0;i<36; i++){
1246 int ri=i/6;
1247 int ci=i%6;
1248 filestr.getline (buffer,256);
1249 sscanf (buffer,"%x",&calib_matrix[index][ri][ci]);
1250 //printf("%d %x\n", calib_matrix[index][ri][ci],calib_matrix[index][ri][ci]);
1251 core->getDownloader()->strain_set_matrix_rc(canLine.toInt(),canId.toInt(), ri, ci, calib_matrix[index][ri][ci], regset);
1252 }
1253
1254 //matrix gain
1255 filestr.getline (buffer,256);
1256 filestr.getline (buffer,256);
1257 int cc=0;
1258 sscanf (buffer,"%d",&cc);
1259 core->getDownloader()->strain_set_matrix_gain(canLine.toInt(),canId.toInt(), cc, regset);
1260
1261 //tare
1262 filestr.getline (buffer,256);
1263 for (i=0;i<CHANNEL_COUNT; i++){
1264 filestr.getline (buffer,256);
1265 sscanf (buffer,"%d",&calib_bias[i]);
1266 core->getDownloader()->strain_set_calib_bias(canLine.toInt(),canId.toInt(), i, calib_bias[i], regset);
1267 }
1268
1269 //full scale values
1270 filestr.getline (buffer,256);
1271 for (i=0;i<CHANNEL_COUNT; i++){
1272 filestr.getline (buffer,256);
1273 sscanf (buffer,"%d",&full_scale_const[index][i]);
1274 core->getDownloader()->strain_set_full_scale(canLine.toInt(),canId.toInt(), i, full_scale_const[index][i], regset);
1275 }
1276 filestr.close();
1277 filestr.clear();
1278
1279 core->getDownloader()->strain_save_to_eeprom(canLine.toInt(),canId.toInt(), &msg);
1280
1281 yInfo() << "Calibration file loaded!";
1282 }
1283
1284 } else {
1285 yError() << "No STRAIN2 board found, stopped!";
1286 return false;
1287 }
1288
1289 /* if(device.contains("ETH")){
1290 ret = setBoardToApplication(core,device,id,board);
1291 if(core->isBoardInMaintenanceMode(board)){
1292 yError("ETH board not switched to application mode!!\n");
1293 return false;
1294 } else yInfo() << "ETH board ready!";
1295 } */
1296
1297 return -1;
1298}
1299
1300int saveDatFileStrain2(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,bool eraseEEprom)
1301{
1302 //09-2020 - davide.tome@iit.it
1303 //This method is used to saves the calibration of the STRAIN2
1304 // i.e. FirmwareUpdater -g -e ETH -i eth1 -t 10.0.1.1 -c 1 -n 13 -u
1305
1306 QList <sBoard> canBoards;
1307 QString retString;
1308 unsigned int CHANNEL_COUNT = 6;
1309 strain2_ampl_regs_t amp_registers[6];
1310 unsigned int offset[6];
1311 int calib_bias[6];
1312 float amp_gains[6];
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];
1317 char serial_no[8];
1318 string msg;
1319
1320 calib_const[0] = 1;
1321 calib_const[1] = 1;
1322 calib_const[2] = 1;
1323
1324
1325 int index = 0;
1326
1327 char path[256] = { 0 };
1328 std::string filename;
1329
1330
1331 unsigned int i=0;
1332 char buffer[256];
1333
1334 if(device.contains("SOCKETCAN"))
1335 {
1336 if (canId.toInt() <1 || canId.toInt() >= 15){
1337 yError("Invalid board address!\n");
1338 return false;
1339 }
1340
1341 canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1342
1343 }
1344 else if(device.contains("ETH"))
1345 {
1346 QString result, ret;
1347 ret = setBoardToMaintenance(core,device,id,board);
1348 if(!core->isBoardInMaintenanceMode(board)){
1349 yError("ETH board is not present or not in maintenace mode!!\n");
1350 return false;
1351 }
1352 canBoards = core->getCanBoardsFromEth(board,&result,canLine.toInt(),true);
1353 }
1354
1355 //Flash the .dat file
1356 if(canBoards.count() > 0 && ( (icubCanProto_boardType__strain2 == canBoards[0].type) || (icubCanProto_boardType__strain2c == canBoards[0].type) ) )
1357 {
1358 core->getDownloader()->strain_get_serial_number(canLine.toInt(),canId.toInt(), serial_no);
1359
1360 filename += "calibrationData";
1361 filename += serial_no;
1362 filename += ".dat";
1363 fstream filestr;
1364 filestr.open (filename.c_str(), fstream::out);
1365
1366 for(int i=0; i<6; i++)
1367 {
1368 core->getDownloader()->strain_get_amplifier_regs(canLine.toInt(),canId.toInt(), i, amp_registers[i], cDownloader::strain_regset_inuse, &msg);
1369 core->getDownloader()->strain_get_amplifier_gain_offset(canLine.toInt(),canId.toInt(), i, amp_gains[i], amp_offsets[i], cDownloader::strain_regset_inuse, &msg);
1370 core->getDownloader()->strain_get_offset (canLine.toInt(),canId.toInt(), i, offset[i], cDownloader::strain_regset_inuse, &msg);
1371 }
1372
1373 for(int mi=0;mi<1;mi++){
1374
1375 for (unsigned int ri=0; ri < CHANNEL_COUNT; ri++){
1376 for (unsigned int ci=0;ci<CHANNEL_COUNT;ci++){
1377 core->getDownloader()->strain_get_matrix_rc(canLine.toInt(),canId.toInt(), ri, ci, matrix[mi][ri][ci], cDownloader::strain_regset_inuse, &msg);
1378 core->getDownloader()->strain_get_full_scale(canLine.toInt(),canId.toInt(), ri, full_scale_const[mi][ri], cDownloader::strain_regset_inuse, &msg);
1379 }
1380 }
1381 }
1382
1383 if(icubCanProto_boardType__strain2 == canBoards[0].type || icubCanProto_boardType__strain2c == canBoards[0].type)
1384 {
1385 // file version
1386 filestr<<"File version:"<<endl;
1387 filestr<<"3"<<endl;
1388 // board type
1389 filestr<<"Board type:"<<endl;
1390 filestr<<"strain2"<<endl;
1391 // serial number
1392 filestr<<"Serial number:"<<endl;
1393 sprintf (buffer,"%s",serial_no);
1394 filestr<<buffer<<endl;
1395 // amplifier registers
1396 filestr<<"Amplifier registers:"<<endl;
1397 for (i=0;i<CHANNEL_COUNT; i++){
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;
1402 }
1403 }
1404 else
1405 {
1406 //file version
1407 filestr<<"File version:"<<endl;
1408 filestr<<"2"<<endl;
1409
1410 //serial number
1411 filestr<<"Serial number:"<<endl;
1412 sprintf (buffer,"%s",serial_no);
1413 filestr<<buffer<<endl;
1414
1415 //offsets
1416 filestr<<"Offsets:"<<endl;
1417 for (i=0;i<CHANNEL_COUNT; i++){
1418 sprintf (buffer,"%d",offset[i]);
1419 filestr<<buffer<<endl;
1420 }
1421 }
1422
1423
1424
1425 //calibration matrix
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;
1430 }
1431
1432
1433 //matrix gain
1434 filestr<<"Matrix gain:"<<endl;
1435 sprintf (buffer,"%d",calib_const[index]);
1436 filestr<<buffer<<endl;
1437
1438
1439 //tare
1440 filestr<<"Tare:"<<endl;
1441 for (i=0;i<CHANNEL_COUNT; i++){
1442 sprintf (buffer,"%d",calib_bias[i]);
1443 filestr<<buffer<<endl;
1444 }
1445
1446 //full scale values
1447 filestr<<"Full scale values:"<<endl;
1448 for (i=0;i<CHANNEL_COUNT; i++){
1449 sprintf (buffer,"%d",full_scale_const[index][i]);
1450 filestr<<buffer<<endl;
1451 }
1452
1453 yInfo() << "Calibration file saved!";
1454 filestr.close();
1455 } else {
1456 yError() << "No STRAIN2 board found, stopped!";
1457 return false;
1458 }
1459
1460 return -1;
1461}
1462
1463int setBoardToApplication(FirmwareUpdaterCore *core,QString device,QString id,QString board)
1464{
1465 int boards = core->connectTo(device,id);
1466 if(boards > 0){
1467 if(device.contains("ETH")){
1468 core->setSelectedEthBoard(board,true);
1469 core->goToApplication();
1470 }
1471 }
1472 return 0;
1473}
1474
1475int setBoardToMaintenance(FirmwareUpdaterCore *core,QString device,QString id,QString board)
1476{
1477 int boards = core->connectTo(device,id);
1478 if(boards > 0){
1479 if(device.contains("ETH")){
1480 core->setSelectedEthBoard(board,true);
1481 core->goToMaintenance();
1482 }
1483 }
1484
1485 return 0;
1486}
1487
1488
1489int programCanDevice(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString canLine,QString canId,QString file,bool eraseEEprom)
1490{
1491 QString retString;
1492 if(device.contains("ETH")){
1493 int boards = core->connectTo(device,id);
1494 if(boards > 0){
1495 char board_ipaddr[16];
1496 for(int i=0;i<core->getEthBoardList().size();i++){
1497 EthBoard ethBoard = core->getEthBoardList()[i];
1498 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", ethBoard.getIPV4string().c_str());
1499
1500 if(board.contains(board_ipaddr)){
1501 core->setSelectedEthBoard(i,true);
1502 QList <sBoard> canBoards = core->getCanBoardsFromEth(board,&retString,canLine.toInt(),true);
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()){
1508 b.selected = true;
1509 b.eeprom = eraseEEprom;
1510 canBoards.replace(j,b);
1511 selectedCount++;
1512 }
1513
1514 }
1515 if(selectedCount > 0){
1516 core->setSelectedCanBoards(canBoards,board);
1517 // bool ret = core->uploadCanApplication(file, &retString, eraseEEprom, board);
1518 QList<sBoard> resultCanBoards; // Declare resultCanBoards
1519 bool ret = core->uploadCanApplication(file, &retString, eraseEEprom, board, canLine.toInt(), &resultCanBoards);
1520 if (verbosity >= 1) qDebug() << retString;
1521 return ret ? 0 : -1;
1522 } else {
1523 if (verbosity >= 1) qDebug() << "No board selected";
1524 return -1;
1525 }
1526 } else {
1527 if (verbosity >= 1) qDebug() << retString;
1528 return -1;
1529 }
1530
1531 }
1532 }
1533 }
1534 }
1535 return -1;
1536}
1537
1538int programEthDevice(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString file)
1539{
1540 int boards = core->connectTo(device,id);
1541 if(boards > 0){
1542 if(device.contains("ETH")){
1543 char board_ipaddr[16];
1544 for(int i=0;i<core->getEthBoardList().size();i++){
1545 EthBoard ethBoard = core->getEthBoardList()[i];
1546 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", ethBoard.getIPV4string().c_str());
1547
1548 if(board.contains(board_ipaddr)){
1549 core->setSelectedEthBoard(i,true);
1550 QString resultString;
1551 bool b = core->uploadEthApplication(file,&resultString);
1552 if(!b){
1553 if(verbosity >= 1) qDebug() << resultString;
1554 return -1;
1555 }else{
1556 if(verbosity >= 1) qDebug() << "Update Done";
1557 return 0;
1558 }
1559 break;
1560 }
1561 }
1562 }
1563
1564 }else{
1565 if(verbosity >= 1) qDebug() << "No boards found";
1566 }
1567 return -1;
1568
1569}
1570
1571int printSecondLevelDevices(FirmwareUpdaterCore *core,QString device,QString id, bool slimprint)
1572{
1573 if(device.contains("ETH")){
1574 int boards = core->connectTo(device,id);
1575 if(boards > 0){
1576
1577 char board_ipaddr[16];
1578 char board_mac[32];
1579
1580 char board_version[16];
1581 char board_date[24];
1582 char board_built[24];
1583 char board_type[24];
1584 char running_process[24];
1585 char board_info[32];
1586 char appl_version[32] = {0};
1587
1588 memset(board_ipaddr,0,sizeof(board_ipaddr));
1589 memset(board_mac,0,sizeof(board_mac));
1590 memset(board_version,0,sizeof(board_version));
1591 memset(board_date,0,sizeof(board_date));
1592 memset(board_built,0,sizeof(board_built));
1593 memset(board_type,0,sizeof(board_type));
1594 memset(running_process,0,sizeof(running_process));
1595 memset(board_info,0,sizeof(board_info));
1596
1597
1598 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1599 for(int i=0;i<core->getEthBoardList().size();i++){
1600 EthBoard board = core->getEthBoardList()[i];
1601
1602 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", board.getIPV4string().c_str());
1603
1604 ACE_UINT64 mac = board.getInfo().macaddress;
1605
1606 snprintf(board_mac, sizeof(board_mac), "%02X-%02X-%02X-%02X-%02X-%02X",
1607 (uint8_t)(mac >> 40) & 0xff,
1608 (uint8_t)(mac >> 32) & 0xff,
1609 (uint8_t)(mac >> 24) & 0xff,
1610 (uint8_t)(mac >> 16) & 0xff,
1611 (uint8_t)(mac >> 8 ) & 0xff,
1612 (uint8_t)(mac ) & 0xff
1613 );
1614
1615
1616 snprintf(board_version, sizeof(board_version), "%s", board.getVersionfRunning().c_str());
1617 snprintf(board_type, sizeof(board_type), "%s", eoboards_type2string2(eoboards_ethtype2type(board.getInfo().boardtype), eobool_true));
1618 snprintf(running_process, sizeof(running_process), "%s", eouprot_process2string((eOuprot_process_t)board.getInfo().processes.runningnow));
1619 snprintf(board_info, sizeof(board_info), "%s", board.getInfoOnEEPROM().c_str());
1620 snprintf(board_date, sizeof(board_date), "%s", board.getDatefRunning().c_str());
1621 snprintf(board_built, sizeof(board_date), "%s", board.getCompilationDateOfRunning().c_str());
1622 snprintf(appl_version, sizeof(appl_version), "%d.%d", board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor);
1623
1624 if(true == slimprint)
1625 {
1626 char IPslimstring[512] = {0};
1627 snprintf(IPslimstring, sizeof(IPslimstring), "%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
1628 board.getIPV4string().c_str(),
1629 eoboards_type2string2(eoboards_ethtype2type(board.getInfo().boardtype), eobool_true),
1630 board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor,
1631 board.getInfo().processes.info[1].version.major, board.getInfo().processes.info[1].version.minor,
1632 board.getInfo().processes.info[0].version.major, board.getInfo().processes.info[0].version.minor);
1633
1634 qDebug() << IPslimstring;
1635 }
1636 else
1637 {
1638 if(verbosity >= 1) qDebug() << "************** Device " << i << " ******************";
1639 if(verbosity >= 1) qDebug() << "Ip: "<< board_ipaddr;
1640 if(verbosity >= 1) qDebug() << "Mac: "<< board_mac;
1641 if(verbosity >= 1) qDebug() << "Version: "<< board_version;
1642 if(verbosity >= 1) qDebug() << "Appl Ver: "<< appl_version;
1643 if(verbosity >= 1) qDebug() << "Type: "<< board_type;
1644 if(verbosity >= 1) qDebug() << "Process: "<< running_process;
1645 if(verbosity >= 1) qDebug() << "Info: "<< board_info;
1646 if(verbosity >= 1) qDebug() << "Date: "<< board_date;
1647 if(verbosity >= 1) qDebug() << "Built: "<< board_built;
1648 if(verbosity >= 1) qDebug() << "\n";
1649 }
1650
1651 }
1652 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1653
1654 }
1655 }else{
1656 QString retString;
1657 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1658 if(canBoards.count() <= 0){
1659 if(verbosity >= 1) qDebug() << retString;
1660 }else{
1661 QString empty;
1662 printCanDevices(canBoards, empty, slimprint);
1663 }
1664 }
1665 return 0;
1666}
1667
1668int printThirdLevelDevices(FirmwareUpdaterCore *core,QString device,QString id,QString board, bool forceMaintenance, bool forceApplication, bool slimprint)
1669{
1670
1671// if(forceMaintenance)
1672// {
1673// yDebug() << "printThirdLevelDevices() is sending in manteinance mode:" << board.toStdString();
1674// int ret = setBoardToMaintenance(core,device,id,board);
1675// yDebug() << "ret is " << ret;
1676// }
1677
1678 int boards = core->connectTo(device,id);
1679 if(boards > 0){
1680 if(device.contains("ETH")){
1681 if(forceMaintenance){
1682 core->setSelectedEthBoard(board,true);
1683 core->goToMaintenance();
1684 }else if(forceApplication){
1685 core->setSelectedEthBoard(board,true);
1686 core->goToApplication();
1687 }
1689 QString retString;
1690 QList <sBoard> canBoards = core->getCanBoardsFromEth(board,&retString);
1691 if(canBoards.count() <= 0){
1692 if(verbosity >= 1) qDebug() << retString;
1693 }else{
1694 printCanDevices(canBoards, board, slimprint);
1695 }
1696
1697 }else{
1698 if(verbosity >= 1) qDebug() << "for board" << board << "You have to put the device in maintenace mode to perform this operation.";
1699 }
1700
1701 }
1702 }else{
1703 if(verbosity >= 1) qDebug() << "No boards Found";
1704 }
1705
1706 return 0;
1707}
1708
1709void printCanDevices(QList<sBoard> canBoards, QString onIPboard, bool slimprint)
1710{
1711 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1712 for(int i=0;i<canBoards.count();i++){
1713 sBoard board = canBoards.at(i);
1714
1715 char board_type [50]; memset (board_type, 0, sizeof(board_type));
1716 char board_process [50]; memset (board_process, 0, sizeof(board_process));
1717 char board_status [50]; memset (board_status, 0, sizeof(board_status));
1718 char board_add_info [50]; memset (board_add_info, 0, sizeof(board_add_info));
1719 char board_firmware_version [32]; memset (board_firmware_version, 0, sizeof(board_firmware_version));
1720 char board_appl_minor [10]; memset (board_appl_minor, 0, sizeof(board_appl_minor));
1721 char board_appl_build [10]; memset (board_appl_build, 0, sizeof(board_appl_build));
1722 char board_serial [50]; memset (board_serial, 0, sizeof(board_serial));
1723 char board_protocol [10]; memset (board_protocol, 0, sizeof(board_protocol));
1724
1725 snprintf(board_type, sizeof(board_type), "%s", eoboards_type2string2((eObrd_type_t)board.type, eobool_true));
1726
1727 switch (board.status)
1728 {
1729 case BOARD_RUNNING:
1730 strcpy(board_status, "RUNNING");
1731 break;
1732 case BOARD_WAITING:
1733 strcpy(board_status, "WAITING");
1734 break;
1735 case BOARD_WAITING_ACK:
1736 strcpy(board_status, "WAITING_ACK");
1737 break;
1738 case BOARD_DOWNLOADING:
1739 strcpy(board_status, "DOWNLOADING");
1740 break;
1741 case BOARD_OK :
1742 strcpy(board_status, "OK");
1743 break;
1744 case BOARD_ERR:
1745 strcpy(board_status, "ERR");
1746 break;
1747 default:
1748 strcpy(board_status, "UNKNOWN");
1749 break;
1750 }
1751
1752 if(true == board.applicationisrunning){
1753 strcpy(board_process, "canApplication");
1754 } else {
1755 strcpy(board_process, "canBootloader");
1756 }
1757
1758 strncpy (board_add_info, board.add_info,32);
1759
1760 if(-1 == board.appl_vers_build){
1761 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d", board.appl_vers_major, board.appl_vers_minor);
1762 } else {
1763 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d.%d", board.appl_vers_major, board.appl_vers_minor, board.appl_vers_build);
1764 }
1765
1766 snprintf (board_appl_minor, sizeof(board_appl_minor), "%d",board.appl_vers_minor);
1767 snprintf (board_appl_build, sizeof(board_appl_build), "%d",board.appl_vers_build);
1768 snprintf (board_serial, sizeof(board_serial), "%s", board.serial);
1769
1770 if((0 == board.prot_vers_major) && (0 == board.prot_vers_minor))
1771 {
1772 snprintf (board_protocol, sizeof(board_protocol), "N/A");
1773 }
1774 else
1775 {
1776 snprintf (board_protocol, sizeof(board_protocol), "%d.%d", board.prot_vers_major, board.prot_vers_minor);
1777 }
1778
1779 if(true == slimprint)
1780 {
1781 char CANslimstring[512] = {0};
1782 char IPstr[24] = {0};
1783 if(false == onIPboard.isEmpty())
1784 {
1785 snprintf(IPstr, sizeof(IPstr), "%s:", onIPboard.toStdString().c_str());
1786 }
1787 snprintf(CANslimstring, sizeof(CANslimstring), "%sCAN%d:%d: type = %s, application = %s",
1788 IPstr,
1789 board.bus, board.pid,
1790 //board.getIPV4string().c_str(),
1791 eoboards_type2string2((eObrd_type_t)board.type, eobool_true),
1792 board_firmware_version);
1793
1794 qDebug() << CANslimstring;
1795 }
1796 else
1797 {
1798 if(verbosity >= 1) qDebug() << "************** Board " << i << " ******************";
1799 if(verbosity >= 1) qDebug() << "Type: " << board_type;
1800 if(verbosity >= 1) qDebug() << "Id: " << board.pid;
1801 if(verbosity >= 1) qDebug() << "Address: " << "CAN_" << board.bus;
1802 if(verbosity >= 1) qDebug() << "Process: " << board_process;
1803 if(verbosity >= 1) qDebug() << "Status: " << board_status;
1804 if(verbosity >= 1) qDebug() << "Info: " << board_add_info;
1805 if(verbosity >= 1) qDebug() << "Firmware Version: " << board_firmware_version;
1806 if(verbosity >= 1) qDebug() << "Serial: " << board_serial;
1807 if(verbosity >= 1) qDebug() << "Protocol: " << board_protocol;
1808 if(verbosity >= 1) qDebug() << "\n";
1809 }
1810 }
1811 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1812}
1813
1815{
1816 QString tempFile;
1817#ifdef Q_OS_WIN
1818 tempFile = QDir::homePath() + "/firmwareUpdater.singleton";
1819#else
1820 tempFile = QDir::homePath() + "/.firmwareUpdater.singleton";
1821#endif
1822
1823 QFileInfo fInfo(tempFile);
1824 if(fInfo.exists()){
1825 return false;
1826 }
1827
1828 QFile f(tempFile);
1829 f.open(QIODevice::WriteOnly);
1830 f.write("busy");
1831 f.flush();
1832 f.close();
1833
1834#ifdef Q_OS_WIN
1835 LPCSTR a = (const char*)fInfo.filePath().utf16();
1836 BOOL b = SetFileAttributes(a,FILE_ATTRIBUTE_HIDDEN);
1837#endif
1838
1839 return true;
1840
1841}
1842
1843
1845{
1846 QString tempFile;
1847#ifdef Q_OS_WIN
1848 tempFile = QDir::homePath() + "/firmwareUpdater.singleton";
1849#else
1850 tempFile = QDir::homePath() + "/.firmwareUpdater.singleton";
1851#endif
1852
1853 QFileInfo fInfo(tempFile);
1854 if(!fInfo.exists()){
1855 return;
1856 }
1857
1858 QFile f(tempFile);
1859 f.remove();
1860
1861}
1862
1863int verifyOnSecondLevel(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
1864{
1865 int ret = 1;
1866
1867 if(device.contains("ETH"))
1868 {
1869 int boards = core->connectTo(device, id);
1870 if(boards > 0)
1871 {
1872
1873 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1874
1875 bool found = false;
1876 for(int i=0;i<core->getEthBoardList().size();i++)
1877 {
1878 EthBoard board = core->getEthBoardList()[i];
1879
1880 if(targetIPaddr.toStdString() == board.getIPV4string())
1881 {
1882 found = true;
1883
1884 char board_ipaddr[16] = {0};
1885 char appl_version[32] = {0};
1886
1887 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", board.getIPV4string().c_str());
1888 snprintf(appl_version, sizeof(appl_version), "%d.%d", board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor);
1889
1890 if(targetFWvers == appl_version)
1891 {
1892 ret = 0;
1893 if(verbosity >= 1) qDebug() << "MATCHED";
1894 }
1895 else
1896 {
1897 ret = 1;
1898 if(verbosity >= 1) qDebug() << "NOT MATCHED";
1899 }
1900
1901 break;
1902 }
1903
1904
1905
1906 }
1907
1908 if(!found)
1909 {
1910 ret = 1;
1911 if(verbosity >= 1) qDebug() << "NOT MATCHED (IP = " << targetIPaddr << " not in found boards)";
1912 }
1913 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1914
1915 }
1916 else
1917 {
1918 ret = 1;
1919 if(verbosity >= 1) qDebug() << "NOT MATCHED (found no board)";
1920 }
1921 }
1922 else
1923 {
1924 QString retString;
1925 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1926 if(canBoards.count() <= 0)
1927 {
1928 ret = 1;
1929 if(verbosity >= 1) qDebug() << retString;
1930 }
1931 else
1932 {
1933 ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
1934 }
1935 }
1936
1937 return ret;
1938}
1939
1940
1941int verifyOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetFWvers)
1942{
1943 int ret = 2;
1944
1945// if(device.contains("ETH"))
1946// {
1947 int boards = core->connectTo(device, id);
1948 if(boards > 0)
1949 {
1950
1951 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1952
1953 bool found = false;
1954 for(int i=0;i<core->getEthBoardList().size();i++)
1955 {
1956 EthBoard board = core->getEthBoardList()[i];
1957
1958 if(targetIPaddr.toStdString() == board.getIPV4string())
1959 {
1960 found = true;
1961 ret = 1;
1962
1963 char board_ipaddr[16] = {0};
1964 char appl_version[32] = {0};
1965
1966 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", board.getIPV4string().c_str());
1967 snprintf(appl_version, sizeof(appl_version), "%d.%d", board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor);
1968
1969 if(targetFWvers == appl_version)
1970 {
1971 ret = 0;
1972 if(verbosity >= 1) qDebug() << "ETH FOUND + FW MATCHED";
1973 }
1974 else
1975 {
1976 ret = 1;
1977 if(verbosity >= 1) qDebug() << "ETH FOUND + FW NOT MATCHED";
1978 }
1979
1980 break;
1981 }
1982
1983
1984
1985 }
1986
1987 if(!found)
1988 {
1989 ret = 2;
1990 if(verbosity >= 1) qDebug() << "NOT MATCHED (IP = " << targetIPaddr << " not in found boards)";
1991 }
1992 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1993
1994 }
1995 else
1996 {
1997 ret = 2;
1998 if(verbosity >= 1) qDebug() << "NOT MATCHED (found no board)";
1999 }
2000
2001// }
2002// else
2003// {
2004// QString retString;
2005// QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
2006// if(canBoards.count() <= 0)
2007// {
2008// ret = 1;
2009// if(verbosity >= 1) qDebug() << retString;
2010// }
2011// else
2012// {
2013// ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2014// }
2015// }
2016
2017 return ret;
2018}
2019
2020int verifyOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
2021{
2022 int ret = 2; // not found, not matched
2023
2024 QString retString;
2025 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device, id.toInt(), &retString, true);
2026 if(canBoards.count() <= 0)
2027 {
2028 ret = 2;
2029 if(verbosity >= 1) qDebug() << retString;
2030 }
2031 else
2032 {
2033 ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2034 }
2035
2036
2037 return ret;
2038}
2039
2040int verifyCanDevices(QList<sBoard> canBoards, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
2041{
2042 int ret = 2; // not found, not matched
2043
2044 bool found = false;
2045
2046 for(int i=0;i<canBoards.count();i++)
2047 {
2048 sBoard board = canBoards.at(i);
2049
2050 if(verbosity >= 1) qDebug() << "---------------------------------------------------------";
2051
2052 // see if address matches
2053 char line[8] = {0};
2054 snprintf(line, sizeof(line), "%d", board.bus);
2055 char addr[8] = {0};
2056 snprintf(addr, sizeof(addr), "%d", board.pid);
2057
2058 //if(verbosity >= 1) qDebug() << targetCANline << targetCANaddr;
2059 //printf("line+addr = %s %s", line, addr);
2060
2061 if((targetCANline.toStdString() == string(line)) && (targetCANaddr.toStdString() == string(addr)) )
2062 {
2063 found = true;
2064 ret = 1; // found, maybe not yet fw match
2065
2066 if(verbosity >= 1) qDebug() << "CAN ADDRESS: FOUND";
2067
2068 //snprintf(board_type, sizeof(board_type), "%s", eoboards_type2string2((eObrd_type_t)board.type, eobool_true));
2069
2070 if(true == board.applicationisrunning)
2071 {
2072 char board_firmware_version [32] = {0};
2073 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d.%d", board.appl_vers_major, board.appl_vers_minor, board.appl_vers_build);
2074 //printf("ss %s", board_firmware_version);
2075
2076 if(string(board_firmware_version) == targetFWvers.toStdString())
2077 {
2078 ret = 0; // match!
2079 if(verbosity >= 1) qDebug() << "CAN FW VERSION: MATCHES";
2080 }
2081 }
2082
2083 break;
2084 }
2085 }
2086
2087 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2088
2089 return ret;
2090}
2091
2092
2093int verifyOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, QString board, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
2094{
2095 int ret = 2;
2096
2097 const bool forceMaintenance = true;
2098
2099 int boards = core->connectTo(device, id);
2100
2101 if(boards > 0)
2102 {
2103 if(device.contains("ETH"))
2104 {
2105 if(forceMaintenance)
2106 {
2107 core->setSelectedEthBoard(board, true);
2108 core->goToMaintenance();
2109 }
2110
2112 {
2113 QString retString;
2114 QList <sBoard> canBoards = core->getCanBoardsFromEth(board, &retString);
2115 if(canBoards.count() <= 0)
2116 {
2117 if(verbosity >= 1) qDebug() << retString;
2118 }
2119 else
2120 {
2121 ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2122 }
2123
2124 }
2125 else
2126 {
2127 if(verbosity >= 1) qDebug() << "You have to put the device in maintenace mode to perform this operation.";
2128 }
2129
2130 }
2131 }
2132 else
2133 {
2134 if(verbosity >= 1) qDebug() << "No boards Found";
2135 }
2136
2137 return ret;
2138}
2139
2140
2141int queryOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr)
2142{
2143 int ret = 1;
2144
2145 const bool slimprint = true;
2146
2147 bool found = false;
2148
2149 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2150
2151 int boards = core->connectTo(device, id);
2152 if(boards > 0)
2153 {
2154 for(int i=0;i<core->getEthBoardList().size();i++)
2155 {
2156 EthBoard board = core->getEthBoardList()[i];
2157
2158 if(targetIPaddr.toStdString() == board.getIPV4string())
2159 {
2160 found = true;
2161 ret = 0;
2162
2163 if(true == slimprint)
2164 {
2165 char IPslimstring[512] = {0};
2166 snprintf(IPslimstring, sizeof(IPslimstring), "%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
2167 board.getIPV4string().c_str(),
2168 eoboards_type2string2(eoboards_ethtype2type(board.getInfo().boardtype), eobool_true),
2169 board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor,
2170 board.getInfo().processes.info[1].version.major, board.getInfo().processes.info[1].version.minor,
2171 board.getInfo().processes.info[0].version.major, board.getInfo().processes.info[0].version.minor);
2172
2173 qDebug() << IPslimstring;
2174 }
2175
2176 break;
2177 }
2178
2179
2180 }
2181
2182
2183 }
2184
2185 if(!found)
2186 {
2187 ret = 1;
2188 char notfound[512] = {0};
2189 snprintf(notfound, sizeof(notfound), "%s: not found",
2190 targetIPaddr.toStdString().c_str());
2191
2192 qDebug() << notfound;
2193 }
2194 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2195
2196
2197 return ret;
2198}
2199
2200
2201int queryOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, const QString board, const QString &targetCANline, const QString &targetCANaddr)
2202{
2203 int ret = 1;
2204
2205 const bool forceMaintenance = true;
2206
2207 char notfound[256] = {0};
2208
2209 int boards = core->connectTo(device, id);
2210
2211 if(boards > 0)
2212 {
2213 if(device.contains("ETH"))
2214 {
2215 if(forceMaintenance)
2216 {
2217 core->setSelectedEthBoard(board, true);
2218 core->goToMaintenance();
2219 }
2220
2222 {
2223 QString retString;
2224 QList <sBoard> canBoards = core->getCanBoardsFromEth(board, &retString);
2225 if(canBoards.count() <= 0)
2226 {
2227 if(verbosity >= 1) qDebug() << retString;
2228 snprintf(notfound, sizeof(notfound), "%s: no can board beneath", board.toStdString().c_str());
2229 qDebug() << notfound;
2230 }
2231 else
2232 {
2233 ret = queryCanDevices(canBoards, board, targetCANline, targetCANaddr);
2234 }
2235
2236 }
2237 else
2238 {
2239 if(verbosity >= 1) qDebug() << "You have to put the device in maintenace mode to perform this operation.";
2240 }
2241
2242 }
2243 }
2244 else
2245 {
2246 if(verbosity >= 1) qDebug() << "No boards Found";
2247 snprintf(notfound, sizeof(notfound), "%s: cannot find it", board.toStdString().c_str());
2248 qDebug() << notfound;
2249 }
2250
2251 return ret;
2252}
2253
2254
2255int queryCanDevices(QList<sBoard> canBoards, const QString onIPboard, const QString &targetCANline, const QString &targetCANaddr)
2256{
2257 int ret = 1; // not found
2258
2259 bool found = false;
2260 const bool slimprint = true;
2261
2262 for(int i=0;i<canBoards.count();i++)
2263 {
2264 sBoard board = canBoards.at(i);
2265
2266 if(verbosity >= 1) qDebug() << "---------------------------------------------------------";
2267
2268 // see if address matches
2269 char line[8] = {0};
2270 snprintf(line, sizeof(line), "%d", board.bus);
2271 char addr[8] = {0};
2272 snprintf(addr, sizeof(addr), "%d", board.pid);
2273
2274
2275 if((targetCANline.toStdString() == string(line)) && (targetCANaddr.toStdString() == string(addr)) )
2276 {
2277 found = true;
2278 ret = 0; // found
2279
2280 char board_firmware_version[32] = {0};
2281
2282 if(true == board.applicationisrunning)
2283 {
2284 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d.%d", board.appl_vers_major, board.appl_vers_minor, board.appl_vers_build);
2285 }
2286 else
2287 {
2288 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d", board.appl_vers_major, board.appl_vers_minor);
2289 }
2290
2291 if(true == slimprint)
2292 {
2293 char CANslimstring[512] = {0};
2294 char IPstr[24] = {0};
2295 if(false == onIPboard.isEmpty())
2296 {
2297 snprintf(IPstr, sizeof(IPstr), "%s:", onIPboard.toStdString().c_str());
2298 }
2299 snprintf(CANslimstring, sizeof(CANslimstring), "%sCAN%d:%d: type = %s, application = %s",
2300 IPstr,
2301 board.bus, board.pid,
2302 eoboards_type2string2((eObrd_type_t)board.type, eobool_true),
2303 board_firmware_version);
2304
2305 qDebug() << CANslimstring;
2306 }
2307
2308 break;
2309 }
2310 }
2311
2312 if(!found)
2313 {
2314 ret = 1;
2315 char notfound[512] = {0};
2316 char IPstr[24] = {0};
2317 if(false == onIPboard.isEmpty())
2318 {
2319 snprintf(IPstr, sizeof(IPstr), "%s:", onIPboard.toStdString().c_str());
2320 }
2321 snprintf(notfound, sizeof(notfound), "%sCAN%s:%s: not found",
2322 IPstr,
2323 targetCANline.toStdString().c_str(), targetCANaddr.toStdString().c_str());
2324
2325 qDebug() << notfound;
2326 }
2327
2328 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2329
2330 return ret;
2331}
2332
2333
2334int queryOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr)
2335{
2336 int ret = 1; // not found
2337
2338 char notfound[256] = {0};
2339
2340 QString retString;
2341 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device, id.toInt(), &retString, true);
2342 if(canBoards.count() <= 0)
2343 {
2344 ret = 1;
2345 if(verbosity >= 1) qDebug() << retString;
2346 snprintf(notfound, sizeof(notfound), "<%s>: no can boards beneath", device.toStdString().c_str());
2347 qDebug() << notfound;
2348 }
2349 else
2350 {
2351 QString none;
2352 ret = queryCanDevices(canBoards, targetCANline, none, targetCANaddr);
2353 }
2354
2355
2356 return ret;
2357}
2358
2359
@ data
#define CHANNEL_COUNT
string getIPV4string()
Definition EthBoard.cpp:65
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)
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)
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)
@ strain_regset_inuse
Definition downloader.h:147
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 &ampregs, 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 &ampregs, 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)
uint8_t board
bool error
void drv_sleep(double time)
#define BOARD_WAITING_ACK
Definition downloader.h:47
#define BOARD_ERR
Definition downloader.h:50
#define BOARD_RUNNING
Definition downloader.h:45
#define BOARD_DOWNLOADING
Definition downloader.h:48
#define BOARD_OK
Definition downloader.h:49
#define BOARD_WAITING
Definition downloader.h:46
@ ampl_gain08
Definition downloader.h:107
@ ampl_gain24
Definition downloader.h:106
@ ampl_gain10
Definition downloader.h:107
#define DEFAULT_IP_ADDRESS
#define DEFAULT_IP_PORT
int changeCanId(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, QString canIdNew)
Definition main.cpp:807
int verifyOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
Definition main.cpp:2020
int verbosity
Definition main.cpp:17
int queryOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr)
Definition main.cpp:2141
void checkForAction(bool &actionIsValid, action_t const &actionValue, action_t &actionResult)
Definition main.cpp:732
void printCanDevices(QList< sBoard > canBoards, QString onIPboard, bool slimprint)
Definition main.cpp:1709
int programCanDevice(FirmwareUpdaterCore *, QString device, QString id, QString board, QString canLine, QString canId, QString file, bool eraseEEprom)
Definition main.cpp:1489
int verifyCanDevices(QList< sBoard > canBoards, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
Definition main.cpp:2040
int getCanBoardVersion(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, bool save)
Definition main.cpp:863
int printSecondLevelDevices(FirmwareUpdaterCore *, QString device, QString id, bool slimprint)
Definition main.cpp:1571
SensorModel
Definition main.cpp:44
int changeBoardIp(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString newipaddr)
Definition main.cpp:779
int printThirdLevelDevices(FirmwareUpdaterCore *, QString device, QString id, QString board, bool forceMaintenance, bool forceApplication, bool slimprint)
Definition main.cpp:1668
int setBoardToApplication(FirmwareUpdaterCore *core, QString device, QString id, QString board)
Definition main.cpp:1463
int verifyOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, QString board, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
Definition main.cpp:2093
void removeApplicationLock()
Definition main.cpp:1844
int saveDatFileStrain2(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, bool eraseEEprom)
Definition main.cpp:1300
bool checkApplicationLock()
Definition main.cpp:1814
int setStrainSn(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, QString serialNumber)
Definition main.cpp:1038
int setBoardToMaintenance(FirmwareUpdaterCore *core, QString device, QString id, QString board)
Definition main.cpp:1475
int queryOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, const QString board, const QString &targetCANline, const QString &targetCANaddr)
Definition main.cpp:2201
int verifyOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetFWvers)
Definition main.cpp:1941
int verifyOnSecondLevel(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
Definition main.cpp:1863
int queryCanDevices(QList< sBoard > canBoards, const QString onIPboard, const QString &targetCANline, const QString &targetCANaddr)
Definition main.cpp:2255
int loadDatFileStrain2(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, QString file, bool eraseEEprom)
Definition main.cpp:1099
int programEthDevice(FirmwareUpdaterCore *, QString device, QString id, QString board, QString file)
Definition main.cpp:1538
action_t
Definition main.cpp:22
@ action_query
Definition main.cpp:30
@ action_discover
Definition main.cpp:25
@ action_setstrainft45gainsoffsets
Definition main.cpp:38
@ action_forceapplication
Definition main.cpp:29
@ action_none
Definition main.cpp:24
@ action_changeBoardIp
Definition main.cpp:37
@ action_setstraingainsspecificoffsets
Definition main.cpp:40
@ action_impossible
Definition main.cpp:23
@ action_setstrainft58gainsoffsets
Definition main.cpp:39
@ action_setstrainsn
Definition main.cpp:32
@ action_loaddatfile
Definition main.cpp:31
@ action_savedatfile
Definition main.cpp:35
@ action_setstraingainsoffsets
Definition main.cpp:33
@ action_verify
Definition main.cpp:26
@ action_forcemaintenance
Definition main.cpp:28
@ action_getcanboardversion
Definition main.cpp:34
@ action_changeCanId
Definition main.cpp:36
@ action_program
Definition main.cpp:27
int queryOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr)
Definition main.cpp:2334
int setStrainGainsOffsets(FirmwareUpdaterCore *core, QString device, QString id, QString board, QString canLine, QString canId, SensorModel model)
Definition main.cpp:934
FILE * file
Definition main.cpp:81
int main()
Definition main.cpp:67
Copyright (C) 2008 RobotCub Consortium.
degrees offset
Definition sine.m:4
bool eeprom
Definition downloader.h:39
int bus
Definition downloader.h:25
int pid
Definition downloader.h:26
bool selected
Definition downloader.h:38