* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
+#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include "protocol.h"
if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
return NULL;
- sr_info("Probing port %s.", conn);
+ sr_info("Probing serial port %s.", conn);
drvc = dmms[dmm].di->priv;
devices = NULL;
serial_flush(serial);
- /*
- * There's no way to get an ID from the multimeter. It just sends data
- * periodically, so the best we can do is check if the packets match
- * the expected format.
- */
-
- /* Let's get a bit of data and see if we can find a packet. */
- len = sizeof(buf);
-
/* Request a packet if the DMM requires this. */
if (dmms[dmm].packet_request) {
if ((ret = dmms[dmm].packet_request(serial)) < 0) {
}
}
+ /*
+ * There's no way to get an ID from the multimeter. It just sends data
+ * periodically (or upon request), so the best we can do is check if
+ * the packets match the expected format.
+ */
+
+ /* 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, dmms[dmm].packet_size,
dmms[dmm].packet_valid, 1000,
dmms[dmm].baudrate);
* If we dropped more than two packets worth of data, something is
* wrong. We shouldn't quit however, since the dropped bytes might be
* just zeroes at the beginning of the stream. Those can occur as a
- * combination of the nonstandard cable that ships with this device and
- * the serial port or USB to serial adapter.
+ * combination of the nonstandard cable that ships with some devices
+ * and the serial port or USB to serial adapter.
*/
dropped = len - dmms[dmm].packet_size;
if (dropped > 2 * dmms[dmm].packet_size)
}
devc->serial = serial;
+ devc->subdriver = dmm;
sdi->priv = devc;
sdi->driver = dmms[dmm].di;
/* Poll every 50ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 50,
- dmms[sdi->driver->subdriver].receive_data, (void *)sdi);
+ dmms[devc->subdriver].receive_data, (void *)sdi);
return SR_OK;
}
.dev_acquisition_start = hw_dev_acquisition_start, \
.dev_acquisition_stop = hw_dev_acquisition_stop, \
.priv = NULL, \
- .subdriver = ID_UPPER, \
};
DRV(digitek_dt4000zc, DIGITEK_DT4000ZC, "digitek-dt4000zc", "Digitek DT4000ZC")