summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAdam Malinowski <a.malinowsk2@partner.samsung.com>2017-02-15 19:02:13 +0100
committerPawel Wieczorek <p.wieczorek2@samsung.com>2017-07-18 12:42:42 +0200
commita4b43a87bbe405064d4218dfb923ea260f5622ad (patch)
tree096a2e7da9f7c4a53709bb6c1dded8dee25d7f1f /src/main.cpp
parentd7d6012d53dc3a6c65dca52db6c500c182346ca1 (diff)
downloadsd-mux-a4b43a87bbe405064d4218dfb923ea260f5622ad.tar.gz
sd-mux-a4b43a87bbe405064d4218dfb923ea260f5622ad.tar.bz2
sd-mux-a4b43a87bbe405064d4218dfb923ea260f5622ad.zip
Add PRODUCT ID option to command line interface
This change introduces possiblity of using FTDI devices other than FT245RL. Change-Id: Ic4a2c51a45ed0fc3d389ecdd38a4edbd9f5df3c1
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 87c3fb7..4ddc377 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -66,6 +66,7 @@ enum CCOption {
CCO_TickTime,
CCO_BitsInvert,
CCO_Vendor,
+ CCO_Product,
CCO_DyPer,
CCO_MAX
};
@@ -91,7 +92,7 @@ int listDevices(CCOptionValue options[]) {
return EXIT_FAILURE;
}
- if ((fret = ftdi_usb_find_all(ftdi, &devlist, options[CCO_Vendor].argn, PRODUCT)) < 0) {
+ if ((fret = ftdi_usb_find_all(ftdi, &devlist, options[CCO_Vendor].argn, options[CCO_Product].argn)) < 0) {
fprintf(stderr, "ftdi_usb_find_all failed: %d (%s)\n", fret, ftdi_get_error_string(ftdi));
ftdi_free(ftdi);
return EXIT_FAILURE;
@@ -142,9 +143,9 @@ struct ftdi_context* openDevice(CCOptionValue options[]) {
}
if (options[CCO_DeviceSerial].args != NULL) {
- fret = ftdi_usb_open_desc_index(ftdi, options[CCO_Vendor].argn, PRODUCT, NULL, options[CCO_DeviceSerial].args, 0);
+ fret = ftdi_usb_open_desc_index(ftdi, options[CCO_Vendor].argn, options[CCO_Product].argn, NULL, options[CCO_DeviceSerial].args, 0);
} else {
- fret = ftdi_usb_open_desc_index(ftdi, options[CCO_Vendor].argn, PRODUCT, NULL, NULL, options[CCO_DeviceId].argn);
+ fret = ftdi_usb_open_desc_index(ftdi, options[CCO_Vendor].argn, options[CCO_Product].argn, NULL, NULL, options[CCO_DeviceId].argn);
}
if (fret < 0) {
fprintf(stderr, "Unable to open ftdi device: %d (%s)\n", fret, ftdi_get_error_string(ftdi));
@@ -218,6 +219,12 @@ int setSerial(char *serialNumber, CCOptionValue options[]) {
goto finish_him;
}
+ f = ftdi_set_eeprom_value(ftdi, PRODUCT_ID, PRODUCT);
+ if (f < 0) {
+ fprintf(stderr, "Unable to set eeprom strings: %d (%s)\n", f, ftdi_get_error_string(ftdi));
+ goto finish_him;
+ }
+
f = ftdi_eeprom_build(ftdi);
if (f < 0) {
fprintf(stderr, "Unable to build eeprom: %d (%s)\n", f, ftdi_get_error_string(ftdi));
@@ -480,6 +487,7 @@ int parseArguments(int argc, const char **argv, CCCommand *cmd, int *arg, char *
{ "device-serial", 'e', POPT_ARG_STRING, &options[CCO_DeviceSerial].args, 'e',
"use device with given serial number", NULL },
{ "vendor", 'x', POPT_ARG_INT, &options[CCO_Vendor].argn, 'x', "use device with given vendor id", NULL },
+ { "product", 'a', POPT_ARG_INT, &options[CCO_Product].argn, 'a', "use device with given product id", NULL },
{ "invert", 'n', POPT_ARG_NONE, NULL, 'n', "invert bits for --pins command", NULL },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0, NULL, NULL }
@@ -558,6 +566,7 @@ int main(int argc, const char **argv) {
memset(&options, 0, sizeof(options));
options[CCO_DeviceId].argn = -1;
options[CCO_Vendor].argn = SAMSUNG_VENDOR;
+ options[CCO_Product].argn = PRODUCT;
if (parseArguments(argc, argv, &cmd, &arg, args, sizeof(args), options) != EXIT_SUCCESS) {
return EXIT_FAILURE;