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