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