File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 1
1
#include " chip_db.h"
2
+ #include < cstring>
2
3
3
4
static ChipInfo chipDB[] =
4
5
{
@@ -13,10 +14,13 @@ uint32_t getChipDB(ChipInfo *&db)
13
14
return CHIP_ID_LAST;
14
15
}
15
16
16
- ChipInfo *getChiInfo ( uint32_t id )
17
+ ChipInfo *getChipInfoByName ( char *name )
17
18
{
18
- if (id >= CHIP_ID_LAST)
19
- return 0 ;
19
+ for (int id = 0 ; id < CHIP_ID_LAST; id++)
20
+ {
21
+ if (!strcmp (name, chipDB[id].name ))
22
+ return &chipDB[id];
23
+ }
20
24
21
- return &chipDB[id] ;
25
+ return 0 ;
22
26
}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ typedef struct
20
20
} ChipInfo;
21
21
22
22
uint32_t getChipDB (ChipInfo *&db);
23
- ChipInfo *getChiInfo ( uint32_t id );
23
+ ChipInfo *getChipInfoByName ( char *name );
24
24
25
25
#endif // CHIP_DB_H
26
26
Original file line number Diff line number Diff line change @@ -178,7 +178,8 @@ void MainWindow::slotProgReadDeviceId()
178
178
void MainWindow::slotProgErase ()
179
179
{
180
180
const uint32_t addr = 0x00000000 ;
181
- ChipInfo *chipInfo = getChiInfo (ui->chipSelectComboBox ->currentIndex ());
181
+ QByteArray ba = ui->chipSelectComboBox ->currentText ().toLatin1 ();
182
+ ChipInfo *chipInfo = getChipInfoByName (ba.data ());
182
183
183
184
if (prog->eraseChip (addr, chipInfo->size ))
184
185
log (tr (" Failed to erase chip\n " ));
You can’t perform that action at this time.
0 commit comments