iCub-main
Loading...
Searching...
No Matches
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 if(verbosity >= 1) qDebug() << retString;
1519 return ret ? 0 : -1;
1520 }else{
1521 if(verbosity >= 1) qDebug() << "No board selected";
1522 return -1;
1523 }
1524 }else{
1525 if(verbosity >= 1) qDebug() << retString;
1526 return -1;
1527 }
1528
1529 }
1530 }
1531
1532 }
1533 }else{
1534 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1535 if(canBoards.count() > 0){
1536 int selectedCount = 0;
1537 for(int j=0;j<canBoards.count();j++){
1538 sBoard b = canBoards.at(j);
1539 if(b.bus == canLine.toInt() && b.pid == canId.toInt()){
1540 b.selected = true;
1541 b.eeprom = eraseEEprom;
1542 canBoards.replace(j,b);
1543 selectedCount++;
1544 }
1545 }
1546 if(selectedCount > 0){
1547 core->setSelectedCanBoards(canBoards,device,id.toInt());
1548 bool ret = core->uploadCanApplication(file, &retString, eraseEEprom, device, id.toInt());
1549 if(verbosity >= 1) qDebug() << retString;
1550 return ret ? 0 : -1;
1551 }else{
1552 if(verbosity >= 1) qDebug() << "No board selected";
1553 return -1;
1554 }
1555 }else{
1556 if(verbosity >= 1) qDebug() << retString;
1557 return -1;
1558 }
1559 }
1560 return -1;
1561}
1562
1563
1564int programEthDevice(FirmwareUpdaterCore *core,QString device,QString id,QString board,QString file)
1565{
1566 int boards = core->connectTo(device,id);
1567 if(boards > 0){
1568 if(device.contains("ETH")){
1569 char board_ipaddr[16];
1570 for(int i=0;i<core->getEthBoardList().size();i++){
1571 EthBoard ethBoard = core->getEthBoardList()[i];
1572 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", ethBoard.getIPV4string().c_str());
1573
1574 if(board.contains(board_ipaddr)){
1575 core->setSelectedEthBoard(i,true);
1576 QString resultString;
1577 bool b = core->uploadEthApplication(file,&resultString);
1578 if(!b){
1579 if(verbosity >= 1) qDebug() << resultString;
1580 return -1;
1581 }else{
1582 if(verbosity >= 1) qDebug() << "Update Done";
1583 return 0;
1584 }
1585 break;
1586 }
1587 }
1588 }
1589
1590 }else{
1591 if(verbosity >= 1) qDebug() << "No boards found";
1592 }
1593 return -1;
1594
1595}
1596
1597int printSecondLevelDevices(FirmwareUpdaterCore *core,QString device,QString id, bool slimprint)
1598{
1599 if(device.contains("ETH")){
1600 int boards = core->connectTo(device,id);
1601 if(boards > 0){
1602
1603 char board_ipaddr[16];
1604 char board_mac[32];
1605
1606 char board_version[16];
1607 char board_date[24];
1608 char board_built[24];
1609 char board_type[24];
1610 char running_process[24];
1611 char board_info[32];
1612 char appl_version[32] = {0};
1613
1614 memset(board_ipaddr,0,sizeof(board_ipaddr));
1615 memset(board_mac,0,sizeof(board_mac));
1616 memset(board_version,0,sizeof(board_version));
1617 memset(board_date,0,sizeof(board_date));
1618 memset(board_built,0,sizeof(board_built));
1619 memset(board_type,0,sizeof(board_type));
1620 memset(running_process,0,sizeof(running_process));
1621 memset(board_info,0,sizeof(board_info));
1622
1623
1624 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1625 for(int i=0;i<core->getEthBoardList().size();i++){
1626 EthBoard board = core->getEthBoardList()[i];
1627
1628 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", board.getIPV4string().c_str());
1629
1630 ACE_UINT64 mac = board.getInfo().macaddress;
1631
1632 snprintf(board_mac, sizeof(board_mac), "%02X-%02X-%02X-%02X-%02X-%02X",
1633 (uint8_t)(mac >> 40) & 0xff,
1634 (uint8_t)(mac >> 32) & 0xff,
1635 (uint8_t)(mac >> 24) & 0xff,
1636 (uint8_t)(mac >> 16) & 0xff,
1637 (uint8_t)(mac >> 8 ) & 0xff,
1638 (uint8_t)(mac ) & 0xff
1639 );
1640
1641
1642 snprintf(board_version, sizeof(board_version), "%s", board.getVersionfRunning().c_str());
1643 snprintf(board_type, sizeof(board_type), "%s", eoboards_type2string2(eoboards_ethtype2type(board.getInfo().boardtype), eobool_true));
1644 snprintf(running_process, sizeof(running_process), "%s", eouprot_process2string((eOuprot_process_t)board.getInfo().processes.runningnow));
1645 snprintf(board_info, sizeof(board_info), "%s", board.getInfoOnEEPROM().c_str());
1646 snprintf(board_date, sizeof(board_date), "%s", board.getDatefRunning().c_str());
1647 snprintf(board_built, sizeof(board_date), "%s", board.getCompilationDateOfRunning().c_str());
1648 snprintf(appl_version, sizeof(appl_version), "%d.%d", board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor);
1649
1650 if(true == slimprint)
1651 {
1652 char IPslimstring[512] = {0};
1653 snprintf(IPslimstring, sizeof(IPslimstring), "%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
1654 board.getIPV4string().c_str(),
1655 eoboards_type2string2(eoboards_ethtype2type(board.getInfo().boardtype), eobool_true),
1656 board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor,
1657 board.getInfo().processes.info[1].version.major, board.getInfo().processes.info[1].version.minor,
1658 board.getInfo().processes.info[0].version.major, board.getInfo().processes.info[0].version.minor);
1659
1660 qDebug() << IPslimstring;
1661 }
1662 else
1663 {
1664 if(verbosity >= 1) qDebug() << "************** Device " << i << " ******************";
1665 if(verbosity >= 1) qDebug() << "Ip: "<< board_ipaddr;
1666 if(verbosity >= 1) qDebug() << "Mac: "<< board_mac;
1667 if(verbosity >= 1) qDebug() << "Version: "<< board_version;
1668 if(verbosity >= 1) qDebug() << "Appl Ver: "<< appl_version;
1669 if(verbosity >= 1) qDebug() << "Type: "<< board_type;
1670 if(verbosity >= 1) qDebug() << "Process: "<< running_process;
1671 if(verbosity >= 1) qDebug() << "Info: "<< board_info;
1672 if(verbosity >= 1) qDebug() << "Date: "<< board_date;
1673 if(verbosity >= 1) qDebug() << "Built: "<< board_built;
1674 if(verbosity >= 1) qDebug() << "\n";
1675 }
1676
1677 }
1678 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1679
1680 }
1681 }else{
1682 QString retString;
1683 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1684 if(canBoards.count() <= 0){
1685 if(verbosity >= 1) qDebug() << retString;
1686 }else{
1687 QString empty;
1688 printCanDevices(canBoards, empty, slimprint);
1689 }
1690 }
1691 return 0;
1692}
1693
1694int printThirdLevelDevices(FirmwareUpdaterCore *core,QString device,QString id,QString board, bool forceMaintenance, bool forceApplication, bool slimprint)
1695{
1696
1697// if(forceMaintenance)
1698// {
1699// yDebug() << "printThirdLevelDevices() is sending in manteinance mode:" << board.toStdString();
1700// int ret = setBoardToMaintenance(core,device,id,board);
1701// yDebug() << "ret is " << ret;
1702// }
1703
1704 int boards = core->connectTo(device,id);
1705 if(boards > 0){
1706 if(device.contains("ETH")){
1707 if(forceMaintenance){
1708 core->setSelectedEthBoard(board,true);
1709 core->goToMaintenance();
1710 }else if(forceApplication){
1711 core->setSelectedEthBoard(board,true);
1712 core->goToApplication();
1713 }
1715 QString retString;
1716 QList <sBoard> canBoards = core->getCanBoardsFromEth(board,&retString);
1717 if(canBoards.count() <= 0){
1718 if(verbosity >= 1) qDebug() << retString;
1719 }else{
1720 printCanDevices(canBoards, board, slimprint);
1721 }
1722
1723 }else{
1724 if(verbosity >= 1) qDebug() << "for board" << board << "You have to put the device in maintenace mode to perform this operation.";
1725 }
1726
1727 }
1728 }else{
1729 if(verbosity >= 1) qDebug() << "No boards Found";
1730 }
1731
1732 return 0;
1733}
1734
1735void printCanDevices(QList<sBoard> canBoards, QString onIPboard, bool slimprint)
1736{
1737 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1738 for(int i=0;i<canBoards.count();i++){
1739 sBoard board = canBoards.at(i);
1740
1741 char board_type [50]; memset (board_type, 0, sizeof(board_type));
1742 char board_process [50]; memset (board_process, 0, sizeof(board_process));
1743 char board_status [50]; memset (board_status, 0, sizeof(board_status));
1744 char board_add_info [50]; memset (board_add_info, 0, sizeof(board_add_info));
1745 char board_firmware_version [32]; memset (board_firmware_version, 0, sizeof(board_firmware_version));
1746 char board_appl_minor [10]; memset (board_appl_minor, 0, sizeof(board_appl_minor));
1747 char board_appl_build [10]; memset (board_appl_build, 0, sizeof(board_appl_build));
1748 char board_serial [50]; memset (board_serial, 0, sizeof(board_serial));
1749 char board_protocol [10]; memset (board_protocol, 0, sizeof(board_protocol));
1750
1751 snprintf(board_type, sizeof(board_type), "%s", eoboards_type2string2((eObrd_type_t)board.type, eobool_true));
1752
1753 switch (board.status)
1754 {
1755 case BOARD_RUNNING:
1756 strcpy(board_status, "RUNNING");
1757 break;
1758 case BOARD_WAITING:
1759 strcpy(board_status, "WAITING");
1760 break;
1761 case BOARD_WAITING_ACK:
1762 strcpy(board_status, "WAITING_ACK");
1763 break;
1764 case BOARD_DOWNLOADING:
1765 strcpy(board_status, "DOWNLOADING");
1766 break;
1767 case BOARD_OK :
1768 strcpy(board_status, "OK");
1769 break;
1770 case BOARD_ERR:
1771 strcpy(board_status, "ERR");
1772 break;
1773 default:
1774 strcpy(board_status, "UNKNOWN");
1775 break;
1776 }
1777
1778 if(true == board.applicationisrunning){
1779 strcpy(board_process, "canApplication");
1780 } else {
1781 strcpy(board_process, "canBootloader");
1782 }
1783
1784 strncpy (board_add_info, board.add_info,32);
1785
1786 if(-1 == board.appl_vers_build){
1787 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d", board.appl_vers_major, board.appl_vers_minor);
1788 } else {
1789 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d.%d", board.appl_vers_major, board.appl_vers_minor, board.appl_vers_build);
1790 }
1791
1792 snprintf (board_appl_minor, sizeof(board_appl_minor), "%d",board.appl_vers_minor);
1793 snprintf (board_appl_build, sizeof(board_appl_build), "%d",board.appl_vers_build);
1794 snprintf (board_serial, sizeof(board_serial), "%s", board.serial);
1795
1796 if((0 == board.prot_vers_major) && (0 == board.prot_vers_minor))
1797 {
1798 snprintf (board_protocol, sizeof(board_protocol), "N/A");
1799 }
1800 else
1801 {
1802 snprintf (board_protocol, sizeof(board_protocol), "%d.%d", board.prot_vers_major, board.prot_vers_minor);
1803 }
1804
1805 if(true == slimprint)
1806 {
1807 char CANslimstring[512] = {0};
1808 char IPstr[24] = {0};
1809 if(false == onIPboard.isEmpty())
1810 {
1811 snprintf(IPstr, sizeof(IPstr), "%s:", onIPboard.toStdString().c_str());
1812 }
1813 snprintf(CANslimstring, sizeof(CANslimstring), "%sCAN%d:%d: type = %s, application = %s",
1814 IPstr,
1815 board.bus, board.pid,
1816 //board.getIPV4string().c_str(),
1817 eoboards_type2string2((eObrd_type_t)board.type, eobool_true),
1818 board_firmware_version);
1819
1820 qDebug() << CANslimstring;
1821 }
1822 else
1823 {
1824 if(verbosity >= 1) qDebug() << "************** Board " << i << " ******************";
1825 if(verbosity >= 1) qDebug() << "Type: " << board_type;
1826 if(verbosity >= 1) qDebug() << "Id: " << board.pid;
1827 if(verbosity >= 1) qDebug() << "Address: " << "CAN_" << board.bus;
1828 if(verbosity >= 1) qDebug() << "Process: " << board_process;
1829 if(verbosity >= 1) qDebug() << "Status: " << board_status;
1830 if(verbosity >= 1) qDebug() << "Info: " << board_add_info;
1831 if(verbosity >= 1) qDebug() << "Firmware Version: " << board_firmware_version;
1832 if(verbosity >= 1) qDebug() << "Serial: " << board_serial;
1833 if(verbosity >= 1) qDebug() << "Protocol: " << board_protocol;
1834 if(verbosity >= 1) qDebug() << "\n";
1835 }
1836 }
1837 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1838}
1839
1841{
1842 QString tempFile;
1843#ifdef Q_OS_WIN
1844 tempFile = QDir::homePath() + "/firmwareUpdater.singleton";
1845#else
1846 tempFile = QDir::homePath() + "/.firmwareUpdater.singleton";
1847#endif
1848
1849 QFileInfo fInfo(tempFile);
1850 if(fInfo.exists()){
1851 return false;
1852 }
1853
1854 QFile f(tempFile);
1855 f.open(QIODevice::WriteOnly);
1856 f.write("busy");
1857 f.flush();
1858 f.close();
1859
1860#ifdef Q_OS_WIN
1861 LPCSTR a = (const char*)fInfo.filePath().utf16();
1862 BOOL b = SetFileAttributes(a,FILE_ATTRIBUTE_HIDDEN);
1863#endif
1864
1865 return true;
1866
1867}
1868
1869
1871{
1872 QString tempFile;
1873#ifdef Q_OS_WIN
1874 tempFile = QDir::homePath() + "/firmwareUpdater.singleton";
1875#else
1876 tempFile = QDir::homePath() + "/.firmwareUpdater.singleton";
1877#endif
1878
1879 QFileInfo fInfo(tempFile);
1880 if(!fInfo.exists()){
1881 return;
1882 }
1883
1884 QFile f(tempFile);
1885 f.remove();
1886
1887}
1888
1889int verifyOnSecondLevel(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
1890{
1891 int ret = 1;
1892
1893 if(device.contains("ETH"))
1894 {
1895 int boards = core->connectTo(device, id);
1896 if(boards > 0)
1897 {
1898
1899 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1900
1901 bool found = false;
1902 for(int i=0;i<core->getEthBoardList().size();i++)
1903 {
1904 EthBoard board = core->getEthBoardList()[i];
1905
1906 if(targetIPaddr.toStdString() == board.getIPV4string())
1907 {
1908 found = true;
1909
1910 char board_ipaddr[16] = {0};
1911 char appl_version[32] = {0};
1912
1913 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", board.getIPV4string().c_str());
1914 snprintf(appl_version, sizeof(appl_version), "%d.%d", board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor);
1915
1916 if(targetFWvers == appl_version)
1917 {
1918 ret = 0;
1919 if(verbosity >= 1) qDebug() << "MATCHED";
1920 }
1921 else
1922 {
1923 ret = 1;
1924 if(verbosity >= 1) qDebug() << "NOT MATCHED";
1925 }
1926
1927 break;
1928 }
1929
1930
1931
1932 }
1933
1934 if(!found)
1935 {
1936 ret = 1;
1937 if(verbosity >= 1) qDebug() << "NOT MATCHED (IP = " << targetIPaddr << " not in found boards)";
1938 }
1939 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1940
1941 }
1942 else
1943 {
1944 ret = 1;
1945 if(verbosity >= 1) qDebug() << "NOT MATCHED (found no board)";
1946 }
1947 }
1948 else
1949 {
1950 QString retString;
1951 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
1952 if(canBoards.count() <= 0)
1953 {
1954 ret = 1;
1955 if(verbosity >= 1) qDebug() << retString;
1956 }
1957 else
1958 {
1959 ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
1960 }
1961 }
1962
1963 return ret;
1964}
1965
1966
1967int verifyOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetFWvers)
1968{
1969 int ret = 2;
1970
1971// if(device.contains("ETH"))
1972// {
1973 int boards = core->connectTo(device, id);
1974 if(boards > 0)
1975 {
1976
1977 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
1978
1979 bool found = false;
1980 for(int i=0;i<core->getEthBoardList().size();i++)
1981 {
1982 EthBoard board = core->getEthBoardList()[i];
1983
1984 if(targetIPaddr.toStdString() == board.getIPV4string())
1985 {
1986 found = true;
1987 ret = 1;
1988
1989 char board_ipaddr[16] = {0};
1990 char appl_version[32] = {0};
1991
1992 snprintf(board_ipaddr, sizeof(board_ipaddr), "%s", board.getIPV4string().c_str());
1993 snprintf(appl_version, sizeof(appl_version), "%d.%d", board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor);
1994
1995 if(targetFWvers == appl_version)
1996 {
1997 ret = 0;
1998 if(verbosity >= 1) qDebug() << "ETH FOUND + FW MATCHED";
1999 }
2000 else
2001 {
2002 ret = 1;
2003 if(verbosity >= 1) qDebug() << "ETH FOUND + FW NOT MATCHED";
2004 }
2005
2006 break;
2007 }
2008
2009
2010
2011 }
2012
2013 if(!found)
2014 {
2015 ret = 2;
2016 if(verbosity >= 1) qDebug() << "NOT MATCHED (IP = " << targetIPaddr << " not in found boards)";
2017 }
2018 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2019
2020 }
2021 else
2022 {
2023 ret = 2;
2024 if(verbosity >= 1) qDebug() << "NOT MATCHED (found no board)";
2025 }
2026
2027// }
2028// else
2029// {
2030// QString retString;
2031// QList <sBoard> canBoards = core->getCanBoardsFromDriver(device,id.toInt(),&retString,true);
2032// if(canBoards.count() <= 0)
2033// {
2034// ret = 1;
2035// if(verbosity >= 1) qDebug() << retString;
2036// }
2037// else
2038// {
2039// ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2040// }
2041// }
2042
2043 return ret;
2044}
2045
2046int verifyOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
2047{
2048 int ret = 2; // not found, not matched
2049
2050 QString retString;
2051 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device, id.toInt(), &retString, true);
2052 if(canBoards.count() <= 0)
2053 {
2054 ret = 2;
2055 if(verbosity >= 1) qDebug() << retString;
2056 }
2057 else
2058 {
2059 ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2060 }
2061
2062
2063 return ret;
2064}
2065
2066int verifyCanDevices(QList<sBoard> canBoards, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
2067{
2068 int ret = 2; // not found, not matched
2069
2070 bool found = false;
2071
2072 for(int i=0;i<canBoards.count();i++)
2073 {
2074 sBoard board = canBoards.at(i);
2075
2076 if(verbosity >= 1) qDebug() << "---------------------------------------------------------";
2077
2078 // see if address matches
2079 char line[8] = {0};
2080 snprintf(line, sizeof(line), "%d", board.bus);
2081 char addr[8] = {0};
2082 snprintf(addr, sizeof(addr), "%d", board.pid);
2083
2084 //if(verbosity >= 1) qDebug() << targetCANline << targetCANaddr;
2085 //printf("line+addr = %s %s", line, addr);
2086
2087 if((targetCANline.toStdString() == string(line)) && (targetCANaddr.toStdString() == string(addr)) )
2088 {
2089 found = true;
2090 ret = 1; // found, maybe not yet fw match
2091
2092 if(verbosity >= 1) qDebug() << "CAN ADDRESS: FOUND";
2093
2094 //snprintf(board_type, sizeof(board_type), "%s", eoboards_type2string2((eObrd_type_t)board.type, eobool_true));
2095
2096 if(true == board.applicationisrunning)
2097 {
2098 char board_firmware_version [32] = {0};
2099 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d.%d", board.appl_vers_major, board.appl_vers_minor, board.appl_vers_build);
2100 //printf("ss %s", board_firmware_version);
2101
2102 if(string(board_firmware_version) == targetFWvers.toStdString())
2103 {
2104 ret = 0; // match!
2105 if(verbosity >= 1) qDebug() << "CAN FW VERSION: MATCHES";
2106 }
2107 }
2108
2109 break;
2110 }
2111 }
2112
2113 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2114
2115 return ret;
2116}
2117
2118
2119int verifyOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, QString board, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
2120{
2121 int ret = 2;
2122
2123 const bool forceMaintenance = true;
2124
2125 int boards = core->connectTo(device, id);
2126
2127 if(boards > 0)
2128 {
2129 if(device.contains("ETH"))
2130 {
2131 if(forceMaintenance)
2132 {
2133 core->setSelectedEthBoard(board, true);
2134 core->goToMaintenance();
2135 }
2136
2138 {
2139 QString retString;
2140 QList <sBoard> canBoards = core->getCanBoardsFromEth(board, &retString);
2141 if(canBoards.count() <= 0)
2142 {
2143 if(verbosity >= 1) qDebug() << retString;
2144 }
2145 else
2146 {
2147 ret = verifyCanDevices(canBoards, targetCANline, targetCANaddr, targetFWvers);
2148 }
2149
2150 }
2151 else
2152 {
2153 if(verbosity >= 1) qDebug() << "You have to put the device in maintenace mode to perform this operation.";
2154 }
2155
2156 }
2157 }
2158 else
2159 {
2160 if(verbosity >= 1) qDebug() << "No boards Found";
2161 }
2162
2163 return ret;
2164}
2165
2166
2167int queryOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr)
2168{
2169 int ret = 1;
2170
2171 const bool slimprint = true;
2172
2173 bool found = false;
2174
2175 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2176
2177 int boards = core->connectTo(device, id);
2178 if(boards > 0)
2179 {
2180 for(int i=0;i<core->getEthBoardList().size();i++)
2181 {
2182 EthBoard board = core->getEthBoardList()[i];
2183
2184 if(targetIPaddr.toStdString() == board.getIPV4string())
2185 {
2186 found = true;
2187 ret = 0;
2188
2189 if(true == slimprint)
2190 {
2191 char IPslimstring[512] = {0};
2192 snprintf(IPslimstring, sizeof(IPslimstring), "%s: type = %s, application = %d.%d, updater = %d.%d, loader = %d.%d",
2193 board.getIPV4string().c_str(),
2194 eoboards_type2string2(eoboards_ethtype2type(board.getInfo().boardtype), eobool_true),
2195 board.getInfo().processes.info[2].version.major, board.getInfo().processes.info[2].version.minor,
2196 board.getInfo().processes.info[1].version.major, board.getInfo().processes.info[1].version.minor,
2197 board.getInfo().processes.info[0].version.major, board.getInfo().processes.info[0].version.minor);
2198
2199 qDebug() << IPslimstring;
2200 }
2201
2202 break;
2203 }
2204
2205
2206 }
2207
2208
2209 }
2210
2211 if(!found)
2212 {
2213 ret = 1;
2214 char notfound[512] = {0};
2215 snprintf(notfound, sizeof(notfound), "%s: not found",
2216 targetIPaddr.toStdString().c_str());
2217
2218 qDebug() << notfound;
2219 }
2220 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2221
2222
2223 return ret;
2224}
2225
2226
2227int queryOnThirdLevel_CANunderETH(FirmwareUpdaterCore *core, QString device, QString id, const QString board, const QString &targetCANline, const QString &targetCANaddr)
2228{
2229 int ret = 1;
2230
2231 const bool forceMaintenance = true;
2232
2233 char notfound[256] = {0};
2234
2235 int boards = core->connectTo(device, id);
2236
2237 if(boards > 0)
2238 {
2239 if(device.contains("ETH"))
2240 {
2241 if(forceMaintenance)
2242 {
2243 core->setSelectedEthBoard(board, true);
2244 core->goToMaintenance();
2245 }
2246
2248 {
2249 QString retString;
2250 QList <sBoard> canBoards = core->getCanBoardsFromEth(board, &retString);
2251 if(canBoards.count() <= 0)
2252 {
2253 if(verbosity >= 1) qDebug() << retString;
2254 snprintf(notfound, sizeof(notfound), "%s: no can board beneath", board.toStdString().c_str());
2255 qDebug() << notfound;
2256 }
2257 else
2258 {
2259 ret = queryCanDevices(canBoards, board, targetCANline, targetCANaddr);
2260 }
2261
2262 }
2263 else
2264 {
2265 if(verbosity >= 1) qDebug() << "You have to put the device in maintenace mode to perform this operation.";
2266 }
2267
2268 }
2269 }
2270 else
2271 {
2272 if(verbosity >= 1) qDebug() << "No boards Found";
2273 snprintf(notfound, sizeof(notfound), "%s: cannot find it", board.toStdString().c_str());
2274 qDebug() << notfound;
2275 }
2276
2277 return ret;
2278}
2279
2280
2281int queryCanDevices(QList<sBoard> canBoards, const QString onIPboard, const QString &targetCANline, const QString &targetCANaddr)
2282{
2283 int ret = 1; // not found
2284
2285 bool found = false;
2286 const bool slimprint = true;
2287
2288 for(int i=0;i<canBoards.count();i++)
2289 {
2290 sBoard board = canBoards.at(i);
2291
2292 if(verbosity >= 1) qDebug() << "---------------------------------------------------------";
2293
2294 // see if address matches
2295 char line[8] = {0};
2296 snprintf(line, sizeof(line), "%d", board.bus);
2297 char addr[8] = {0};
2298 snprintf(addr, sizeof(addr), "%d", board.pid);
2299
2300
2301 if((targetCANline.toStdString() == string(line)) && (targetCANaddr.toStdString() == string(addr)) )
2302 {
2303 found = true;
2304 ret = 0; // found
2305
2306 char board_firmware_version[32] = {0};
2307
2308 if(true == board.applicationisrunning)
2309 {
2310 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d.%d", board.appl_vers_major, board.appl_vers_minor, board.appl_vers_build);
2311 }
2312 else
2313 {
2314 snprintf (board_firmware_version, sizeof(board_firmware_version), "%d.%d", board.appl_vers_major, board.appl_vers_minor);
2315 }
2316
2317 if(true == slimprint)
2318 {
2319 char CANslimstring[512] = {0};
2320 char IPstr[24] = {0};
2321 if(false == onIPboard.isEmpty())
2322 {
2323 snprintf(IPstr, sizeof(IPstr), "%s:", onIPboard.toStdString().c_str());
2324 }
2325 snprintf(CANslimstring, sizeof(CANslimstring), "%sCAN%d:%d: type = %s, application = %s",
2326 IPstr,
2327 board.bus, board.pid,
2328 eoboards_type2string2((eObrd_type_t)board.type, eobool_true),
2329 board_firmware_version);
2330
2331 qDebug() << CANslimstring;
2332 }
2333
2334 break;
2335 }
2336 }
2337
2338 if(!found)
2339 {
2340 ret = 1;
2341 char notfound[512] = {0};
2342 char IPstr[24] = {0};
2343 if(false == onIPboard.isEmpty())
2344 {
2345 snprintf(IPstr, sizeof(IPstr), "%s:", onIPboard.toStdString().c_str());
2346 }
2347 snprintf(notfound, sizeof(notfound), "%sCAN%s:%s: not found",
2348 IPstr,
2349 targetCANline.toStdString().c_str(), targetCANaddr.toStdString().c_str());
2350
2351 qDebug() << notfound;
2352 }
2353
2354 if(verbosity >= 1) qDebug() << "-------------------------------------------------------------";
2355
2356 return ret;
2357}
2358
2359
2360int queryOnSecondLevel_CANboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetCANline, const QString &targetCANaddr)
2361{
2362 int ret = 1; // not found
2363
2364 char notfound[256] = {0};
2365
2366 QString retString;
2367 QList <sBoard> canBoards = core->getCanBoardsFromDriver(device, id.toInt(), &retString, true);
2368 if(canBoards.count() <= 0)
2369 {
2370 ret = 1;
2371 if(verbosity >= 1) qDebug() << retString;
2372 snprintf(notfound, sizeof(notfound), "<%s>: no can boards beneath", device.toStdString().c_str());
2373 qDebug() << notfound;
2374 }
2375 else
2376 {
2377 QString none;
2378 ret = queryCanDevices(canBoards, targetCANline, none, targetCANaddr);
2379 }
2380
2381
2382 return ret;
2383}
2384
2385
@ 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:2046
int verbosity
Definition main.cpp:17
int queryOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr)
Definition main.cpp:2167
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:1735
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:2066
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:1597
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:1694
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:2119
void removeApplicationLock()
Definition main.cpp:1870
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:1840
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:2227
int verifyOnSecondLevel_ETHboard(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetFWvers)
Definition main.cpp:1967
int verifyOnSecondLevel(FirmwareUpdaterCore *core, QString device, QString id, const QString &targetIPaddr, const QString &targetCANline, const QString &targetCANaddr, const QString &targetFWvers)
Definition main.cpp:1889
int queryCanDevices(QList< sBoard > canBoards, const QString onIPboard, const QString &targetCANline, const QString &targetCANaddr)
Definition main.cpp:2281
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:1564
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:2360
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