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