FreeCalypso > hg > freecalypso-sw
annotate loadtools/labaud.c @ 721:fc7158e1bda3
mm_fors.c compiles
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 04 Oct 2014 01:16:19 +0000 |
parents | 604648026e9c |
children |
rev | line source |
---|---|
52
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This module handles the switching of serial baud rates |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * in coordination with loadagent. |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <termios.h> |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <unistd.h> |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "baudrate.h" |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 extern int target_fd; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 extern struct baudrate *current_baud_rate; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 extern struct baudrate *find_baudrate_by_name(); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 loadagent_switch_baud(newbr) |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 struct baudrate *newbr; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 { |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 char *argv[3]; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 static char U = 'U'; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
53
604648026e9c
fc-xram: baud rate switching implemented per original intent
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
52
diff
changeset
|
22 printf("Switching loadagent communication to %s baud\n", newbr->name); |
52
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 argv[0] = "baud"; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 argv[1] = newbr->name; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 argv[2] = 0; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 tpinterf_make_cmd(argv); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 if (tpinterf_send_cmd() < 0) |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 return(-1); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 switch_baud_rate(newbr); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 usleep(150000); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 write(target_fd, &U, 1); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 return tpinterf_pass_output(1); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 cmd_baud(argc, argv) |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 char **argv; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 { |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 struct baudrate *br; |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 if (argc < 2) { |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 printf("Current baud rate is %s\n", current_baud_rate->name); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 return(0); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 } |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 br = find_baudrate_by_name(argv[1]); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 if (!br) |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 return(-1); /* error msg already printed */ |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 return loadagent_switch_baud(br); |
b015036286f3
fc-loadtool: fast-baud communication with loadagent implemented, works!
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 } |