comparison loadtools/labaud.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children 8c011177adb9
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
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 printf("Switching loadagent communication to %s baud\n", newbr->name);
23 argv[0] = "baud";
24 argv[1] = newbr->name;
25 argv[2] = 0;
26 tpinterf_make_cmd(argv);
27 if (tpinterf_send_cmd() < 0)
28 return(-1);
29 switch_baud_rate(newbr);
30 usleep(150000);
31 write(target_fd, &U, 1);
32 return tpinterf_pass_output(1);
33 }
34
35 cmd_baud(argc, argv)
36 char **argv;
37 {
38 struct baudrate *br;
39
40 if (argc < 2) {
41 printf("Current baud rate is %s\n", current_baud_rate->name);
42 return(0);
43 }
44 br = find_baudrate_by_name(argv[1]);
45 if (!br)
46 return(-1); /* error msg already printed */
47 return loadagent_switch_baud(br);
48 }