X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fhardware%2Fserial-lcr%2Fapi.c;h=7f3fc5362ae1b980991857be4b88d7d66d2be0ad;hp=50b3f49361ef3db95334f62d6c8ca65796e87e77;hb=1a7adeac29d6331b53a2c78fc9c70429b32da0bd;hpb=c4d2e6fa5ee4f238afc6a91df9c0362281b213ce diff --git a/src/hardware/serial-lcr/api.c b/src/hardware/serial-lcr/api.c index 50b3f493..7f3fc536 100644 --- a/src/hardware/serial-lcr/api.c +++ b/src/hardware/serial-lcr/api.c @@ -38,7 +38,7 @@ static const uint32_t drvopts[] = { static const uint32_t devopts[] = { SR_CONF_CONTINUOUS, - SR_CONF_LIMIT_FRAMES | SR_CONF_SET, + SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_SET, SR_CONF_OUTPUT_FREQUENCY | SR_CONF_GET | SR_CONF_LIST, SR_CONF_EQUIV_CIRCUIT_MODEL | SR_CONF_GET | SR_CONF_LIST, @@ -105,7 +105,6 @@ static int scan_lcr_port(const struct lcr_info *lcr, * send data periodically. So we check if the packets match the * probed device's expected format. */ - serial_flush(serial); if (lcr->packet_request) { ret = lcr->packet_request(serial); if (ret < 0) { @@ -115,7 +114,7 @@ static int scan_lcr_port(const struct lcr_info *lcr, } len = sizeof(buf); ret = serial_stream_detect(serial, buf, &len, - lcr->packet_size, lcr->packet_valid, 3000); + lcr->packet_size, lcr->packet_valid, NULL, NULL, 3000); if (ret != SR_OK) goto scan_port_cleanup; @@ -177,6 +176,15 @@ static int read_lcr_port(struct sr_dev_inst *sdi, uint8_t buf[128]; 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 * current output frequency and circuit model parameter values @@ -190,7 +198,7 @@ static int read_lcr_port(struct sr_dev_inst *sdi, len = sizeof(buf); scan_packet_check_setup(sdi); ret = serial_stream_detect(serial, buf, &len, - lcr->packet_size, scan_packet_check_func, 1000); + lcr->packet_size, scan_packet_check_func, NULL, NULL, 1500); scan_packet_check_setup(NULL); return ret; @@ -390,3 +398,36 @@ SR_REGISTER_DEV_DRIVER_LIST(lcr_es51919_drivers, LCR_ES51919("peaktech-2170", "PeakTech", "2170"), LCR_ES51919("uni-t-ut612", "UNI-T", "UT612"), ); + +#define LCR_VC4080(id, vendor, model) \ + &((struct lcr_info) { \ + { \ + .name = id, \ + .longname = vendor " " model, \ + .api_version = 1, \ + .init = std_init, \ + .cleanup = std_cleanup, \ + .scan = scan, \ + .dev_list = std_dev_list, \ + .dev_clear = std_dev_clear, \ + .config_get = config_get, \ + .config_set = config_set, \ + .config_list = config_list, \ + .dev_open = std_serial_dev_open, \ + .dev_close = std_serial_dev_close, \ + .dev_acquisition_start = dev_acquisition_start, \ + .dev_acquisition_stop = std_serial_dev_acquisition_stop, \ + .context = NULL, \ + }, \ + vendor, model, \ + VC4080_CHANNEL_COUNT, vc4080_channel_formats, \ + VC4080_COMM_PARAM, VC4080_PACKET_SIZE, \ + 500, vc4080_packet_request, \ + vc4080_packet_valid, vc4080_packet_parse, \ + NULL, NULL, vc4080_config_list, \ + }).di + +SR_REGISTER_DEV_DRIVER_LIST(lcr_vc4080_drivers, + LCR_VC4080("peaktech-2165", "PeakTech", "2165"), + LCR_VC4080("voltcraft-4080", "Voltcraft", "4080"), +);