serial-dmm: Cosmetics, documentation fixes.

This commit is contained in:
Uwe Hermann 2012-12-16 21:23:49 +01:00
parent 6aed917b13
commit 22f5419235
2 changed files with 26 additions and 26 deletions

View File

@ -19,12 +19,12 @@
* 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"
@ -203,21 +203,12 @@ static GSList *scan(const char *conn, const char *serialcomm, int dmm)
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) {
@ -226,6 +217,14 @@ static GSList *scan(const char *conn, const char *serialcomm, int dmm)
}
}
/*
* 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);
@ -236,8 +235,8 @@ static GSList *scan(const char *conn, const char *serialcomm, int dmm)
* 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)

View File

@ -18,11 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include "protocol.h"
@ -105,6 +105,7 @@ static void handle_packet(const uint8_t *buf, struct dev_context *devc,
dmms[dmm].packet_parse(buf, &floatval, analog, info);
analog->data = &floatval;
/* If this DMM needs additional handling, call the resp. function. */
if (dmms[dmm].dmm_details)
dmms[dmm].dmm_details(analog, info);
@ -185,20 +186,20 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
return TRUE;
}
#define RECV_DATA(ID_UPPER, DMM_DRIVER) \
#define RECEIVE_DATA(ID_UPPER, DMM_DRIVER) \
SR_PRIV int receive_data_##ID_UPPER(int fd, int revents, void *cb_data) { \
struct DMM_DRIVER##_info info; \
return receive_data(fd, revents, ID_UPPER, &info, cb_data); }
/* Driver-specific receive_data() wrappers */
RECV_DATA(DIGITEK_DT4000ZC, fs9721)
RECV_DATA(TEKPOWER_TP4000ZC, fs9721)
RECV_DATA(METEX_ME31, metex14)
RECV_DATA(PEAKTECH_3410, metex14)
RECV_DATA(MASTECH_MAS345, metex14)
RECV_DATA(VA_VA18B, fs9721)
RECV_DATA(METEX_M3640D, metex14)
RECV_DATA(PEAKTECH_4370, metex14)
RECV_DATA(PCE_PCE_DM32, fs9721)
RECV_DATA(RADIOSHACK_22_168, metex14)
RECV_DATA(RADIOSHACK_22_812, rs9lcd)
RECEIVE_DATA(DIGITEK_DT4000ZC, fs9721)
RECEIVE_DATA(TEKPOWER_TP4000ZC, fs9721)
RECEIVE_DATA(METEX_ME31, metex14)
RECEIVE_DATA(PEAKTECH_3410, metex14)
RECEIVE_DATA(MASTECH_MAS345, metex14)
RECEIVE_DATA(VA_VA18B, fs9721)
RECEIVE_DATA(METEX_M3640D, metex14)
RECEIVE_DATA(PEAKTECH_4370, metex14)
RECEIVE_DATA(PCE_PCE_DM32, fs9721)
RECEIVE_DATA(RADIOSHACK_22_168, metex14)
RECEIVE_DATA(RADIOSHACK_22_812, rs9lcd)