12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- /*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
- #include <u.h>
- #include <libc.h>
- #include <thread.h>
- #include <usb/usb.h>
- #include <usb/usbfs.h>
- #include <usb/serial.h>
- #include <usb/ucons.h>
- #include <usb/prolific.h>
- #include <usb/ftdi.h>
- #include <usb/silabs.h>
- enum {
- Arglen = 80,
- };
- typedef struct Parg Parg;
- /* keep in sync with serial.c */
- static void
- usage(void)
- {
- fprint(2, "usage: %s [-dD] [-N nb] [-m mtpt] [-s srv] [dev...]\n", argv0);
- threadexitsall("usage");
- }
- static int
- matchserial(char *info, void*_)
- {
- if(uconsmatch(info) == 0 || plmatch(info) == 0 ||
- ftmatch(nil, info) == 0 || slmatch(info) == 0)
- return 0;
- return -1;
- }
- void
- threadmain(int argc, char **argv)
- {
- char *mnt, *srv, *as, *ae;
- char args[Arglen];
- mnt = "/dev";
- srv = nil;
- quotefmtinstall();
- ae = args + sizeof args;
- as = seprint(args, ae, "serial");
- ARGBEGIN{
- case 'D':
- usbfsdebug++;
- break;
- case 'd':
- usbdebug++;
- as = seprint(as, ae, " -d");
- break;
- case 'N':
- as = seprint(as, ae, " -N %s", EARGF(usage()));
- break;
- case 'm':
- mnt = EARGF(usage());
- break;
- case 's':
- srv = EARGF(usage());
- break;
- default:
- usage();
- break;
- }ARGEND;
- rfork(RFNOTEG);
- fmtinstall('U', Ufmt);
- threadsetgrp(threadid());
- usbfsinit(srv, mnt, &usbdirfs, MAFTER|MCREATE);
- startdevs(args, argv, argc, matchserial, nil, serialmain);
- threadexits(nil);
- }
|