/* 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, 9600) != SR_OK)
+ appa_55ii_packet_valid, 500) != SR_OK)
goto scan_cleanup;
sr_info("Found device on port %s.", conn);
/* Let's get a bit of data and see if we can find a packet. */
len = sizeof(buf);
ret = serial_stream_detect(serial, buf, &len, scale->packet_size,
- scale->packet_valid, 3000, scale->baudrate);
+ scale->packet_valid, 3000);
if (ret != SR_OK)
goto scan_cleanup;
/* Let's get a bit of data and see if we can find a packet. */
len = sizeof(buf);
ret = serial_stream_detect(serial, buf, &len, dmm->packet_size,
- dmm->packet_valid, 3000,
- dmm->baudrate);
+ dmm->packet_valid, 3000);
if (ret != SR_OK)
goto scan_cleanup;
/* 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, 1200) != SR_OK)
+ teleinfo_packet_valid, 3000) != SR_OK)
goto scan_cleanup;
sr_info("Found device on port %s.", conn);
uint8_t *buf, size_t buflen,
size_t packet_size,
packet_valid_callback is_valid,
- uint64_t timeout_ms, int baudrate)
+ uint64_t timeout_ms)
{
size_t len, dropped;
int ret;
len = buflen;
ret = serial_stream_detect(serial, buf, &len, packet_size,
- is_valid, timeout_ms, baudrate);
+ is_valid, timeout_ms);
serial_close(serial);
static int serial_stream_check(struct sr_serial_dev_inst *serial,
size_t packet_size,
packet_valid_callback is_valid,
- uint64_t timeout_ms, int baudrate)
+ uint64_t timeout_ms)
{
uint8_t buf[128];
return serial_stream_check_buf(serial, buf, sizeof(buf), packet_size,
- is_valid, timeout_ms, baudrate);
+ is_valid, timeout_ms);
}
/*
if (!(serial = serial_dev_new(options, "9600/8n1/rts=1/dtr=1")))
goto scan_cleanup;
- ret = serial_stream_check(serial, PACKET_SIZE, packet_valid,
- 3000, 9600);
+ ret = serial_stream_check(serial, PACKET_SIZE, packet_valid, 3000);
if (ret != SR_OK)
goto scan_cleanup;
uint8_t *buf, size_t *buflen,
size_t packet_size,
packet_valid_callback is_valid,
- uint64_t timeout_ms, int baudrate);
+ uint64_t timeout_ms);
SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device,
const char **serial_options);
SR_PRIV int serial_source_add(struct sr_session *session,
* @param is_valid Callback that assesses whether the packet is valid or not.
* @param[in] timeout_ms The timeout after which, if no packet is detected, to
* abort scanning.
- * @param[in] baudrate The baudrate of the serial port. This parameter is not
- * critical, but it helps fine tune the serial port polling
- * delay.
*
* @retval SR_OK Valid packet was found within the given timeout.
* @retval SR_ERR Failure.
uint8_t *buf, size_t *buflen,
size_t packet_size,
packet_valid_callback is_valid,
- uint64_t timeout_ms, int baudrate)
+ uint64_t timeout_ms)
{
uint64_t start, time, byte_delay_us;
size_t ibuf, i, maxlen;
maxlen = *buflen;
- sr_dbg("Detecting packets on %s (timeout = %" PRIu64
- "ms, baudrate = %d).", serial->port, timeout_ms, baudrate);
+ sr_dbg("Detecting packets on %s (timeout = %" PRIu64 "ms).",
+ serial->port, timeout_ms);
- if (maxlen < (packet_size / 2) ) {
+ if (maxlen < (packet_size * 2) ) {
sr_err("Buffer size must be at least twice the packet size.");
return SR_ERR;
}
/* Assume 8n1 transmission. That is 10 bits for every byte. */
- byte_delay_us = 10 * ((1000 * 1000) / baudrate);
+ byte_delay_us = serial_timeout(serial, 1) * 1000;
start = g_get_monotonic_time();
i = ibuf = len = 0;