FreeCalypso > hg > freecalypso-tools
annotate miscutil/fc-pulse-rts.c @ 964:a96cb97b66a2
ringtools/imy: fix duplicate definition of tdma_durations[]
The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>,
although the present fix is slightly different from the contributed
patch: because main.c doesn't need this tdma_durations[] array
at all, let's simply remove the reference to this array from main.c
rather than turn it into an extern.
I no longer remember my original thought flow that resulted (by mistake)
in tdma_durations[] being multiply defined in main.c and durations.c.
My intent might have been to define all globals in main.c and have
the reference in durations.c be an extern - and I missed that extern -
but without clear memory, I have no certainty. In any case, having
this data array defined in the same module that fills it (durations.c)
is sensible, so let's make it the new way.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 31 Aug 2023 19:38:18 +0000 |
parents | 5b8287c655cf |
children |
rev | line source |
---|---|
735
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This utility opens a serial port, asserts RTS for 50 ms, then negates it |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * and exits. It is intended for use with FreeCalypso DUART28C adapters. |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/file.h> |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <sys/ioctl.h> |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <unistd.h> |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 main(argc, argv) |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char **argv; |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 int target_fd; |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 int mctl_arg = TIOCM_RTS; |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (argc != 2) { |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 fprintf(stderr, "usage: %s ttyname\n", argv[0]); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 exit(1); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 target_fd = open(argv[1], O_RDWR|O_NONBLOCK); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (target_fd < 0) { |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 perror(argv[1]); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 ioctl(target_fd, TIOCMBIS, &mctl_arg); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 usleep(50000); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 ioctl(target_fd, TIOCMBIC, &mctl_arg); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 exit(0); |
5b8287c655cf
fc-pulse-dtr and fc-pulse-rts utilities implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |