diff --git a/monitor/control.c b/monitor/control.c
index 95df980..f9a0b53 100644
--- a/monitor/control.c
+++ b/monitor/control.c
}
}
-void control_tty(const char *path)
+static unsigned int get_speed(unsigned int speed)
+{
+ switch (speed) {
+ case 57600:
+ return B57600;
+ case 115200:
+ return B115200;
+ case 230400:
+ return B230400;
+ case 460800:
+ return B460800;
+ case 500000:
+ return B500000;
+ case 576000:
+ return B576000;
+ case 921600:
+ return B921600;
+ case 1000000:
+ return B1000000;
+ case 1152000:
+ return B1152000;
+ case 1500000:
+ return B1500000;
+ case 2000000:
+ return B2000000;
+#ifdef B2500000
+ case 2500000:
+ return B2500000;
+#endif
+#ifdef B3000000
+ case 3000000:
+ return B3000000;
+#endif
+#ifdef B3500000
+ case 3500000:
+ return B3500000;
+#endif
+#ifdef B3710000
+ case 3710000:
+ return B3710000;
+#endif
+#ifdef B4000000
+ case 4000000:
+ return B4000000;
+#endif
+ default:
+ fprintf(stderr, "Unsupported speed. Using 115200.\n");
+ return B115200;
+ }
+
+ return 0;
+}
+
+void control_tty(const char *path, unsigned int speed)
{
struct control_data *data;
struct termios ti;
ti.c_cflag |= (CLOCAL | CREAD);
ti.c_cflag &= ~CRTSCTS;
- cfsetspeed(&ti, B115200);
+ cfsetspeed(&ti, get_speed(speed));
if (tcsetattr(fd, TCSANOW, &ti) < 0) {
perror("Failed to set serial port settings");
diff --git a/monitor/control.h b/monitor/control.h
index f37d9cd..601a45f 100644
--- a/monitor/control.h
+++ b/monitor/control.h
bool control_writer(const char *path);
void control_reader(const char *path);
void control_server(const char *path);
-void control_tty(const char *path);
+void control_tty(const char *path, unsigned int speed);
int control_tracing(void);
void control_message(uint16_t opcode, const void *data, uint16_t size);
diff --git a/monitor/main.c b/monitor/main.c
index e124157..38e4fc9 100644
--- a/monitor/main.c
+++ b/monitor/main.c
"\t-p, --priority <level> Show only priority or lower\n"
"\t-i, --index <num> Show only specified controller\n"
"\t-d, --tty <tty> Read data from TTY\n"
+ "\t-B, --tty-speed <rate> Set TTY speed (default 115200)\n"
"\t-t, --time Show time instead of time offset\n"
"\t-T, --date Show time and date information\n"
"\t-S, --sco Dump SCO traffic\n"
static const struct option main_options[] = {
{ "tty", required_argument, NULL, 'd' },
+ { "tty-speed", required_argument, NULL, 'B' },
{ "read", required_argument, NULL, 'r' },
{ "write", required_argument, NULL, 'w' },
{ "analyze", required_argument, NULL, 'a' },
const char *writer_path = NULL;
const char *analyze_path = NULL;
const char *ellisys_server = NULL;
+ const char *tty = NULL;
+ unsigned int tty_speed = 115200;
unsigned short ellisys_port = 0;
const char *str;
int exit_status;
switch (opt) {
case 'd':
- control_tty(optarg);
+ tty= optarg;
+ break;
+ case 'B':
+ tty_speed = atoi(optarg);
break;
case 'r':
reader_path = optarg;
if (ellisys_server)
ellisys_enable(ellisys_server, ellisys_port);
+ if (tty)
+ control_tty(tty, tty_speed);
+
if (control_tracing() < 0)
return EXIT_FAILURE;