1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <unistd.h>
28#include "serial.h"
29#include "error.h"
30#include "remote.h"
31
32char *serialdev = "/dev/term/b";
33speed_t speed = B230400;
34int verbose = 0;
35
36int
37main(int ac, char **av)
38{
39 int c, sfd;
40
41 if ((pname = strrchr(av[0], '/')) == NULL)
42 pname = av[0];
43 else
44 pname++;
45
46 while ((c = getopt(ac, av, "b:p:v")) != EOF)
47 switch (c) {
48
49 case 'b':
50 if ((speed = cvtspeed(optarg)) == B0)
51 Error("can't decode baud rate specified in -b option");
52 break;
53
54 case 'p':
55 serialdev = optarg;
56 break;
57
58 case 'v':
59 verbose = 1;
60 break;
61
62 default:
63 usage:
64 fprintf(stderr, "Usage: %s [-b bps] [-p dev] [-v]\n", pname);
65 exit(1);
66 }
67 if (optind != ac)
68 goto usage;
69
70 if (verbose)
71 fprintf(stderr, "Opening serial port and sending continue...\n");
72
73 if ((sfd = serialopen(serialdev, speed)) < 0)
74 Perror("open of serial device '%s' failed", serialdev);
75
76 remote_desc = sfd;
77 remote_reset();
78 remote_continue();
79
80 if (serialclose(sfd) < 0)
81 Perror("close of serial device '%s' failed", serialdev);
82
83 if (verbose)
84 fprintf(stderr, "Done.\n");
85
86 return (0);
87}
88