From d2a0c857edfc64d1b97ebd8965b7d1cfb0e182da Mon Sep 17 00:00:00 2001 From: Burak Han <44507545+bozkurthan@users.noreply.github.com> Date: Mon, 1 Apr 2019 09:25:23 +0300 Subject: [PATCH] sf0x.cpp: change baudrate to 115200 for SF11/C --- src/drivers/distance_sensor/sf0x/sf0x.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/drivers/distance_sensor/sf0x/sf0x.cpp b/src/drivers/distance_sensor/sf0x/sf0x.cpp index 0e60b8a0f9..5260987979 100644 --- a/src/drivers/distance_sensor/sf0x/sf0x.cpp +++ b/src/drivers/distance_sensor/sf0x/sf0x.cpp @@ -590,7 +590,19 @@ SF0X::cycle() /* no parity, one stop bit */ uart_config.c_cflag &= ~(CSTOPB | PARENB); - unsigned speed = B9600; + /* if distance sensor model is SF11/C, then set baudrate 115200, else 9600 */ + int hw_model; + + param_get(param_find("SENS_EN_SF0X"), &hw_model); + + unsigned speed; + + if (hw_model == 5) { + speed = B115200; + + } else { + speed = B9600; + } /* set baud rate */ if ((termios_state = cfsetispeed(&uart_config, speed)) < 0) {