summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2b57158)
The --wait option hangs around until a suitable device appears, so
that you can test a pile of µPusb devices without needing to
constantly interact with the command line.
Signed-off-by: Keith Packard <keithp@keithp.com>
static const struct option options[] = {
{ .name = "tty", .has_arg = 1, .val = 'T' },
{ .name = "device", .has_arg = 1, .val = 'D' },
static const struct option options[] = {
{ .name = "tty", .has_arg = 1, .val = 'T' },
{ .name = "device", .has_arg = 1, .val = 'D' },
+ { .name = "wait", .has_arg = 0, .val = 'w' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--tty <tty-name>] [--device <device-name>]\n", program);
+ fprintf(stderr, "usage: %s [--tty <tty-name>] [--device <device-name>] [--wait]\n", program);
static int find_header(struct cc_usb *cc)
{
for (;;) {
static int find_header(struct cc_usb *cc)
{
for (;;) {
- if (get_nonwhite(cc, 0) == 'M' && get_nonwhite(cc, 1000) == 'P')
+ if (get_nonwhite(cc, -1) == 'M' && get_nonwhite(cc, 1000) == 'P')
int i;
int crc;
int current_crc;
int i;
int crc;
int current_crc;
- while ((c = getopt_long(argc, argv, "T:D:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "wT:D:", options, NULL)) != -1) {
+ case 'w':
+ wait = 1;
+ break;
case 'T':
tty = optarg;
break;
case 'T':
tty = optarg;
break;
- if (!tty)
- tty = cc_usbdevs_find_by_arg(device, "FT230X Basic UART");
+ if (!tty) {
+ for (;;) {
+ tty = cc_usbdevs_find_by_arg(device, "FT230X Basic UART");
+ if (tty) {
+ if (wait) {
+ printf("tty is %s\n", tty);
+ sleep(1);
+ }
+ break;
+ }
+ if (!wait)
+ break;
+ sleep(1);
+ }
+ }
if (!tty)
tty = getenv("ALTOS_TTY");
if (!tty)
if (!tty)
tty = getenv("ALTOS_TTY");
if (!tty)
write(2, cc->in_buf, cc->in_count);
cc->in_count = 0;
}
write(2, cc->in_buf, cc->in_count);
cc->in_count = 0;
}
}
if (fds.revents & POLLOUT) {
ret = write(cc->fd, cc->out_buf,
}
if (fds.revents & POLLOUT) {
ret = write(cc->fd, cc->out_buf,