diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2016-11-15 18:54:02 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2016-11-15 18:54:02 +0100 |
commit | ab5792d49cd47a9a0967dd94e41eecd30f230e7c (patch) | |
tree | 28dad26a4819eb1e96576665bc15a140654f5299 /tools/btattach.c | |
parent | 4a8c33b1f76edf2dfe33b9956014cc2746ae71d8 (diff) | |
download | bluez-ab5792d49cd47a9a0967dd94e41eecd30f230e7c.tar.gz |
tools: Add option to not set flow control for btattach
Diffstat (limited to 'tools/btattach.c')
-rw-r--r-- | tools/btattach.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/tools/btattach.c b/tools/btattach.c index 9d1868a04..5adbc8d83 100644 --- a/tools/btattach.c +++ b/tools/btattach.c @@ -49,7 +49,7 @@ #include "src/shared/tty.h" #include "src/shared/hci.h" -static int open_serial(const char *path, unsigned int speed) +static int open_serial(const char *path, unsigned int speed, bool flowctl) { struct termios ti; int fd, saved_ldisc, ldisc = N_HCI; @@ -78,8 +78,10 @@ static int open_serial(const char *path, unsigned int speed) ti.c_cflag |= (speed | CLOCAL | CREAD); - /* Set flow control */ - ti.c_cflag |= CRTSCTS; + if (flowctl) { + /* Set flow control */ + ti.c_cflag |= CRTSCTS; + } if (tcsetattr(fd, TCSANOW, &ti) < 0) { perror("Failed to set serial port settings"); @@ -107,11 +109,11 @@ static void local_version_callback(const void *data, uint8_t size, } static int attach_proto(const char *path, unsigned int proto, - unsigned int speed, unsigned int flags) + unsigned int speed, bool flowctl, unsigned int flags) { int fd, dev_id; - fd = open_serial(path, speed); + fd = open_serial(path, speed, flowctl); if (fd < 0) return -1; @@ -191,6 +193,7 @@ static void usage(void) "\t-A, --amp <device> Attach AMP controller\n" "\t-P, --protocol <proto> Specify protocol type\n" "\t-S, --speed <baudrate> Specify which baudrate to use\n" + "\t-N, --noflowctl Disable flow control\n" "\t-h, --help Show help options\n"); } @@ -199,6 +202,7 @@ static const struct option main_options[] = { { "amp", required_argument, NULL, 'A' }, { "protocol", required_argument, NULL, 'P' }, { "speed", required_argument, NULL, 'S' }, + { "noflowctl",no_argument, NULL, 'N' }, { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { } @@ -226,7 +230,7 @@ static const struct { int main(int argc, char *argv[]) { const char *bredr_path = NULL, *amp_path = NULL, *proto = NULL; - bool raw_device = false; + bool flowctl = true, raw_device = false; sigset_t mask; int exit_status, count = 0, proto_id = HCI_UART_H4; unsigned int speed = B115200; @@ -234,7 +238,7 @@ int main(int argc, char *argv[]) for (;;) { int opt; - opt = getopt_long(argc, argv, "B:A:P:S:Rvh", + opt = getopt_long(argc, argv, "B:A:P:S:NRvh", main_options, NULL); if (opt < 0) break; @@ -256,6 +260,9 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } break; + case 'N': + flowctl = false; + break; case 'R': raw_device = true; break; @@ -310,7 +317,7 @@ int main(int argc, char *argv[]) if (raw_device) flags = (1 << HCI_UART_RAW_DEVICE); - fd = attach_proto(bredr_path, proto_id, speed, flags); + fd = attach_proto(bredr_path, proto_id, speed, flowctl, flags); if (fd >= 0) { mainloop_add_fd(fd, 0, uart_callback, NULL, NULL); count++; @@ -329,7 +336,7 @@ int main(int argc, char *argv[]) if (raw_device) flags = (1 << HCI_UART_RAW_DEVICE); - fd = attach_proto(amp_path, proto_id, speed, flags); + fd = attach_proto(amp_path, proto_id, speed, flowctl, flags); if (fd >= 0) { mainloop_add_fd(fd, 0, uart_callback, NULL, NULL); count++; |