serial-lcr: also request packets before initial state retrieval

Commit cb5cd1538f introduced packet request support in the serial-lcr
device driver. Calls were added to the detection of the device's
presence, and the periodic acquisition of measurement data. Add another
call to the device configuration retrieval that follows the presence
detection, without it communication timed out with no data received.

Also slightly raise the timeout for this device configuration gathering
phase. With one second sharp, the VC4080 was detected, but getting its
current configuration kept failing. This device's serial communication
is extra slow (1200 bps) and the packets are rather large (39 bytes).
Which made the stream detect's receive routine stop checking for the
availability of more data while a packet was being received.
This commit is contained in:
Gerhard Sittig 2019-06-23 08:19:39 +02:00 committed by Uwe Hermann
parent c4d2e6fa5e
commit 66c300c4a6
1 changed files with 10 additions and 1 deletions

View File

@ -177,6 +177,15 @@ static int read_lcr_port(struct sr_dev_inst *sdi,
uint8_t buf[128]; uint8_t buf[128];
int ret; int ret;
serial_flush(serial);
if (lcr->packet_request) {
ret = lcr->packet_request(serial);
if (ret < 0) {
sr_err("Failed to request packet: %d.", ret);
return ret;
}
}
/* /*
* Receive a few more packets (and process them!) to have the * Receive a few more packets (and process them!) to have the
* current output frequency and circuit model parameter values * current output frequency and circuit model parameter values
@ -190,7 +199,7 @@ static int read_lcr_port(struct sr_dev_inst *sdi,
len = sizeof(buf); len = sizeof(buf);
scan_packet_check_setup(sdi); scan_packet_check_setup(sdi);
ret = serial_stream_detect(serial, buf, &len, ret = serial_stream_detect(serial, buf, &len,
lcr->packet_size, scan_packet_check_func, 1000); lcr->packet_size, scan_packet_check_func, 1500);
scan_packet_check_setup(NULL); scan_packet_check_setup(NULL);
return ret; return ret;