pc/serial_xx: Change arguments for the open call.
This commit is contained in:
parent
a09104c281
commit
8fea3f6baa
|
@ -194,7 +194,9 @@ void platform_init(int argc, char **argv)
|
|||
libusb_strerror(res));
|
||||
exit(-1);
|
||||
}
|
||||
if (find_debuggers(&cl_opts, &info)) {
|
||||
if (cl_opts.opt_device) {
|
||||
info.bmp_type = BMP_TYPE_BMP;
|
||||
} else if (find_debuggers(&cl_opts, &info)) {
|
||||
exit(-1);
|
||||
}
|
||||
printf("Using %s %s %s\n", info.serial,
|
||||
|
|
|
@ -60,7 +60,7 @@ void platform_init(int argc, char **argv)
|
|||
printf("License GPLv3+: GNU GPL version 3 or later "
|
||||
"<http://gnu.org/licenses/gpl.html>\n\n");
|
||||
|
||||
if (serial_open(&cl_opts))
|
||||
if (serial_open(cl_opts.opt_device, cl_opts.opt_serial))
|
||||
exit(-1);
|
||||
int c=snprintf(construct,PLATFORM_MAX_MSG_SIZE,"%s",REMOTE_START_STR);
|
||||
platform_buffer_write((uint8_t *)construct,c);
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#if !defined(__CL_UTILS_H)
|
||||
#define __CL_UTILS_H
|
||||
|
||||
#define RESP_TIMEOUT (100)
|
||||
|
||||
enum bmp_cl_mode {
|
||||
BMP_MODE_DEBUG,
|
||||
BMP_MODE_TEST,
|
||||
|
@ -56,6 +58,6 @@ typedef struct BMP_CL_OPTIONS_s {
|
|||
extern int cl_debuglevel;
|
||||
void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv);
|
||||
int cl_execute(BMP_CL_OPTIONS_t *opt);
|
||||
int serial_open(BMP_CL_OPTIONS_t *opt);
|
||||
int serial_open(BMP_CL_OPTIONS_t *opt, char *serial);
|
||||
void serial_close(void);
|
||||
#endif
|
||||
|
|
|
@ -69,10 +69,10 @@ static int set_interface_attribs(void)
|
|||
}
|
||||
#define BMP_IDSTRING "usb-Black_Sphere_Technologies_Black_Magic_Probe"
|
||||
#define DEVICE_BY_ID "/dev/serial/by-id/"
|
||||
int serial_open(BMP_CL_OPTIONS_t *opt)
|
||||
int serial_open(BMP_CL_OPTIONS_t *cl_opts, char *serial)
|
||||
{
|
||||
char name[4096];
|
||||
if (!opt->opt_device) {
|
||||
if (!cl_opts->opt_device) {
|
||||
/* Try to find some BMP if0*/
|
||||
struct dirent *dp;
|
||||
DIR *dir = opendir(DEVICE_BY_ID);
|
||||
|
@ -86,8 +86,7 @@ int serial_open(BMP_CL_OPTIONS_t *opt)
|
|||
if ((strstr(dp->d_name, BMP_IDSTRING)) &&
|
||||
(strstr(dp->d_name, "-if00"))) {
|
||||
num_total++;
|
||||
if (((opt->opt_serial) &&
|
||||
(!strstr(dp->d_name, opt->opt_serial))))
|
||||
if ((serial) && (!strstr(dp->d_name, serial)))
|
||||
continue;
|
||||
num_devices++;
|
||||
strcpy(name, DEVICE_BY_ID);
|
||||
|
@ -108,8 +107,8 @@ int serial_open(BMP_CL_OPTIONS_t *opt)
|
|||
fprintf(stderr, "%s\n", dp->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
if (opt->opt_serial)
|
||||
fprintf(stderr, "Do no match given serial \"%s\"\n", opt->opt_serial);
|
||||
if (serial)
|
||||
fprintf(stderr, "Do no match given serial \"%s\"\n", serial);
|
||||
else
|
||||
fprintf(stderr, "Select Probe with -s <(Partial) Serial Number\n");
|
||||
} else {
|
||||
|
@ -118,7 +117,7 @@ int serial_open(BMP_CL_OPTIONS_t *opt)
|
|||
return -1;
|
||||
}
|
||||
} else {
|
||||
strncpy(name, opt->opt_device, sizeof(name) - 1);
|
||||
strncpy(name, cl_opts->opt_device, sizeof(name) - 1);
|
||||
}
|
||||
fd = open(name, O_RDWR | O_SYNC | O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
|
|
|
@ -25,18 +25,20 @@
|
|||
|
||||
HANDLE hComm;
|
||||
|
||||
int serial_open(BMP_CL_OPTIONS_t *opt)
|
||||
int serial_open(BMP_CL_OPTIONS_t *cl_opts, char * serial)
|
||||
{
|
||||
if (!opt->opt_device) {
|
||||
(void) serial; /* FIXME: Does Windows allow open with USB serial no? */
|
||||
if (!cl_opts->opt_device) {
|
||||
fprintf(stderr,"Specify the serial device to use!\n");
|
||||
return -1;
|
||||
}
|
||||
char device[256];
|
||||
if (strstr(opt->opt_device, "\\\\.\\")) {
|
||||
strncpy(device, opt->opt_device, sizeof(device) - 1);
|
||||
if (strstr(device, "\\\\.\\")) {
|
||||
strncpy(device, cl_opts->opt_device, sizeof(cl_opts->opt_device) - 1);
|
||||
} else {
|
||||
strcpy(device, "\\\\.\\");
|
||||
strncat(device, opt->opt_device, sizeof(device) - strlen(device) - 1);
|
||||
strncat(device, cl_opts->opt_device,
|
||||
sizeof(cl_opts->opt_device) - strlen(cl_opts->opt_device) - 1);
|
||||
}
|
||||
hComm = CreateFile(device, //port name
|
||||
GENERIC_READ | GENERIC_WRITE, //Read/Write
|
||||
|
|
Loading…
Reference in New Issue