From: Gerhard Sittig Date: Sun, 20 Sep 2020 07:23:45 +0000 (+0200) Subject: brymen-dmm: unbreak BM85x communication by pulsing RTS after COM port open X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=648f32d11966917a53caed2d2b640ea75de5c3dd;p=libsigrok.git brymen-dmm: unbreak BM85x communication by pulsing RTS after COM port open Either the Brymen meters in the BM850s series or their cables require an RTS pulse to wakeup, without it there won't be a response during scan or when requesting measurements. Follow the vendor's documented sequence for a low RTS pulse after opening the serial port and before communication to the device. This fixes bug #1595. Reported-By: Karl Palsson --- diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index ce6f1f33..230b6adf 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -41,6 +41,7 @@ static GSList *brymen_scan(struct sr_dev_driver *di, const char *conn, struct sr_dev_inst *sdi; struct dev_context *devc; struct sr_serial_dev_inst *serial; + int rts_toggle_delay_us; GSList *devices; int ret; uint8_t buf[128]; @@ -50,6 +51,21 @@ static GSList *brymen_scan(struct sr_dev_driver *di, const char *conn, if (serial_open(serial, SERIAL_RDWR) != SR_OK) return NULL; + /* + * The device requires an RTS *pulse* before communication. + * The vendor's documentation recommends the following sequence: + * Open the COM port, wait for 100ms, set RTS=1, wait for 100ms, + * set RTS=0, wait for 100ms, set RTS=1, configure bitrate and + * frame format, transmit request data, receive response data. + */ + rts_toggle_delay_us = 100 * 1000; /* 100ms */ + g_usleep(rts_toggle_delay_us); + serial_set_handshake(serial, 1, -1); + g_usleep(rts_toggle_delay_us); + serial_set_handshake(serial, 0, -1); + g_usleep(rts_toggle_delay_us); + serial_set_handshake(serial, 1, -1); + g_usleep(rts_toggle_delay_us); sr_info("Probing port %s.", conn);