diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2019-03-02 09:50:06 +0100 |
---|---|---|
committer | Adam Malinowski <a.malinowsk2@partner.samsung.com> | 2019-05-20 11:46:11 +0200 |
commit | 9915f54dbd003ed687394bb07e3e2a9ab426dd9d (patch) | |
tree | d649cbb28d794415f6803f5a1d6d0af769dfc672 | |
parent | 7bc5f45a6718401865e0be0dc71cac9c72996375 (diff) | |
download | sd-mux-9915f54dbd003ed687394bb07e3e2a9ab426dd9d.tar.gz sd-mux-9915f54dbd003ed687394bb07e3e2a9ab426dd9d.tar.bz2 sd-mux-9915f54dbd003ed687394bb07e3e2a9ab426dd9d.zip |
setSerial: do not use default device type
When setting the serial number with the wrong device type the SD-Wire
device becomes unusable until the serial number is set again specifying the
correct device type. So using 'sd-mux' as default device type is unwise.
Let's require that a device type is specified when executing the set serial
command.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-rw-r--r-- | doc/man/sd-mux-ctrl.1 | 1 | ||||
-rw-r--r-- | src/main.cpp | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/doc/man/sd-mux-ctrl.1 b/doc/man/sd-mux-ctrl.1 index 60343c5..99ead28 100644 --- a/doc/man/sd-mux-ctrl.1 +++ b/doc/man/sd-mux-ctrl.1 @@ -85,7 +85,6 @@ Set PRODUCT ID of devices which are to be used by sd-mux-ctrl. Default value is Set device type of sd-mux. It can be either "sd-mux" or "sd-wire". This setting is used to distinguish one type of SD-MUX from another. "sd-mux" is a type of standard, full-sized SD-MUX board, while "sd-wire" is a type of miniaturized version of SD-MUX with functionality reduced to SD card multiplexing only. -The default value of this setting is "sd-mux". .RE .PP diff --git a/src/main.cpp b/src/main.cpp index b873cdf..4c6e917 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -278,14 +278,18 @@ int doInit(CCOptionValue options[]) { int setSerial(char *serialNumber, CCOptionValue options[]) { struct ftdi_context *ftdi; int f, ret = EXIT_FAILURE; + char *type = options[CCO_DeviceType].args; + + if (!type) { + fprintf(stderr, "Device type not specified\n"); + return EXIT_FAILURE; + } ftdi = openDevice(options, NULL); if (ftdi == NULL) { return EXIT_FAILURE; } - char *type = options[CCO_DeviceType].args != NULL ? options[CCO_DeviceType].args : (char *)"sd-mux"; - f = ftdi_eeprom_initdefaults(ftdi, (char *)"SRPOL", type, serialNumber); if (f < 0) { fprintf(stderr, "Unable to set eeprom strings: %d (%s)\n", f, ftdi_get_error_string(ftdi)); |