drivers/distance_sensor/lightware_laser_serial: add LW20/C support

This commit is contained in:
Jacob Dahl 2021-10-08 13:30:41 -08:00 committed by GitHub
parent 47dc2ae5a5
commit fd39d5b9a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -127,6 +127,13 @@ LightwareLaserSerial::init()
_simple_serial = true;
break;
case 8:
/* LW20/c (100M 20Hz) */
_px4_rangefinder.set_min_distance(0.2f);
_px4_rangefinder.set_max_distance(100.0f);
_interval = 50000;
break;
default:
PX4_ERR("invalid HW model %" PRIi32 ".", hw_model);
return -1;
@ -297,6 +304,12 @@ void LightwareLaserSerial::Run()
if ((termios_state = tcsetattr(_fd, TCSANOW, &uart_config)) < 0) {
PX4_ERR("baud %d ATTR", termios_state);
}
// LW20: Enable serial mode by sending some characters
if (hw_model == 8) {
const char *data = "www\r\n";
(void)!::write(_fd, &data, strlen(data));
}
}
/* collection phase? */

View File

@ -41,5 +41,8 @@
* @value 3 SF10/b
* @value 4 SF10/c
* @value 5 SF11/c
* @value 6 SF30/b
* @value 7 SF30/c
* @value 8 LW20/c
*/
PARAM_DEFINE_INT32(SENS_EN_SF0X, 1);