blob: 9291a71749a91e5cbba1c38686b4378d667db71e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk6dd652f2003-06-19 23:40:20 +00002/*
3 * (C) Copyright 2000
4 * Murray Jensen <Murray.Jensen@csiro.au>
wdenk6dd652f2003-06-19 23:40:20 +00005 */
6
wdenk3ba68652000-10-11 22:04:29 +00007#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
15char *serialdev = "/dev/term/b";
16speed_t speed = B230400;
17int verbose = 0;
18
19int
20main(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}