Skip to content

Commit cb09602

Browse files
committed
Pick up some changes from richardeoin#20 proposed by @mumme74
1 parent 80e7a56 commit cb09602

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

ftx_prog.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ enum cbus_mode {
6868
cbus_bitbang_rd = 19,
6969
cbus_timestamp = 20,
7070
cbus_keep_awake = 21,
71+
_cbus_mode_end
7172
};
7273
enum misc_config {
7374
bcd_enable = 0x01,
@@ -554,7 +555,12 @@ static void ee_dump (struct eeprom_fields *ee)
554555
printf(" CBUS\n");
555556
printf("-------\n");
556557
for (c = 0; c < CBUS_COUNT; ++c) {
557-
printf(" CBUS%u = %s\n", c, cbus_mode_strings[ee->cbus[c]]);
558+
/* Check this is a valid cbus mode */
559+
if (ee->cbus[c] < _cbus_mode_end) {
560+
printf(" CBUS%u = %s\n", c, cbus_mode_strings[ee->cbus[c]]);
561+
} else {
562+
printf(" CBUS%u = %d\n", c, ee->cbus[c]);
563+
}
558564
}
559565
};
560566

@@ -1293,17 +1299,20 @@ int main (int argc, char *argv[])
12931299
printf("Erasing EEPROM\n");
12941300
}
12951301

1296-
ee_write(new, len);
1302+
printf("Continue? [y|n]:");
1303+
if (getc(stdin) == 'y') {
1304+
ee_write(new, len);
12971305

1298-
/* Read it back again, and check for differences */
1299-
if (ee_read_and_verify(new, len) != new_crc ) {
1300-
fprintf(stderr, "Readback test failed, results may be botched\n");
1301-
exit(EINVAL);
1302-
}
1303-
if (erase_eeprom == 1) { printf("Erase done\n"); }
1306+
/* Read it back again, and check for differences */
1307+
if (ee_read_and_verify(new, len) != new_crc ) {
1308+
fprintf(stderr, "Readback test failed, results may be botched\n");
1309+
exit(EINVAL);
1310+
}
1311+
if (erase_eeprom == 1) { printf("Erase done\n"); }
13041312

1305-
/* Reset the device to force it to load the new settings */
1306-
ftdi_usb_reset(&ftdi);
1313+
/* Reset the device to force it to load the new settings */
1314+
ftdi_usb_reset(&ftdi);
1315+
}
13071316
}
13081317

13091318
return 0;

0 commit comments

Comments
 (0)