wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Murray Jensen <Murray.Jensen@csiro.au> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
wdenk | 3ba6865 | 2000-10-11 22:04:29 +0000 | [diff] [blame] | 8 | #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 | |
| 16 | char *serialdev = "/dev/term/b"; |
| 17 | speed_t speed = B230400; |
| 18 | int verbose = 0; |
| 19 | |
| 20 | int |
| 21 | main(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 | } |