From: Martin Ling Date: Sat, 21 Mar 2015 09:07:49 +0000 (+0000) Subject: serial-dmm: Declare each meter type in only one place. X-Git-Tag: libsigrok-0.4.0~584 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bcbef5ed709a56e8cec3d7d0b5f73a00a4040984;p=libsigrok.git serial-dmm: Declare each meter type in only one place. --- diff --git a/src/drivers.c b/src/drivers.c index 0789b1f7..6eac4589 100644 --- a/src/drivers.c +++ b/src/drivers.c @@ -128,50 +128,7 @@ extern SR_PRIV struct sr_dev_driver saleae_logic16_driver_info; extern SR_PRIV struct sr_dev_driver scpi_pps_driver_info; #endif #ifdef HAVE_HW_SERIAL_DMM -extern SR_PRIV struct sr_dev_driver bbcgm_m2110_driver_info; -extern SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info; -extern SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info; -extern SR_PRIV struct sr_dev_driver metex_me31_driver_info; -extern SR_PRIV struct sr_dev_driver peaktech_3410_driver_info; -extern SR_PRIV struct sr_dev_driver mastech_mas345_driver_info; -extern SR_PRIV struct sr_dev_driver mastech_ms8250b_driver_info; -extern SR_PRIV struct sr_dev_driver va_va18b_driver_info; -extern SR_PRIV struct sr_dev_driver va_va40b_driver_info; -extern SR_PRIV struct sr_dev_driver metex_m3640d_driver_info; -extern SR_PRIV struct sr_dev_driver metex_m4650cr_driver_info; -extern SR_PRIV struct sr_dev_driver peaktech_4370_driver_info; -extern SR_PRIV struct sr_dev_driver pce_pce_dm32_driver_info; -extern SR_PRIV struct sr_dev_driver radioshack_22_168_driver_info; -extern SR_PRIV struct sr_dev_driver radioshack_22_805_driver_info; -extern SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info; -extern SR_PRIV struct sr_dev_driver tecpel_dmm_8061_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_m3650cr_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_m3650d_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_m4650cr_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc830_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc870_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc920_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc940_ser_driver_info; -extern SR_PRIV struct sr_dev_driver voltcraft_vc960_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut60a_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut60e_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut60g_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut61b_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut61c_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut61d_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut61e_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut71a_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut71b_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut71c_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut71d_ser_driver_info; -extern SR_PRIV struct sr_dev_driver uni_t_ut71e_ser_driver_info; -extern SR_PRIV struct sr_dev_driver iso_tech_idm103n_driver_info; -extern SR_PRIV struct sr_dev_driver tenma_72_7745_ser_driver_info; -extern SR_PRIV struct sr_dev_driver tenma_72_7750_ser_driver_info; -extern SR_PRIV struct sr_dev_driver brymen_bm25x_driver_info; +extern SR_PRIV struct sr_dev_driver *serial_dmm_drivers[]; #endif #ifdef HAVE_HW_SYSCLK_LWLA extern SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info; @@ -341,52 +298,7 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { (DRVS) {&scpi_pps_driver_info, NULL}, #endif #ifdef HAVE_HW_SERIAL_DMM - (DRVS) { - &bbcgm_m2110_driver_info, - &digitek_dt4000zc_driver_info, - &tekpower_tp4000zc_driver_info, - &metex_me31_driver_info, - &peaktech_3410_driver_info, - &mastech_mas345_driver_info, - &mastech_ms8250b_driver_info, - &va_va18b_driver_info, - &va_va40b_driver_info, - &metex_m3640d_driver_info, - &metex_m4650cr_driver_info, - &peaktech_4370_driver_info, - &pce_pce_dm32_driver_info, - &radioshack_22_168_driver_info, - &radioshack_22_805_driver_info, - &radioshack_22_812_driver_info, - &tecpel_dmm_8061_ser_driver_info, - &voltcraft_m3650cr_driver_info, - &voltcraft_m3650d_driver_info, - &voltcraft_m4650cr_driver_info, - &voltcraft_me42_driver_info, - &voltcraft_vc820_ser_driver_info, - &voltcraft_vc830_ser_driver_info, - &voltcraft_vc840_ser_driver_info, - &voltcraft_vc870_ser_driver_info, - &voltcraft_vc920_ser_driver_info, - &voltcraft_vc940_ser_driver_info, - &voltcraft_vc960_ser_driver_info, - &uni_t_ut60a_ser_driver_info, - &uni_t_ut60e_ser_driver_info, - &uni_t_ut60g_ser_driver_info, - &uni_t_ut61b_ser_driver_info, - &uni_t_ut61c_ser_driver_info, - &uni_t_ut61d_ser_driver_info, - &uni_t_ut61e_ser_driver_info, - &uni_t_ut71a_ser_driver_info, - &uni_t_ut71b_ser_driver_info, - &uni_t_ut71c_ser_driver_info, - &uni_t_ut71d_ser_driver_info, - &uni_t_ut71e_ser_driver_info, - &iso_tech_idm103n_driver_info, - &tenma_72_7745_ser_driver_info, - &tenma_72_7750_ser_driver_info, - &brymen_bm25x_driver_info, - NULL}, + serial_dmm_drivers, #endif #ifdef HAVE_HW_SYSCLK_LWLA (DRVS) {&sysclk_lwla_driver_info, NULL}, diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 5ab8eb9f..fb446de4 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -41,389 +41,48 @@ static const uint32_t devopts[] = { SR_CONF_LIMIT_MSEC | SR_CONF_SET, }; -SR_PRIV struct sr_dev_driver bbcgm_m2110_driver_info; -SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info; -SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info; -SR_PRIV struct sr_dev_driver metex_me31_driver_info; -SR_PRIV struct sr_dev_driver peaktech_3410_driver_info; -SR_PRIV struct sr_dev_driver mastech_mas345_driver_info; -SR_PRIV struct sr_dev_driver mastech_ms8250b_driver_info; -SR_PRIV struct sr_dev_driver va_va18b_driver_info; -SR_PRIV struct sr_dev_driver va_va40b_driver_info; -SR_PRIV struct sr_dev_driver metex_m3640d_driver_info; -SR_PRIV struct sr_dev_driver metex_m4650cr_driver_info; -SR_PRIV struct sr_dev_driver peaktech_4370_driver_info; -SR_PRIV struct sr_dev_driver pce_pce_dm32_driver_info; -SR_PRIV struct sr_dev_driver radioshack_22_168_driver_info; -SR_PRIV struct sr_dev_driver radioshack_22_805_driver_info; -SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info; -SR_PRIV struct sr_dev_driver tecpel_dmm_8061_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_m3650cr_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_m3650d_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_m4650cr_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc830_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc870_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc920_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc940_ser_driver_info; -SR_PRIV struct sr_dev_driver voltcraft_vc960_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut60a_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut60e_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut60g_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut61b_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut61c_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut61d_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut61e_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut71a_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut71b_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut71c_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut71d_ser_driver_info; -SR_PRIV struct sr_dev_driver uni_t_ut71e_ser_driver_info; -SR_PRIV struct sr_dev_driver iso_tech_idm103n_driver_info; -SR_PRIV struct sr_dev_driver tenma_72_7745_ser_driver_info; -SR_PRIV struct sr_dev_driver tenma_72_7750_ser_driver_info; -SR_PRIV struct sr_dev_driver brymen_bm25x_driver_info; - -SR_PRIV struct dmm_info dmms[] = { - { - "BBC Goertz Metrawatt", "M2110", "1200/7n2", 1200, - BBCGM_M2110_PACKET_SIZE, 0, 0, NULL, - sr_m2110_packet_valid, sr_m2110_parse, - NULL, - &bbcgm_m2110_driver_info, receive_data_BBCGM_M2110, - }, - { - "Digitek", "DT4000ZC", "2400/8n1/dtr=1", 2400, - FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_10_temp_c, - &digitek_dt4000zc_driver_info, receive_data_DIGITEK_DT4000ZC, - }, - { - "TekPower", "TP4000ZC", "2400/8n1/dtr=1", 2400, - FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_10_temp_c, - &tekpower_tp4000zc_driver_info, receive_data_TEKPOWER_TP4000ZC, - }, - { - "Metex", "ME-31", "600/7n2/rts=0/dtr=1", 600, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &metex_me31_driver_info, receive_data_METEX_ME31, - }, - { - "Peaktech", "3410", "600/7n2/rts=0/dtr=1", 600, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &peaktech_3410_driver_info, receive_data_PEAKTECH_3410, - }, - { - "MASTECH", "MAS345", "600/7n2/rts=0/dtr=1", 600, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &mastech_mas345_driver_info, receive_data_MASTECH_MAS345, - }, - { - "MASTECH", "MS8250B", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - NULL, - &mastech_ms8250b_driver_info, receive_data_MASTECH_MS8250B, - }, - { - "V&A", "VA18B", "2400/8n1", 2400, - FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_01_temp_c, - &va_va18b_driver_info, receive_data_VA_VA18B, - }, - { - "V&A", "VA40B", "2400/8n1", 2400, - FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_max_c_min, - &va_va40b_driver_info, receive_data_VA_VA40B, - }, - { - "Metex", "M-3640D", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &metex_m3640d_driver_info, receive_data_METEX_M3640D, - }, - { - "Metex", "M-4650CR", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &metex_m4650cr_driver_info, receive_data_METEX_M4650CR, - }, - { - "PeakTech", "4370", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &peaktech_4370_driver_info, receive_data_PEAKTECH_4370, - }, - { - "PCE", "PCE-DM32", "2400/8n1", 2400, - FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_01_10_temp_f_c, - &pce_pce_dm32_driver_info, receive_data_PCE_PCE_DM32, - }, - { - "RadioShack", "22-168", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &radioshack_22_168_driver_info, receive_data_RADIOSHACK_22_168, - }, - { - "RadioShack", "22-805", "600/7n2/rts=0/dtr=1", 600, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &radioshack_22_805_driver_info, receive_data_RADIOSHACK_22_805, - }, - { - "RadioShack", "22-812", "4800/8n1/rts=0/dtr=1", 4800, - RS9LCD_PACKET_SIZE, 0, 0, NULL, - sr_rs9lcd_packet_valid, sr_rs9lcd_parse, - NULL, - &radioshack_22_812_driver_info, receive_data_RADIOSHACK_22_812, - }, - { - "Tecpel", "DMM-8061 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_00_temp_c, - &tecpel_dmm_8061_ser_driver_info, - receive_data_TECPEL_DMM_8061_SER, - }, - { - "Voltcraft", "M-3650CR", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 150, 20, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &voltcraft_m3650cr_driver_info, receive_data_VOLTCRAFT_M3650CR, - }, - { - "Voltcraft", "M-3650D", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &voltcraft_m3650d_driver_info, receive_data_VOLTCRAFT_M3650D, - }, - { - "Voltcraft", "M-4650CR", "1200/7n2/rts=0/dtr=1", 1200, - METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &voltcraft_m4650cr_driver_info, receive_data_VOLTCRAFT_M4650CR, - }, - { - "Voltcraft", "ME-42", "600/7n2/rts=0/dtr=1", 600, - METEX14_PACKET_SIZE, 250, 60, sr_metex14_packet_request, - sr_metex14_packet_valid, sr_metex14_parse, - NULL, - &voltcraft_me42_driver_info, receive_data_VOLTCRAFT_ME42, - }, - { - "Voltcraft", "VC-820 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - NULL, - &voltcraft_vc820_ser_driver_info, - receive_data_VOLTCRAFT_VC820_SER, - }, - { - /* - * Note: The VC830 doesn't set the 'volt' and 'diode' bits of - * the FS9922 protocol. Instead, it only sets the user-defined - * bit "z1" to indicate "diode mode" and "voltage". - */ - "Voltcraft", "VC-830 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9922_PACKET_SIZE, 0, 0, NULL, - sr_fs9922_packet_valid, sr_fs9922_parse, - &sr_fs9922_z1_diode, - &voltcraft_vc830_ser_driver_info, - receive_data_VOLTCRAFT_VC830_SER, - }, - { - "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_00_temp_c, - &voltcraft_vc840_ser_driver_info, - receive_data_VOLTCRAFT_VC840_SER, - }, - { - "Voltcraft", "VC-870 (UT-D02 cable)", "9600/8n1/rts=0/dtr=1", - 9600, VC870_PACKET_SIZE, 0, 0, NULL, - sr_vc870_packet_valid, sr_vc870_parse, - NULL, - &voltcraft_vc870_ser_driver_info, receive_data_VOLTCRAFT_VC870_SER, - }, - { - "Voltcraft", "VC-920 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &voltcraft_vc920_ser_driver_info, - receive_data_VOLTCRAFT_VC920_SER, - }, - { - "Voltcraft", "VC-940 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &voltcraft_vc940_ser_driver_info, - receive_data_VOLTCRAFT_VC940_SER, - }, - { - "Voltcraft", "VC-960 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &voltcraft_vc960_ser_driver_info, - receive_data_VOLTCRAFT_VC960_SER, - }, - { - "UNI-T", "UT60A (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - NULL, - &uni_t_ut60a_ser_driver_info, - receive_data_UNI_T_UT60A_SER, - }, - { - "UNI-T", "UT60E (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_00_temp_c, - &uni_t_ut60e_ser_driver_info, - receive_data_UNI_T_UT60E_SER, - }, - { - /* Note: ES51986 baudrate is actually 19230! */ - "UNI-T", "UT60G (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", - 19200, ES519XX_11B_PACKET_SIZE, 0, 0, NULL, - sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse, - NULL, - &uni_t_ut60g_ser_driver_info, receive_data_UNI_T_UT60G_SER, - }, - { - "UNI-T", "UT61B (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9922_PACKET_SIZE, 0, 0, NULL, - sr_fs9922_packet_valid, sr_fs9922_parse, NULL, - &uni_t_ut61b_ser_driver_info, receive_data_UNI_T_UT61B_SER, - }, - { - "UNI-T", "UT61C (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9922_PACKET_SIZE, 0, 0, NULL, - sr_fs9922_packet_valid, sr_fs9922_parse, NULL, - &uni_t_ut61c_ser_driver_info, receive_data_UNI_T_UT61C_SER, - }, - { - "UNI-T", "UT61D (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9922_PACKET_SIZE, 0, 0, NULL, - sr_fs9922_packet_valid, sr_fs9922_parse, NULL, - &uni_t_ut61d_ser_driver_info, receive_data_UNI_T_UT61D_SER, - }, - { - /* Note: ES51922 baudrate is actually 19230! */ - "UNI-T", "UT61E (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", - 19200, ES519XX_14B_PACKET_SIZE, 0, 0, NULL, - sr_es519xx_19200_14b_packet_valid, sr_es519xx_19200_14b_parse, - NULL, - &uni_t_ut61e_ser_driver_info, receive_data_UNI_T_UT61E_SER, - }, - { - "UNI-T", "UT71A (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &uni_t_ut71a_ser_driver_info, receive_data_UNI_T_UT71A_SER, - }, - { - "UNI-T", "UT71B (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &uni_t_ut71b_ser_driver_info, receive_data_UNI_T_UT71B_SER, - }, - { - "UNI-T", "UT71C (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &uni_t_ut71c_ser_driver_info, receive_data_UNI_T_UT71C_SER, - }, - { - "UNI-T", "UT71D (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &uni_t_ut71d_ser_driver_info, receive_data_UNI_T_UT71D_SER, - }, - { - "UNI-T", "UT71E (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", - 2400, UT71X_PACKET_SIZE, 0, 0, NULL, - sr_ut71x_packet_valid, sr_ut71x_parse, NULL, - &uni_t_ut71e_ser_driver_info, receive_data_UNI_T_UT71E_SER, - }, - { - "ISO-TECH", "IDM103N", "2400/7o1/rts=0/dtr=1", - 2400, ES519XX_11B_PACKET_SIZE, 0, 0, NULL, - sr_es519xx_2400_11b_packet_valid, sr_es519xx_2400_11b_parse, - NULL, - &iso_tech_idm103n_driver_info, receive_data_ISO_TECH_IDM103N, - }, - { - "Tenma", "72-7745 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", - 2400, FS9721_PACKET_SIZE, 0, 0, NULL, - sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_00_temp_c, - &tenma_72_7745_ser_driver_info, receive_data_TENMA_72_7745_SER, - }, - { - /* Note: ES51986 baudrate is actually 19230! */ - "Tenma", "72-7750 (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", - 19200, ES519XX_11B_PACKET_SIZE, 0, 0, NULL, - sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse, - NULL, - &tenma_72_7750_ser_driver_info, receive_data_TENMA_72_7750_SER, - }, - { - "Brymen", "BM25x", "9600/8n1/rts=1/dtr=1", - 9600, BRYMEN_BM25X_PACKET_SIZE, 0, 0, NULL, - sr_brymen_bm25x_packet_valid, sr_brymen_bm25x_parse, - NULL, - &brymen_bm25x_driver_info, receive_data_BRYMEN_BM25X, - }, -}; - -static int dev_clear(int dmm) +static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear(dmms[dmm].di, NULL); + return std_dev_clear(di, NULL); } -static int init(struct sr_context *sr_ctx, int dmm) +static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { - return std_init(sr_ctx, dmms[dmm].di, LOG_PREFIX); + return std_init(sr_ctx, di, LOG_PREFIX); } -static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm) +static GSList *scan(struct sr_dev_driver *di, GSList *options) { + struct dmm_info *dmm = (struct dmm_info *) di; + struct sr_config *src; + GSList *l, *devices; + const char *conn, *serialcomm; struct sr_dev_inst *sdi; struct drv_context *drvc; struct dev_context *devc; struct sr_serial_dev_inst *serial; - GSList *devices; int dropped, ret; size_t len; uint8_t buf[128]; + conn = serialcomm = NULL; + for (l = options; l; l = l->next) { + src = l->data; + switch (src->key) { + case SR_CONF_CONN: + conn = g_variant_get_string(src->data, NULL); + break; + case SR_CONF_SERIALCOMM: + serialcomm = g_variant_get_string(src->data, NULL); + break; + } + } + if (!conn) + return NULL; + + if (!serialcomm) + serialcomm = dmm->conn; + serial = sr_serial_dev_inst_new(conn, serialcomm); if (serial_open(serial, SERIAL_RDWR) != SR_OK) @@ -431,13 +90,13 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm) sr_info("Probing serial port %s.", conn); - drvc = dmms[dmm].di->priv; + drvc = di->priv; devices = NULL; serial_flush(serial); /* Request a packet if the DMM requires this. */ - if (dmms[dmm].packet_request) { - if ((ret = dmms[dmm].packet_request(serial)) < 0) { + if (dmm->packet_request) { + if ((ret = dmm->packet_request(serial)) < 0) { sr_err("Failed to request packet: %d.", ret); return FALSE; } @@ -451,9 +110,9 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm) /* 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, 3000, - dmms[dmm].baudrate); + ret = serial_stream_detect(serial, buf, &len, dmm->packet_size, + dmm->packet_valid, 3000, + dmm->baudrate); if (ret != SR_OK) goto scan_cleanup; @@ -464,21 +123,21 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm) * 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) + dropped = len - dmm->packet_size; + if (dropped > 2 * dmm->packet_size) sr_warn("Had to drop too much data."); sr_info("Found device on port %s.", conn); sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; - sdi->vendor = g_strdup(dmms[dmm].vendor); - sdi->model = g_strdup(dmms[dmm].device); + sdi->vendor = g_strdup(dmm->vendor); + sdi->model = g_strdup(dmm->device); devc = g_malloc0(sizeof(struct dev_context)); sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial; sdi->priv = devc; - sdi->driver = dmms[dmm].di; + sdi->driver = di; sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1"); drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); @@ -489,46 +148,14 @@ scan_cleanup: return devices; } -static GSList *scan(GSList *options, int dmm) +static GSList *dev_list(const struct sr_dev_driver *di) { - struct sr_config *src; - GSList *l, *devices; - const char *conn, *serialcomm; - - conn = serialcomm = NULL; - for (l = options; l; l = l->next) { - src = l->data; - switch (src->key) { - case SR_CONF_CONN: - conn = g_variant_get_string(src->data, NULL); - break; - case SR_CONF_SERIALCOMM: - serialcomm = g_variant_get_string(src->data, NULL); - break; - } - } - if (!conn) - return NULL; - - if (serialcomm) { - /* Use the provided comm specs. */ - devices = sdmm_scan(conn, serialcomm, dmm); - } else { - /* Try the default. */ - devices = sdmm_scan(conn, dmms[dmm].conn, dmm); - } - - return devices; -} - -static GSList *dev_list(int dmm) -{ - return ((struct drv_context *)(dmms[dmm].di->priv))->instances; + return ((struct drv_context *)(di->priv))->instances; } -static int cleanup(int dmm) +static int cleanup(const struct sr_dev_driver *di) { - return dev_clear(dmm); + return dev_clear(di); } static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, @@ -586,8 +213,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data, int dmm) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_serial_dev_inst *serial; @@ -616,7 +242,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; serial_source_add(sdi->session, serial, G_IO_IN, 50, - dmms[dmm].receive_data, (void *)sdi); + receive_data, (void *)sdi); return SR_OK; } @@ -627,94 +253,335 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) sdi->conn, LOG_PREFIX); } -/* Driver-specific API function wrappers */ -#define HW_INIT(X) \ -static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \ - (void) di; return init(sr_ctx, X); } -#define HW_CLEANUP(X) \ -static int cleanup_##X(const struct sr_dev_driver *di) { \ - (void) di; return cleanup(X); } -#define HW_SCAN(X) \ -static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \ - (void) di; return scan(options, X); } -#define HW_DEV_LIST(X) \ -static GSList *dev_list_##X(const struct sr_dev_driver *di) { \ - (void) di; return dev_list(X); } -#define HW_DEV_CLEAR(X) \ -static int dev_clear_##X(const struct sr_dev_driver *di) { \ - (void) di; return dev_clear(X); } -#define HW_DEV_ACQUISITION_START(X) \ -static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ -void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } - -/* Driver structs and API function wrappers */ -#define DRV(ID, ID_UPPER, NAME, LONGNAME) \ -HW_INIT(ID_UPPER) \ -HW_CLEANUP(ID_UPPER) \ -HW_SCAN(ID_UPPER) \ -HW_DEV_LIST(ID_UPPER) \ -HW_DEV_CLEAR(ID_UPPER) \ -HW_DEV_ACQUISITION_START(ID_UPPER) \ -SR_PRIV struct sr_dev_driver ID##_driver_info = { \ - .name = NAME, \ - .longname = LONGNAME, \ - .api_version = 1, \ - .init = init_##ID_UPPER, \ - .cleanup = cleanup_##ID_UPPER, \ - .scan = scan_##ID_UPPER, \ - .dev_list = dev_list_##ID_UPPER, \ - .dev_clear = dev_clear_##ID_UPPER, \ - .config_get = NULL, \ - .config_set = config_set, \ - .config_list = config_list, \ - .dev_open = std_serial_dev_open, \ - .dev_close = std_serial_dev_close, \ - .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ - .dev_acquisition_stop = dev_acquisition_stop, \ - .priv = NULL, \ -}; +#define DMM(ID, CHIPSET, VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, \ + DELAY, REQUEST, VALID, PARSE, DETAILS) \ + &(struct dmm_info) { \ + { \ + .name = ID, \ + .longname = VENDOR " " MODEL, \ + .api_version = 1, \ + .init = init, \ + .cleanup = cleanup, \ + .scan = scan, \ + .dev_list = dev_list, \ + .dev_clear = dev_clear, \ + .config_get = NULL, \ + .config_set = config_set, \ + .config_list = config_list, \ + .dev_open = std_serial_dev_open, \ + .dev_close = std_serial_dev_close, \ + .dev_acquisition_start = dev_acquisition_start, \ + .dev_acquisition_stop = dev_acquisition_stop, \ + .priv = NULL, \ + }, \ + VENDOR, MODEL, CONN, BAUDRATE, PACKETSIZE, TIMEOUT, DELAY, \ + REQUEST, VALID, PARSE, DETAILS, sizeof(struct CHIPSET##_info) \ + } -DRV(bbcgm_m2110, BBCGM_M2110, "bbcgm-m2110", "BBC Goertz Metrawatt M2110") -DRV(digitek_dt4000zc, DIGITEK_DT4000ZC, "digitek-dt4000zc", "Digitek DT4000ZC") -DRV(tekpower_tp4000zc, TEKPOWER_TP4000ZC, "tekpower-tp4000zc", "TekPower TP4000ZC") -DRV(metex_me31, METEX_ME31, "metex-me31", "Metex ME-31") -DRV(peaktech_3410, PEAKTECH_3410, "peaktech-3410", "PeakTech 3410") -DRV(mastech_mas345, MASTECH_MAS345, "mastech-mas345", "MASTECH MAS345") -DRV(mastech_ms8250b, MASTECH_MS8250B, "mastech-ms8250b", "MASTECH MS8250B") -DRV(va_va18b, VA_VA18B, "va-va18b", "V&A VA18B") -DRV(va_va40b, VA_VA40B, "va-va40b", "V&A VA40B") -DRV(metex_m3640d, METEX_M3640D, "metex-m3640d", "Metex M-3640D") -DRV(metex_m4650cr, METEX_M4650CR, "metex-m4650cr", "Metex M-4650CR") -DRV(peaktech_4370, PEAKTECH_4370, "peaktech-4370", "PeakTech 4370") -DRV(pce_pce_dm32, PCE_PCE_DM32, "pce-pce-dm32", "PCE PCE-DM32") -DRV(radioshack_22_168, RADIOSHACK_22_168, "radioshack-22-168", "RadioShack 22-168") -DRV(radioshack_22_805, RADIOSHACK_22_805, "radioshack-22-805", "RadioShack 22-805") -DRV(radioshack_22_812, RADIOSHACK_22_812, "radioshack-22-812", "RadioShack 22-812") -DRV(tecpel_dmm_8061_ser, TECPEL_DMM_8061_SER, "tecpel-dmm-8061-ser", "Tecpel DMM-8061 (UT-D02 cable)") -DRV(voltcraft_m3650cr, VOLTCRAFT_M3650CR, "voltcraft-m3650cr", "Voltcraft M-3650CR") -DRV(voltcraft_m3650d, VOLTCRAFT_M3650D, "voltcraft-m3650d", "Voltcraft M-3650D") -DRV(voltcraft_m4650cr, VOLTCRAFT_M4650CR, "voltcraft-m4650cr", "Voltcraft M-4650CR") -DRV(voltcraft_me42, VOLTCRAFT_ME42, "voltcraft-me42", "Voltcraft ME-42") -DRV(voltcraft_vc820_ser, VOLTCRAFT_VC820_SER, "voltcraft-vc820-ser", "Voltcraft VC-820 (UT-D02 cable)") -DRV(voltcraft_vc830_ser, VOLTCRAFT_VC830_SER, "voltcraft-vc830-ser", "Voltcraft VC-830 (UT-D02 cable)") -DRV(voltcraft_vc840_ser, VOLTCRAFT_VC840_SER, "voltcraft-vc840-ser", "Voltcraft VC-840 (UT-D02 cable)") -DRV(voltcraft_vc870_ser, VOLTCRAFT_VC870_SER, "voltcraft-vc870-ser", "Voltcraft VC-870 (UT-D02 cable)") -DRV(voltcraft_vc920_ser, VOLTCRAFT_VC920_SER, "voltcraft-vc920-ser", "Voltcraft VC-920 (UT-D02 cable)") -DRV(voltcraft_vc940_ser, VOLTCRAFT_VC940_SER, "voltcraft-vc940-ser", "Voltcraft VC-940 (UT-D02 cable)") -DRV(voltcraft_vc960_ser, VOLTCRAFT_VC960_SER, "voltcraft-vc960-ser", "Voltcraft VC-960 (UT-D02 cable)") -DRV(uni_t_ut60a_ser, UNI_T_UT60A_SER, "uni-t-ut60a-ser", "UNI-T UT60A (UT-D02 cable)") -DRV(uni_t_ut60e_ser, UNI_T_UT60E_SER, "uni-t-ut60e-ser", "UNI-T UT60E (UT-D02 cable)") -DRV(uni_t_ut60g_ser, UNI_T_UT60G_SER, "uni-t-ut60g-ser", "UNI-T UT60G (UT-D02 cable)") -DRV(uni_t_ut61b_ser, UNI_T_UT61B_SER, "uni-t-ut61b-ser", "UNI-T UT61B (UT-D02 cable)") -DRV(uni_t_ut61c_ser, UNI_T_UT61C_SER, "uni-t-ut61c-ser", "UNI-T UT61C (UT-D02 cable)") -DRV(uni_t_ut61d_ser, UNI_T_UT61D_SER, "uni-t-ut61d-ser", "UNI-T UT61D (UT-D02 cable)") -DRV(uni_t_ut61e_ser, UNI_T_UT61E_SER, "uni-t-ut61e-ser", "UNI-T UT61E (UT-D02 cable)") -DRV(uni_t_ut71a_ser, UNI_T_UT71A_SER, "uni-t-ut71a-ser", "UNI-T UT71A (UT-D02 cable)") -DRV(uni_t_ut71b_ser, UNI_T_UT71B_SER, "uni-t-ut71b-ser", "UNI-T UT71B (UT-D02 cable)") -DRV(uni_t_ut71c_ser, UNI_T_UT71C_SER, "uni-t-ut71c-ser", "UNI-T UT71C (UT-D02 cable)") -DRV(uni_t_ut71d_ser, UNI_T_UT71D_SER, "uni-t-ut71d-ser", "UNI-T UT71D (UT-D02 cable)") -DRV(uni_t_ut71e_ser, UNI_T_UT71E_SER, "uni-t-ut71e-ser", "UNI-T UT71E (UT-D02 cable)") -DRV(iso_tech_idm103n, ISO_TECH_IDM103N, "iso-tech-idm103n", "ISO-TECH IDM103N") -DRV(tenma_72_7745_ser, TENMA_72_7745_SER, "tenma-72-7745-ser", "Tenma 72-7745 (UT-D02 cable)") -DRV(tenma_72_7750_ser, TENMA_72_7750_SER, "tenma-72-7750-ser", "Tenma 72-7750 (UT-D02 cable)") -DRV(brymen_bm25x, BRYMEN_BM25X, "brymen-bm25x", "Brymen BM25x") +SR_PRIV struct dmm_info *serial_dmm_drivers[] = { + DMM( + "bbcgm-2010", metex14, + "BBC Goertz Metrawatt", "M2110", "1200/7n2", 1200, + BBCGM_M2110_PACKET_SIZE, 0, 0, NULL, + sr_m2110_packet_valid, sr_m2110_parse, + NULL + ), + DMM( + "digitek-dt4000zc", fs9721, + "Digitek", "DT4000ZC", "2400/8n1/dtr=1", 2400, + FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_10_temp_c + ), + DMM( + "tekpower-tp4000ZC", fs9721, + "TekPower", "TP4000ZC", "2400/8n1/dtr=1", 2400, + FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_10_temp_c + ), + DMM( + "metex-me31", metex14, + "Metex", "ME-31", "600/7n2/rts=0/dtr=1", 600, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "peaktech-3410", metex14, + "Peaktech", "3410", "600/7n2/rts=0/dtr=1", 600, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "mastech-mas345", metex14, + "MASTECH", "MAS345", "600/7n2/rts=0/dtr=1", 600, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "mastech-ms8250b", fs9721, + "MASTECH", "MS8250B", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + NULL + ), + DMM( + "va-va18b", fs9721, + "V&A", "VA18B", "2400/8n1", 2400, + FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_01_temp_c + ), + DMM( + "va-va40b", fs9721, + "V&A", "VA40B", "2400/8n1", 2400, + FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_max_c_min + ), + DMM( + "metex-m3640d", metex14, + "Metex", "M-3640D", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "metex-m4650cr", metex14, + "Metex", "M-4650CR", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "peaktech-4370", metex14, + "PeakTech", "4370", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "pce-pce-dm32", fs9721, + "PCE", "PCE-DM32", "2400/8n1", 2400, + FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_01_10_temp_f_c + ), + DMM( + "radioshack-22-168", metex14, + "RadioShack", "22-168", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "radioshack-22-805", metex14, + "RadioShack", "22-805", "600/7n2/rts=0/dtr=1", 600, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "radioshack-22-812", rs9lcd, + "RadioShack", "22-812", "4800/8n1/rts=0/dtr=1", 4800, + RS9LCD_PACKET_SIZE, 0, 0, NULL, + sr_rs9lcd_packet_valid, sr_rs9lcd_parse, + NULL + ), + DMM( + "tecpel-dmm-8061-ser", fs9721, + "Tecpel", "DMM-8061 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_00_temp_c + ), + DMM( + "voltcraft-m3650cr", metex14, + "Voltcraft", "M-3650CR", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 150, 20, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "voltcraft-m3650d", metex14, + "Voltcraft", "M-3650D", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "voltcraft-m4650cr", metex14, + "Voltcraft", "M-4650CR", "1200/7n2/rts=0/dtr=1", 1200, + METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "voltcraft-me42", metex14, + "Voltcraft", "ME-42", "600/7n2/rts=0/dtr=1", 600, + METEX14_PACKET_SIZE, 250, 60, sr_metex14_packet_request, + sr_metex14_packet_valid, sr_metex14_parse, + NULL + ), + DMM( + "voltcraft-vc820-ser", fs9721, + "Voltcraft", "VC-820 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + NULL + ), + DMM( + /* + * Note: The VC830 doesn't set the 'volt' and 'diode' bits of + * the FS9922 protocol. Instead, it only sets the user-defined + * bit "z1" to indicate "diode mode" and "voltage". + */ + "voltcraft-vc830-ser", fs9922, + "Voltcraft", "VC-830 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9922_PACKET_SIZE, 0, 0, NULL, + sr_fs9922_packet_valid, sr_fs9922_parse, + &sr_fs9922_z1_diode + ), + DMM( + "voltcraft-vc840-ser", fs9721, + "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_00_temp_c + ), + DMM( + "voltcraft-vc870-ser", vc870, + "Voltcraft", "VC-870 (UT-D02 cable)", "9600/8n1/rts=0/dtr=1", + 9600, VC870_PACKET_SIZE, 0, 0, NULL, + sr_vc870_packet_valid, sr_vc870_parse, NULL + ), + DMM( + "voltcraft-vc920-ser", ut71x, + "Voltcraft", "VC-920 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "voltcraft-vc940-ser", ut71x, + "Voltcraft", "VC-940 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "voltcraft-vc960-ser", ut71x, + "Voltcraft", "VC-960 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "uni-t-ut60a-ser", fs9721, + "UNI-T", "UT60A (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + NULL + ), + DMM( + "uni-t-ut60e-ser", fs9721, + "UNI-T", "UT60E (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_00_temp_c + ), + DMM( + /* Note: ES51986 baudrate is actually 19230! */ + "uni-t-ut60g-ser", es519xx, + "UNI-T", "UT60G (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", + 19200, ES519XX_11B_PACKET_SIZE, 0, 0, NULL, + sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse, + NULL + ), + DMM( + "uni-t-ut61b-ser", fs9922, + "UNI-T", "UT61B (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9922_PACKET_SIZE, 0, 0, NULL, + sr_fs9922_packet_valid, sr_fs9922_parse, NULL + ), + DMM( + "uni-t-ut61c-ser", fs9922, + "UNI-T", "UT61C (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9922_PACKET_SIZE, 0, 0, NULL, + sr_fs9922_packet_valid, sr_fs9922_parse, NULL + ), + DMM( + "uni-t-ut61d-ser", fs9922, + "UNI-T", "UT61D (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9922_PACKET_SIZE, 0, 0, NULL, + sr_fs9922_packet_valid, sr_fs9922_parse, NULL + ), + DMM( + "uni-t-ut61e-ser", es519xx, + /* Note: ES51922 baudrate is actually 19230! */ + "UNI-T", "UT61E (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", + 19200, ES519XX_14B_PACKET_SIZE, 0, 0, NULL, + sr_es519xx_19200_14b_packet_valid, sr_es519xx_19200_14b_parse, + NULL + ), + DMM( + "uni-t-ut71a-ser", ut71x, + "UNI-T", "UT71A (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "uni-t-ut71b-ser", ut71x, + "UNI-T", "UT71B (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "uni-t-ut71c-ser", ut71x, + "UNI-T", "UT71C (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "uni-t-ut71d-ser", ut71x, + "UNI-T", "UT71D (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "uni-t-ut71e-ser", ut71x, + "UNI-T", "UT71E (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", + 2400, UT71X_PACKET_SIZE, 0, 0, NULL, + sr_ut71x_packet_valid, sr_ut71x_parse, NULL + ), + DMM( + "iso-tech-idm103n", es519xx, + "ISO-TECH", "IDM103N", "2400/7o1/rts=0/dtr=1", + 2400, ES519XX_11B_PACKET_SIZE, 0, 0, NULL, + sr_es519xx_2400_11b_packet_valid, sr_es519xx_2400_11b_parse, + NULL + ), + DMM( + "tenma-72-7745-ser", fs9721, + "Tenma", "72-7745 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", + 2400, FS9721_PACKET_SIZE, 0, 0, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + sr_fs9721_00_temp_c + ), + DMM( + "tenma-72-7750-ser", es519xx, + /* Note: ES51986 baudrate is actually 19230! */ + "Tenma", "72-7750 (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", + 19200, ES519XX_11B_PACKET_SIZE, 0, 0, NULL, + sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse, + NULL + ), + DMM( + "brymen-bm25x", bm25x, + "Brymen", "BM25x", "9600/8n1/rts=1/dtr=1", + 9600, BRYMEN_BM25X_PACKET_SIZE, 0, 0, NULL, + sr_brymen_bm25x_packet_valid, sr_brymen_bm25x_parse, + NULL + ), + NULL +}; diff --git a/src/hardware/serial-dmm/protocol.c b/src/hardware/serial-dmm/protocol.c index bcac8500..119d0403 100644 --- a/src/hardware/serial-dmm/protocol.c +++ b/src/hardware/serial-dmm/protocol.c @@ -39,8 +39,9 @@ static void log_dmm_packet(const uint8_t *buf) } static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, - int dmm, void *info) + void *info) { + struct dmm_info *dmm = (struct dmm_info *) sdi->driver; float floatval; struct sr_datafeed_packet packet; struct sr_datafeed_analog analog; @@ -55,12 +56,12 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, analog.num_samples = 1; analog.mq = -1; - dmms[dmm].packet_parse(buf, &floatval, &analog, info); + 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); + if (dmm->dmm_details) + dmm->dmm_details(&analog, info); if (analog.mq != -1) { /* Got a measurement. */ @@ -72,13 +73,14 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, } /** Request packet, if required. */ -SR_PRIV int req_packet(struct sr_dev_inst *sdi, int dmm) +SR_PRIV int req_packet(struct sr_dev_inst *sdi) { + struct dmm_info *dmm = (struct dmm_info *) sdi->driver; struct dev_context *devc; struct sr_serial_dev_inst *serial; int ret; - if (!dmms[dmm].packet_request) + if (!dmm->packet_request) return SR_OK; devc = sdi->priv; @@ -90,20 +92,21 @@ SR_PRIV int req_packet(struct sr_dev_inst *sdi, int dmm) return SR_OK; } - ret = dmms[dmm].packet_request(serial); + ret = dmm->packet_request(serial); if (ret < 0) { sr_err("Failed to request packet: %d.", ret); return ret; } - if (dmms[dmm].req_timeout_ms) - devc->req_next_at = g_get_monotonic_time() + (dmms[dmm].req_timeout_ms * 1000); + if (dmm->req_timeout_ms) + devc->req_next_at = g_get_monotonic_time() + (dmm->req_timeout_ms * 1000); return SR_OK; } -static void handle_new_data(struct sr_dev_inst *sdi, int dmm, void *info) +static void handle_new_data(struct sr_dev_inst *sdi, void *info) { + struct dmm_info *dmm = (struct dmm_info *) sdi->driver; struct dev_context *devc; int len, i, offset = 0; struct sr_serial_dev_inst *serial; @@ -123,18 +126,18 @@ static void handle_new_data(struct sr_dev_inst *sdi, int dmm, void *info) devc->buflen += len; /* Now look for packets in that data. */ - while ((devc->buflen - offset) >= dmms[dmm].packet_size) { - if (dmms[dmm].packet_valid(devc->buf + offset)) { - handle_packet(devc->buf + offset, sdi, dmm, info); - offset += dmms[dmm].packet_size; + while ((devc->buflen - offset) >= dmm->packet_size) { + if (dmm->packet_valid(devc->buf + offset)) { + handle_packet(devc->buf + offset, sdi, info); + offset += dmm->packet_size; /* Request next packet, if required. */ - if (!dmms[dmm].packet_request) + if (!dmm->packet_request) break; - if (dmms[dmm].req_timeout_ms || dmms[dmm].req_delay_ms) + if (dmm->req_timeout_ms || dmm->req_delay_ms) devc->req_next_at = g_get_monotonic_time() + - dmms[dmm].req_delay_ms * 1000; - req_packet(sdi, dmm); + dmm->req_delay_ms * 1000; + req_packet(sdi); } else { offset++; } @@ -146,11 +149,13 @@ static void handle_new_data(struct sr_dev_inst *sdi, int dmm, void *info) devc->buflen -= offset; } -static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data) +int receive_data(int fd, int revents, void *cb_data) { struct sr_dev_inst *sdi; struct dev_context *devc; + struct dmm_info *dmm; int64_t time; + void *info; (void)fd; @@ -160,12 +165,16 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data) if (!(devc = sdi->priv)) return TRUE; + dmm = (struct dmm_info *) sdi->driver; + if (revents == G_IO_IN) { /* Serial data arrived. */ - handle_new_data(sdi, dmm, info); + info = malloc(dmm->info_size); + handle_new_data(sdi, info); + free(info); } else { /* Timeout; send another packet request if DMM needs it. */ - if (dmms[dmm].packet_request && (req_packet(sdi, dmm) < 0)) + if (dmm->packet_request && (req_packet(sdi) < 0)) return FALSE; } @@ -186,54 +195,3 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data) return TRUE; } - -#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 */ -RECEIVE_DATA(BBCGM_M2110, metex14) /* metex14_info used as a dummy. */ -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(MASTECH_MS8250B, fs9721) -RECEIVE_DATA(VA_VA18B, fs9721) -RECEIVE_DATA(VA_VA40B, fs9721) -RECEIVE_DATA(METEX_M3640D, metex14) -RECEIVE_DATA(METEX_M4650CR, metex14) -RECEIVE_DATA(PEAKTECH_4370, metex14) -RECEIVE_DATA(PCE_PCE_DM32, fs9721) -RECEIVE_DATA(RADIOSHACK_22_168, metex14) -RECEIVE_DATA(RADIOSHACK_22_805, metex14) -RECEIVE_DATA(RADIOSHACK_22_812, rs9lcd) -RECEIVE_DATA(TECPEL_DMM_8061_SER, fs9721) -RECEIVE_DATA(VOLTCRAFT_M3650CR, metex14) -RECEIVE_DATA(VOLTCRAFT_M3650D, metex14) -RECEIVE_DATA(VOLTCRAFT_M4650CR, metex14) -RECEIVE_DATA(VOLTCRAFT_ME42, metex14) -RECEIVE_DATA(VOLTCRAFT_VC820_SER, fs9721) -RECEIVE_DATA(VOLTCRAFT_VC830_SER, fs9922) -RECEIVE_DATA(VOLTCRAFT_VC840_SER, fs9721) -RECEIVE_DATA(VOLTCRAFT_VC870_SER, vc870) -RECEIVE_DATA(VOLTCRAFT_VC920_SER, ut71x) -RECEIVE_DATA(VOLTCRAFT_VC940_SER, ut71x) -RECEIVE_DATA(VOLTCRAFT_VC960_SER, ut71x) -RECEIVE_DATA(UNI_T_UT60A_SER, fs9721) -RECEIVE_DATA(UNI_T_UT60E_SER, fs9721) -RECEIVE_DATA(UNI_T_UT60G_SER, es519xx) -RECEIVE_DATA(UNI_T_UT61B_SER, fs9922) -RECEIVE_DATA(UNI_T_UT61C_SER, fs9922) -RECEIVE_DATA(UNI_T_UT61D_SER, fs9922) -RECEIVE_DATA(UNI_T_UT61E_SER, es519xx) -RECEIVE_DATA(UNI_T_UT71A_SER, ut71x) -RECEIVE_DATA(UNI_T_UT71B_SER, ut71x) -RECEIVE_DATA(UNI_T_UT71C_SER, ut71x) -RECEIVE_DATA(UNI_T_UT71D_SER, ut71x) -RECEIVE_DATA(UNI_T_UT71E_SER, ut71x) -RECEIVE_DATA(ISO_TECH_IDM103N, es519xx) -RECEIVE_DATA(TENMA_72_7745_SER, fs9721) -RECEIVE_DATA(TENMA_72_7750_SER, es519xx) -RECEIVE_DATA(BRYMEN_BM25X, bm25x) diff --git a/src/hardware/serial-dmm/protocol.h b/src/hardware/serial-dmm/protocol.h index 33317fc6..202eba27 100644 --- a/src/hardware/serial-dmm/protocol.h +++ b/src/hardware/serial-dmm/protocol.h @@ -22,54 +22,9 @@ #define LOG_PREFIX "serial-dmm" -enum { - BBCGM_M2110, - DIGITEK_DT4000ZC, - TEKPOWER_TP4000ZC, - METEX_ME31, - PEAKTECH_3410, - MASTECH_MAS345, - MASTECH_MS8250B, - VA_VA18B, - VA_VA40B, - METEX_M3640D, - METEX_M4650CR, - PEAKTECH_4370, - PCE_PCE_DM32, - RADIOSHACK_22_168, - RADIOSHACK_22_805, - RADIOSHACK_22_812, - TECPEL_DMM_8061_SER, - VOLTCRAFT_M3650CR, - VOLTCRAFT_M3650D, - VOLTCRAFT_M4650CR, - VOLTCRAFT_ME42, - VOLTCRAFT_VC820_SER, - VOLTCRAFT_VC830_SER, - VOLTCRAFT_VC840_SER, - VOLTCRAFT_VC870_SER, - VOLTCRAFT_VC920_SER, - VOLTCRAFT_VC940_SER, - VOLTCRAFT_VC960_SER, - UNI_T_UT60A_SER, - UNI_T_UT60E_SER, - UNI_T_UT60G_SER, - UNI_T_UT61B_SER, - UNI_T_UT61C_SER, - UNI_T_UT61D_SER, - UNI_T_UT61E_SER, - UNI_T_UT71A_SER, - UNI_T_UT71B_SER, - UNI_T_UT71C_SER, - UNI_T_UT71D_SER, - UNI_T_UT71E_SER, - ISO_TECH_IDM103N, - TENMA_72_7745_SER, - TENMA_72_7750_SER, - BRYMEN_BM25X, -}; - struct dmm_info { + /** libsigrok driver info struct. */ + struct sr_dev_driver di; /** Manufacturer/brand. */ char *vendor; /** Model. */ @@ -95,13 +50,11 @@ struct dmm_info { struct sr_datafeed_analog *, void *); /** */ void (*dmm_details)(struct sr_datafeed_analog *, void *); - /** libsigrok driver info struct. */ - struct sr_dev_driver *di; - /** Data reception function. */ - int (*receive_data)(int, int, void *); + /** Size of chipset info struct. */ + gsize info_size; }; -extern SR_PRIV struct dmm_info dmms[]; +extern SR_PRIV struct dmm_info *dmms[]; #define DMM_BUFSIZE 256 @@ -131,51 +84,7 @@ struct dev_context { int64_t req_next_at; }; -SR_PRIV int req_packet(struct sr_dev_inst *sdi, int dmm); - -SR_PRIV int receive_data_BBCGM_M2110(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_MASTECH_MS8250B(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_VA_VA40B(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_METEX_M4650CR(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_805(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_RADIOSHACK_22_812(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_TECPEL_DMM_8061_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_M3650CR(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_M3650D(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_M4650CR(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_ME42(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC820_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC830_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC840_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC870_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC920_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC940_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_VOLTCRAFT_VC960_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT60A_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT60E_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT60G_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT61B_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT61C_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT61D_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT61E_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT71A_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT71B_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT71C_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT71D_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_UNI_T_UT71E_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_ISO_TECH_IDM103N(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_TENMA_72_7745_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_TENMA_72_7750_SER(int fd, int revents, void *cb_data); -SR_PRIV int receive_data_BRYMEN_BM25X(int fd, int revents, void *cb_data); +SR_PRIV int req_packet(struct sr_dev_inst *sdi); +SR_PRIV int receive_data(int fd, int revents, void *cb_data); #endif