if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
if (serial_write_blocking(serial, "*IDN?\r\n", 7, SERIAL_WRITE_TIMEOUT_MS) < 7) {
sr_err("Unable to send identification string.");
return NULL;
sr_info("Probing serial port %s.", conn);
- serial_flush(serial);
-
/* Let's get a bit of data and see if we can find a packet. */
if (serial_stream_detect(serial, buf, &len, 25,
appa_55ii_packet_valid, 500) != SR_OK)
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
/*
* First stop potentially running monitoring and wait for 50ms before
* next command can be sent.
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
/* This is how the vendor software scans for hardware. */
memset(packet, 0, PACKET_SIZE);
packet[0] = 0xaa;
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
sr_info("Found device on port %s.", conn);
sdi = g_malloc0(sizeof(struct sr_dev_inst));
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
serial_close(serial);
sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn);
* Try to find message consisting of device code and several
* (at least 4) data bytes.
*/
+ serial_flush(serial);
for (bytecnt = 0; bytecnt < 100; bytecnt++) {
byte = read_byte(serial, timeout_us);
if ((byte == -1) || (timeout_us < g_get_monotonic_time()))
return NULL;
}
- serial_flush(serial);
-
model = scan_model_sm(serial);
/*
serialcomm = SERIALCOMM_1X_RS232;
g_free(serial->serialcomm);
serial->serialcomm = g_strdup(serialcomm);
- if (serial_set_paramstr(serial, serialcomm) == SR_OK) {
- serial_flush(serial);
+ if (serial_set_paramstr(serial, serialcomm) == SR_OK)
model = scan_model_sm(serial);
- }
}
if (model != METRAHIT_NONE) {
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
gpd_send_cmd(serial, "*IDN?\n");
if (gpd_receive_reply(serial, reply, sizeof(reply)) != SR_OK) {
sr_err("Device did not reply.");
sr_info("Probing serial port %s.", conn);
devices = NULL;
- serial_flush(serial);
sr_spew("Set O1 mode (continuous values, stable and unstable ones).");
if (serial_write_blocking(serial, "O1\r\n", 4, 0) < 0)
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
/* Get the device model. */
len = 0;
for (i = 0; models[i].id; i++) {
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
sr_info("Probing serial port %s.", conn);
/* Get the device model. */
sr_info("Probing serial port %s.", conn);
- serial_flush(serial);
-
/* Let's get a bit of data and see if we can find a packet. */
if (serial_stream_detect(serial, buf, &len, (2 * MASTECH_MS6514_FRAME_SIZE),
mastech_ms6514_packet_valid, 500) != SR_OK)
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
/* TODO: Query device type. */
// ret = mic_cmd_get_device_info(serial);
goto exit_err;
/* Query and verify model string. */
- serial_flush(serial);
if (lps_cmd_reply(buf, serial, "MODEL") != SR_OK)
return NULL;
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- serial_flush(serial);
-
buf = g_malloc(BUF_MAX);
snprintf(req, sizeof(req), "%s\r\n",
sr_info("Probing serial port %s.", conn);
devices = NULL;
- serial_flush(serial);
/* Request a packet if the DMM requires this. */
if (dmm->packet_request) {
* 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) {
sr_info("Probing serial port %s.", conn);
- serial_flush(serial);
-
/* Let's get a bit of data and see if we can find a packet. */
if (serial_stream_detect(serial, buf, &len, len,
teleinfo_packet_valid, 3000) != SR_OK)
devices = NULL;
serial = sr_serial_dev_inst_new(conn, serialcomm);
rc = serial_open(serial, SERIAL_RDWR);
- serial_flush(serial);
/* Cannot query/identify the device. Successful open shall suffice. */
serial_close(serial);
if (rc != SR_OK) {
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return SR_ERR;
- if (serial_flush(serial) != SR_OK)
- return SR_ERR;
-
return SR_OK;
}
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return SR_ERR;
- if (serial_flush(serial) != SR_OK)
- return SR_ERR;
-
sscpi->got_newline = FALSE;
return SR_OK;
if (ret != SR_OK)
return ret;
- if (serial->serialcomm)
- return serial_set_paramstr(serial, serial->serialcomm);
- else
- return SR_OK;
+ if (serial->serialcomm) {
+ ret = serial_set_paramstr(serial, serial->serialcomm);
+ if (ret != SR_OK)
+ return ret;
+ }
+
+ return serial_flush(serial);
}
/**