]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Use a macro for receive_data() wrappers.
authorUwe Hermann <redacted>
Thu, 13 Dec 2012 00:19:17 +0000 (01:19 +0100)
committerUwe Hermann <redacted>
Thu, 13 Dec 2012 00:34:21 +0000 (01:34 +0100)
hardware/serial-dmm/api.c
hardware/serial-dmm/protocol.c
hardware/serial-dmm/protocol.h

index 52d5a8848a7b80cdcfcfc2a85b1fd0ccd881013b..3ecafd3bed4055da51d024c285e78c1414078254 100644 (file)
@@ -68,77 +68,77 @@ SR_PRIV struct dmm_info dmms[] = {
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                dmm_details_dt4000zc,
-               &digitek_dt4000zc_driver_info, digitek_dt4000zc_receive_data,
+               &digitek_dt4000zc_driver_info, receive_data_DIGITEK_DT4000ZC,
        },
        {
                "TekPower", "TP4000ZC", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                dmm_details_tp4000zc,
-               &tekpower_tp4000zc_driver_info, tekpower_tp4000zc_receive_data,
+               &tekpower_tp4000zc_driver_info, receive_data_TEKPOWER_TP4000ZC,
        },
        {
                "Metex", "ME-31", "600/7n2/rts=0/dtr=1", 600,
                METEX14_PACKET_SIZE, sr_metex14_packet_request,
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
-               &metex_me31_driver_info, metex_me31_receive_data,
+               &metex_me31_driver_info, receive_data_METEX_ME31,
        },
        {
                "Peaktech", "3410", "600/7n2/rts=0/dtr=1", 600,
                METEX14_PACKET_SIZE, sr_metex14_packet_request,
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
-               &peaktech_3410_driver_info, peaktech_3410_receive_data,
+               &peaktech_3410_driver_info, receive_data_PEAKTECH_3410,
        },
        {
                "MASTECH", "MAS345", "600/7n2/rts=0/dtr=1", 600,
                METEX14_PACKET_SIZE, sr_metex14_packet_request,
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
-               &mastech_mas345_driver_info, mastech_mas345_receive_data,
+               &mastech_mas345_driver_info, receive_data_MASTECH_MAS345,
        },
        {
                "V&A", "VA18B", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                dmm_details_va18b,
-               &va_va18b_driver_info, va_va18b_receive_data,
+               &va_va18b_driver_info, receive_data_VA_VA18B,
        },
        {
                "Metex", "M-3640D", "1200/7n2/rts=0/dtr=1", 1200,
                METEX14_PACKET_SIZE, sr_metex14_packet_request,
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
-               &metex_m3640d_driver_info, metex_m3640d_receive_data,
+               &metex_m3640d_driver_info, receive_data_METEX_M3640D,
        },
        {
                "PeakTech", "4370", "1200/7n2/rts=0/dtr=1", 1200,
                METEX14_PACKET_SIZE, sr_metex14_packet_request,
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
-               &peaktech_4370_driver_info, peaktech_4370_receive_data,
+               &peaktech_4370_driver_info, receive_data_PEAKTECH_4370,
        },
        {
                "PCE", "PCE-DM32", "2400/8n1", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                dmm_details_pce_dm32,
-               &pce_pce_dm32_driver_info, pce_pce_dm32_receive_data,
+               &pce_pce_dm32_driver_info, receive_data_PCE_PCE_DM32,
        },
        {
                "RadioShack", "22-168", "1200/7n2/rts=0/dtr=1", 1200,
                METEX14_PACKET_SIZE, sr_metex14_packet_request,
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
-               &radioshack_22_168_driver_info, radioshack_22_168_receive_data,
+               &radioshack_22_168_driver_info, receive_data_RADIOSHACK_22_168,
        },
        {
                "RadioShack", "22-812", "4800/8n1/rts=0/dtr=1", 4800,
                RS9LCD_PACKET_SIZE, NULL,
                sr_rs9lcd_packet_valid, sr_rs9lcd_parse,
                NULL,
-               &radioshack_22_812_driver_info, radioshack_22_812_receive_data,
+               &radioshack_22_812_driver_info, receive_data_RADIOSHACK_22_812,
        },
 };
 
index 5b6d8e264bf084d2b393633ebe40409eccd0ccd3..156f88dd1a38b1cb24170a0e330613bc58702c60 100644 (file)
@@ -185,68 +185,20 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
        return TRUE;
 }
 
-SR_PRIV int digitek_dt4000zc_receive_data(int fd, int revents, void *cb_data)
-{
-       struct fs9721_info info;
-       return receive_data(fd, revents, DIGITEK_DT4000ZC, &info, cb_data);
-}
-
-SR_PRIV int tekpower_tp4000zc_receive_data(int fd, int revents, void *cb_data)
-{
-       struct fs9721_info info;
-       return receive_data(fd, revents, TEKPOWER_TP4000ZC, &info, cb_data);
-}
-
-SR_PRIV int metex_me31_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, METEX_ME31, &info, cb_data);
-}
-
-SR_PRIV int peaktech_3410_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, PEAKTECH_3410, &info, cb_data);
-}
-
-SR_PRIV int mastech_mas345_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, MASTECH_MAS345, &info, cb_data);
-}
-
-SR_PRIV int va_va18b_receive_data(int fd, int revents, void *cb_data)
-{
-       struct fs9721_info info;
-       return receive_data(fd, revents, VA_VA18B, &info, cb_data);
-}
-
-SR_PRIV int metex_m3640d_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, METEX_M3640D, &info, cb_data);
-}
-
-SR_PRIV int peaktech_4370_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, PEAKTECH_4370, &info, cb_data);
-}
-
-SR_PRIV int pce_pce_dm32_receive_data(int fd, int revents, void *cb_data)
-{
-       struct fs9721_info info;
-       return receive_data(fd, revents, PCE_PCE_DM32, &info, cb_data);
-}
-
-SR_PRIV int radioshack_22_168_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, RADIOSHACK_22_168, &info, cb_data);
-}
-
-SR_PRIV int radioshack_22_812_receive_data(int fd, int revents, void *cb_data)
-{
-       struct metex14_info info;
-       return receive_data(fd, revents, RADIOSHACK_22_812, &info, cb_data);
-}
+#define RECV_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, metex14)
index c0573e8f06745e63c48d5c186633e7a64530fd3d..77f89c741defe2ab3bf4fdc59925d7af5e67ade7 100644 (file)
@@ -83,17 +83,17 @@ struct dev_context {
        int buflen;
 };
 
-SR_PRIV int digitek_dt4000zc_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int tekpower_tp4000zc_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int metex_me31_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int peaktech_3410_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int mastech_mas345_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int va_va18b_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int metex_m3640d_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int peaktech_4370_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int pce_pce_dm32_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int radioshack_22_168_receive_data(int fd, int revents, void *cb_data);
-SR_PRIV int radioshack_22_812_receive_data(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_DIGITEK_DT4000ZC(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_TEKPOWER_TP4000ZC(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_METEX_ME31(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_PEAKTECH_3410(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_MASTECH_MAS345(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_VA_VA18B(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_METEX_M3640D(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_PEAKTECH_4370(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_PCE_PCE_DM32(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_RADIOSHACK_22_168(int fd, int revents, void *cb_data);
+SR_PRIV int receive_data_RADIOSHACK_22_812(int fd, int revents, void *cb_data);
 
 SR_PRIV void dmm_details_tp4000zc(struct sr_datafeed_analog *analog, void *info);
 SR_PRIV void dmm_details_dt4000zc(struct sr_datafeed_analog *analog, void *info);