From f186c46ff61cc36d18061bd570276d9df1abaf67 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 29 Jan 2009 08:45:19 +0000 Subject: [PATCH] bs11_config: add setting of baud rate --- src/bs11_config.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bs11_config.c b/src/bs11_config.c index 1aed28986..e05c609ae 100644 --- a/src/bs11_config.c +++ b/src/bs11_config.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -179,8 +180,10 @@ static struct msgb *serial_read_msg(void) sizeof(struct abis_om_hdr)) fprintf(stderr, "Invalied header byte 1(len): %u\n", msg->data[1]); + printf("length = %u\n", msg->data[1]); while (msg->len < 2 + msg->data[1]) { + printf("msg->len(%u), waiting for %u\n", msg->len, 2 + msg->data[1] - msg->len); rc = read(serial_fd, msg->tail, 2 + msg->data[1] - msg->len); if (rc < 0) { perror("reading from serial port"); @@ -319,6 +322,8 @@ static void handle_options(int argc, char **argv) int main(int argc, char **argv) { struct gsm_network *gsmnet; + struct termios tio; + int rc; handle_options(argc, argv); @@ -328,7 +333,20 @@ int main(int argc, char **argv) exit(1); } - /* FIXME: set baudrate */ + /* set baudrate */ + rc = tcgetattr(serial_fd, &tio); + if (rc < 0) { + perror("tcgetattr()"); + exit(1); + } + cfsetispeed(&tio, B19200); + cfsetospeed(&tio, B19200); + tio.c_cflag |= CREAD | CLOCAL; + rc = tcsetattr(serial_fd, TCSADRAIN, &tio); + if (rc < 0) { + perror("tcsetattr()"); + exit(1); + } gsmnet = gsm_network_init(1, 1, 1); if (!gsmnet) { @@ -343,7 +361,7 @@ int main(int argc, char **argv) struct msgb *rx_msg; struct abis_om_hdr *oh; struct abis_om_fom_hdr *foh; - int rc = -1; + rc = -1; rx_msg = serial_read_msg();