From da1461640fcbb28d1d03c6d02011847ca78d98fc Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 19 Oct 2022 18:41:13 +0800 Subject: [PATCH] The saved session file does not use a string value, use a code value instead. --- DSView/pv/deviceagent.cpp | 5 - DSView/pv/deviceagent.h | 2 - DSView/pv/mainwindow.cpp | 254 ++++++++++++----------- DSView/pv/mainwindow.h | 26 ++- DSView/pv/prop/binding/deviceoptions.cpp | 10 +- DSView/pv/prop/binding/probeoptions.cpp | 25 +-- DSView/pv/toolbars/filebar.cpp | 13 +- libsigrok4DSL/hardware/DSL/dscope.c | 60 ++---- libsigrok4DSL/hardware/DSL/dsl.c | 9 +- libsigrok4DSL/hardware/DSL/dsl.h | 112 +++------- libsigrok4DSL/hardware/DSL/dslogic.c | 238 +++++++++++---------- libsigrok4DSL/hardware/demo/demo.c | 7 - libsigrok4DSL/hardware/demo/demo.h | 8 +- libsigrok4DSL/hwdriver.c | 141 ++++--------- libsigrok4DSL/lib_main.c | 10 - libsigrok4DSL/libsigrok-internal.h | 8 +- libsigrok4DSL/libsigrok.h | 106 ++++++++-- libsigrok4DSL/session_driver.c | 12 +- 18 files changed, 467 insertions(+), 579 deletions(-) diff --git a/DSView/pv/deviceagent.cpp b/DSView/pv/deviceagent.cpp index 3f6c543e..fb0a76de 100644 --- a/DSView/pv/deviceagent.cpp +++ b/DSView/pv/deviceagent.cpp @@ -302,11 +302,6 @@ const struct sr_config_info *DeviceAgent::get_config_info(int key) return ds_get_actived_device_config_info(key); } -const struct sr_config_info *DeviceAgent::get_config_info_by_name(const char *optname) -{ - return ds_get_actived_device_config_info_by_name(optname); -} - bool DeviceAgent::get_device_status(struct sr_status &status, gboolean prg) { if (ds_get_actived_device_status(&status, prg) == SR_OK) diff --git a/DSView/pv/deviceagent.h b/DSView/pv/deviceagent.h index 38544375..8fa733d7 100644 --- a/DSView/pv/deviceagent.h +++ b/DSView/pv/deviceagent.h @@ -173,8 +173,6 @@ public: const struct sr_config_info* get_config_info(int key); - const struct sr_config_info* get_config_info_by_name(const char *optname); - bool get_device_status(struct sr_status &status, gboolean prg); struct sr_config* new_config(int key, GVariant *data); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 34f75e6d..fe2393f1 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -599,6 +599,124 @@ namespace pv return load_session_json(sessionDoc, bDone); } + bool MainWindow::gen_session_json(QJsonObject &sessionVar) + { + AppConfig &app = AppConfig::Instance(); + + GVariant *gvar_opts; + GVariant *gvar; + gsize num_opts; + + QString title = QApplication::applicationName() + " v" + QApplication::applicationVersion(); + + QJsonArray channelVar; + sessionVar["Version"] = QJsonValue::fromVariant(BASE_SESSION_VERSION); + sessionVar["Device"] = QJsonValue::fromVariant(_device_agent->driver_name()); + sessionVar["DeviceMode"] = QJsonValue::fromVariant(_device_agent->get_work_mode()); + sessionVar["Language"] = QJsonValue::fromVariant(app._frameOptions.language); + sessionVar["Title"] = QJsonValue::fromVariant(title); + + gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_DEVICE_SESSIONS); + if (gvar_opts == NULL) + { + dsv_warn("%s", "Device config list is empty. id:SR_CONF_DEVICE_SESSIONS"); + /* Driver supports no device instance sessions. */ + return false; + } + + const int *const options = (const int32_t *)g_variant_get_fixed_array( + gvar_opts, &num_opts, sizeof(int32_t)); + + for (unsigned int i = 0; i < num_opts; i++) + { + const struct sr_config_info *const info = _device_agent->get_config_info(options[i]); + gvar = _device_agent->get_config(NULL, NULL, info->key); + if (gvar != NULL) + { + if (info->datatype == SR_T_BOOL) + sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_boolean(gvar)); + else if (info->datatype == SR_T_UINT64) + sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_uint64(gvar))); + else if (info->datatype == SR_T_UINT8) + sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_byte(gvar))); + else if (info->datatype == SR_T_FLOAT) + sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_double(gvar)); + else if (info->datatype == SR_T_CHAR) + sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_string(gvar, NULL)); + else if (info->datatype == SR_T_LIST) + sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_uint16(gvar))); + else{ + dsv_err("Unkown config info type:%d", info->datatype); + assert(false); + } + g_variant_unref(gvar); + } + } + + for (auto &s : _session->get_signals()) + { + QJsonObject s_obj; + s_obj["index"] = s->get_index(); + s_obj["type"] = s->get_type(); + s_obj["enabled"] = s->enabled(); + s_obj["name"] = s->get_name(); + if (s->get_colour().isValid()) + s_obj["colour"] = QJsonValue::fromVariant(s->get_colour()); + else + s_obj["colour"] = QJsonValue::fromVariant("default"); + + view::LogicSignal *logicSig = NULL; + if ((logicSig = dynamic_cast(s))) + { + s_obj["strigger"] = logicSig->get_trig(); + } + + view::DsoSignal *dsoSig = NULL; + if ((dsoSig = dynamic_cast(s))) + { + s_obj["vdiv"] = QJsonValue::fromVariant(static_cast(dsoSig->get_vDialValue())); + s_obj["vfactor"] = QJsonValue::fromVariant(static_cast(dsoSig->get_factor())); + s_obj["coupling"] = dsoSig->get_acCoupling(); + s_obj["trigValue"] = dsoSig->get_trig_vrate(); + s_obj["zeroPos"] = dsoSig->get_zero_ratio(); + } + + view::AnalogSignal *analogSig = NULL; + if ((analogSig = dynamic_cast(s))) + { + s_obj["vdiv"] = QJsonValue::fromVariant(static_cast(analogSig->get_vdiv())); + s_obj["vfactor"] = QJsonValue::fromVariant(static_cast(analogSig->get_factor())); + s_obj["coupling"] = analogSig->get_acCoupling(); + s_obj["zeroPos"] = analogSig->get_zero_ratio(); + s_obj["mapUnit"] = analogSig->get_mapUnit(); + s_obj["mapMin"] = analogSig->get_mapMin(); + s_obj["mapMax"] = analogSig->get_mapMax(); + } + channelVar.append(s_obj); + } + sessionVar["channel"] = channelVar; + + if (_device_agent->get_work_mode() == LOGIC) + { + sessionVar["trigger"] = _trigger_widget->get_session(); + } + + StoreSession ss(_session); + QJsonArray decodeJson; + ss.json_decoders(decodeJson); + sessionVar["decoder"] = decodeJson; + + if (_device_agent->get_work_mode() == DSO) + { + sessionVar["measure"] = _view->get_viewstatus()->get_session(); + } + + if (gvar_opts != NULL) + g_variant_unref(gvar_opts); + + return true; + } + bool MainWindow::load_session_json(QJsonDocument json, bool &haveDecoder) { haveDecoder = false; @@ -606,6 +724,7 @@ namespace pv QJsonObject sessionObj = json.object(); int mode = _device_agent->get_work_mode(); + bool isNew = false; // check session file version if (!sessionObj.contains("Version")) @@ -620,16 +739,15 @@ namespace pv return false; } - // old version(<= 1.1.2), restore the language - if (sessionObj["Version"].toInt() == BASE_SESSION_VERSION) - { - } + if (sessionObj.contains("Title")) + isNew = true; + + int sessionMode = sessionObj["DeviceMode"].toInt(); if (_device_agent->is_hardware()) { QString driverName = _device_agent->driver_name(); - QString sessionDevice = sessionObj["Device"].toString(); - int sessionMode = sessionObj["DeviceMode"].toInt(); + QString sessionDevice = sessionObj["Device"].toString(); // check device and mode if (driverName != sessionDevice || mode != sessionMode) { @@ -663,13 +781,9 @@ namespace pv else if (info->datatype == SR_T_FLOAT) _device_agent->set_config(NULL, NULL, info->key, g_variant_new_double(sessionObj[info->name].toDouble())); else if (info->datatype == SR_T_CHAR) - { - QString v = sessionObj[info->name].toString(); - if (info->key == SR_CONF_OPERATION_MODE){ - - } - _device_agent->set_config(NULL, NULL, info->key, g_variant_new_string(v.toUtf8())); - } + _device_agent->set_config(NULL, NULL, info->key, g_variant_new_string(sessionObj[info->name].toString().toUtf8())); + else if (info->datatype == SR_T_LIST) + _device_agent->set_config(NULL, NULL, info->key, g_variant_new_uint16(sessionObj[info->name].toString().toInt())); } } @@ -832,114 +946,8 @@ namespace pv _view->get_viewstatus()->load_session(sessionObj["measure"].toArray()); } - return true; - } - - bool MainWindow::gen_session_json(QJsonObject &sessionVar) - { - AppConfig &app = AppConfig::Instance(); - - GVariant *gvar_opts; - GVariant *gvar; - gsize num_opts; - - QString title = QApplication::applicationName() + " v" + QApplication::applicationVersion(); - - QJsonArray channelVar; - sessionVar["Version"] = QJsonValue::fromVariant(BASE_SESSION_VERSION); - sessionVar["Device"] = QJsonValue::fromVariant(_device_agent->driver_name()); - sessionVar["DeviceMode"] = QJsonValue::fromVariant(_device_agent->get_work_mode()); - sessionVar["Language"] = QJsonValue::fromVariant(app._frameOptions.language); - sessionVar["Title"] = QJsonValue::fromVariant(title); - - gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_DEVICE_SESSIONS); - if (gvar_opts == NULL) - { - dsv_warn("%s", "Device config list is empty. id:SR_CONF_DEVICE_SESSIONS"); - /* Driver supports no device instance sessions. */ - return false; - } - - const int *const options = (const int32_t *)g_variant_get_fixed_array( - gvar_opts, &num_opts, sizeof(int32_t)); - - for (unsigned int i = 0; i < num_opts; i++) - { - const struct sr_config_info *const info = _device_agent->get_config_info(options[i]); - gvar = _device_agent->get_config(NULL, NULL, info->key); - if (gvar != NULL) - { - if (info->datatype == SR_T_BOOL) - sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_boolean(gvar)); - else if (info->datatype == SR_T_UINT64) - sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_uint64(gvar))); - else if (info->datatype == SR_T_UINT8) - sessionVar[info->name] = QJsonValue::fromVariant(QString::number(g_variant_get_byte(gvar))); - else if (info->datatype == SR_T_FLOAT) - sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_double(gvar)); - else if (info->datatype == SR_T_CHAR) - sessionVar[info->name] = QJsonValue::fromVariant(g_variant_get_string(gvar, NULL)); - g_variant_unref(gvar); - } - } - - for (auto &s : _session->get_signals()) - { - QJsonObject s_obj; - s_obj["index"] = s->get_index(); - s_obj["type"] = s->get_type(); - s_obj["enabled"] = s->enabled(); - s_obj["name"] = s->get_name(); - if (s->get_colour().isValid()) - s_obj["colour"] = QJsonValue::fromVariant(s->get_colour()); - else - s_obj["colour"] = QJsonValue::fromVariant("default"); - - view::LogicSignal *logicSig = NULL; - if ((logicSig = dynamic_cast(s))) - { - s_obj["strigger"] = logicSig->get_trig(); - } - - view::DsoSignal *dsoSig = NULL; - if ((dsoSig = dynamic_cast(s))) - { - s_obj["vdiv"] = QJsonValue::fromVariant(static_cast(dsoSig->get_vDialValue())); - s_obj["vfactor"] = QJsonValue::fromVariant(static_cast(dsoSig->get_factor())); - s_obj["coupling"] = dsoSig->get_acCoupling(); - s_obj["trigValue"] = dsoSig->get_trig_vrate(); - s_obj["zeroPos"] = dsoSig->get_zero_ratio(); - } - - view::AnalogSignal *analogSig = NULL; - if ((analogSig = dynamic_cast(s))) - { - s_obj["vdiv"] = QJsonValue::fromVariant(static_cast(analogSig->get_vdiv())); - s_obj["vfactor"] = QJsonValue::fromVariant(static_cast(analogSig->get_factor())); - s_obj["coupling"] = analogSig->get_acCoupling(); - s_obj["zeroPos"] = analogSig->get_zero_ratio(); - s_obj["mapUnit"] = analogSig->get_mapUnit(); - s_obj["mapMin"] = analogSig->get_mapMin(); - s_obj["mapMax"] = analogSig->get_mapMax(); - } - channelVar.append(s_obj); - } - sessionVar["channel"] = channelVar; - - if (_device_agent->get_work_mode() == LOGIC) - { - sessionVar["trigger"] = _trigger_widget->get_session(); - } - - StoreSession ss(_session); - QJsonArray decodeJson; - ss.json_decoders(decodeJson); - sessionVar["decoder"] = decodeJson; - - if (_device_agent->get_work_mode() == DSO) - { - sessionVar["measure"] = _view->get_viewstatus()->get_session(); - } + if (gvar_opts != NULL) + g_variant_unref(gvar_opts); return true; } @@ -1154,9 +1162,7 @@ namespace pv { if (language == 0) return; - - if (_device_agent->have_instance()) - _device_agent->set_config(NULL, NULL, SR_CONF_LANGUAGE, g_variant_new_int16(language)); + AppConfig &app = AppConfig::Instance(); if (app._frameOptions.language != language && language > 0) diff --git a/DSView/pv/mainwindow.h b/DSView/pv/mainwindow.h index 410e5c64..b33f8fc9 100644 --- a/DSView/pv/mainwindow.h +++ b/DSView/pv/mainwindow.h @@ -87,15 +87,6 @@ public: explicit MainWindow(QWidget *parent = 0); void openDoc(); - -private: - void closeEvent(QCloseEvent *event); - - void setup_ui(); - void retranslateUi(); - bool eventFilter(QObject *object, QEvent *event); - bool load_session_json(QJsonDocument json, bool &haveDecoder); - QString genSessionFileName(); public slots: void switchTheme(QString style); @@ -139,10 +130,22 @@ public: void session_save(); private: + void closeEvent(QCloseEvent *event); + void setup_ui(); + void retranslateUi(); + bool eventFilter(QObject *object, QEvent *event); + void check_usb_device_speed(); void reset_all_view(); bool confirm_to_store_data(); void update_toolbar_view_status(); + bool load_session_json(QJsonDocument json, bool &haveDecoder); + QString genSessionFileName(); + bool gen_session_json(QJsonObject &sessionVar); + void check_session_file_version(); + void load_device_config(); + QJsonDocument get_session_json_from_file(QString file); + QJsonArray get_decoder_json_from_file(QString file); private: //ISessionCallback @@ -168,11 +171,6 @@ private: //ISessionDataGetter bool genSessionData(std::string &str); - bool gen_session_json(QJsonObject &sessionVar); - void check_session_file_version(); - void load_device_config(); - QJsonDocument get_session_json_from_file(QString file); - QJsonArray get_decoder_json_from_file(QString file); //IMessageListener void OnMessage(int msg); diff --git a/DSView/pv/prop/binding/deviceoptions.cpp b/DSView/pv/prop/binding/deviceoptions.cpp index 9f322b0f..811212d6 100644 --- a/DSView/pv/prop/binding/deviceoptions.cpp +++ b/DSView/pv/prop/binding/deviceoptions.cpp @@ -70,15 +70,7 @@ DeviceOptions::DeviceOptions() gvar_list = _device_agent->get_config_list(NULL, key); const QString name(info->name); - char *label_char = info->label; - GVariant *gvar_tmp = _device_agent->get_config(NULL, NULL, SR_CONF_LANGUAGE); - - if (gvar_tmp != NULL) { - int language = g_variant_get_int16(gvar_tmp); - if (language == LAN_CN) - label_char = info->label_cn; - g_variant_unref(gvar_tmp); - } + char *label_char = info->name; QString label(label_char); switch(key) diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/pv/prop/binding/probeoptions.cpp index da1a47e7..ae1fa025 100644 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/pv/prop/binding/probeoptions.cpp @@ -42,14 +42,14 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : Binding(), _probe(probe) { - GVariant *gvar_opts, *gvar_list; + GVariant *gvar_opts; gsize num_opts; SigSession *session = AppControl::Instance()->GetSession(); _device_agent = session->get_device(); gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_PROBE_CONFIGS); - if (gvar_opts != NULL){ + if (gvar_opts == NULL){ /* Driver supports no device instance options. */ return; } @@ -57,7 +57,8 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : const int *const options = (const int32_t *)g_variant_get_fixed_array( gvar_opts, &num_opts, sizeof(int32_t)); - for (unsigned int i = 0; i < num_opts; i++) { + for (unsigned int i = 0; i < num_opts; i++) + { const struct sr_config_info *const info = _device_agent->get_config_info(options[i]); @@ -66,18 +67,10 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : const int key = info->key; - gvar_list = _device_agent->get_config_list(NULL, key); + GVariant *gvar_list = _device_agent->get_config_list(NULL, key); const QString name(info->name); - char *label_char = info->label; - GVariant *gvar_tmp = _device_agent->get_config(NULL, NULL, SR_CONF_LANGUAGE); - - if (gvar_tmp != NULL) { - int language = g_variant_get_int16(gvar_tmp); - if (language == LAN_CN) - label_char = info->label_cn; - g_variant_unref(gvar_tmp); - } + char *label_char = info->name; const QString label(label_char); switch(key) @@ -103,16 +96,12 @@ ProbeOptions::ProbeOptions(struct sr_channel *probe) : case SR_CONF_PROBE_MAP_DEFAULT: bind_bool(name, label, key); break; - - default: - gvar_list = NULL; } if (gvar_list) g_variant_unref(gvar_list); } - if (gvar_opts) - g_variant_unref(gvar_opts); + g_variant_unref(gvar_opts); } GVariant* ProbeOptions::config_getter(const struct sr_channel *probe, int key) diff --git a/DSView/pv/toolbars/filebar.cpp b/DSView/pv/toolbars/filebar.cpp index 9d43ccb7..642f2fcf 100644 --- a/DSView/pv/toolbars/filebar.cpp +++ b/DSView/pv/toolbars/filebar.cpp @@ -191,16 +191,11 @@ void FileBar::on_actionDefault_triggered() QString driver_name = _session->get_device()->name(); QString mode_name = QString::number(_session->get_device()->get_work_mode()); - int language = LAN_EN; - GVariant *gvar_tmp = _session->get_device()->get_config(NULL, NULL, SR_CONF_LANGUAGE); - if (gvar_tmp != NULL) { - language = g_variant_get_int16(gvar_tmp); - g_variant_unref(gvar_tmp); - } + + int language = AppConfig::Instance()._frameOptions.language; QString file_name = dir.absolutePath() + "/" + driver_name + mode_name + - ".def"+QString::number(language)+".dsc"; - if (!file_name.isEmpty()) - sig_load_session(file_name); + ".def" + QString::number(language) + ".dsc"; + sig_load_session(file_name); } void FileBar::on_actionStore_triggered() diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index 0ec5d959..e2b34b81 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -29,31 +29,22 @@ static int dev_destroy(struct sr_dev_inst *sdi); -enum { +enum DSCOPE_OPERATION_MODE +{ /** Normal */ OP_NORMAL = 0, /** Internal pattern test mode */ OP_INTEST = 1, }; -static const char *opmodes_cn[] = { - "正常", - "内部测试", -}; - -static const char *opmodes[] = { - "Normal", - "Internal Test", -}; - enum { BW_FULL = 0, BW_20M = 1, }; -static const char *bandwidths_cn[] = { - "全带宽", - "20MHz", +static const char *opmodes[] = { + "Normal", + "Internal Test", }; static const char *bandwidths[] = { @@ -61,6 +52,15 @@ static const char *bandwidths[] = { "20MHz", }; +static struct lang_text_map_item opmodes_map[] = +{ + {SR_CONF_OPERATION_MODE, OP_NORMAL, "Normal", "正常"}, + {SR_CONF_OPERATION_MODE, OP_INTEST, "Internal Test", "内部测试"}, + + {SR_CONF_BANDWIDTH_LIMIT, BW_FULL, "Full Bandwidth", "全带宽"}, + {SR_CONF_BANDWIDTH_LIMIT, BW_20M, "20MHz", NULL}, +}; + static const int32_t hwoptions[] = { SR_CONF_OPERATION_MODE, SR_CONF_BANDWIDTH_LIMIT, @@ -96,22 +96,6 @@ static const uint8_t zero_big_addr = 0x20; SR_PRIV struct sr_dev_driver DSCope_driver_info; static struct sr_dev_driver *di = &DSCope_driver_info; -static const char ** get_opmodes(struct DSL_context *devc) -{ - if (devc->language == LANGUAGE_CN) - return opmodes_cn; - else - return opmodes; -} - -static const char ** get_bandwidths(struct DSL_context *devc) -{ - if (devc->language == LANGUAGE_CN) - return bandwidths_cn; - else - return bandwidths; -} - static uint16_t get_default_preoff(const struct sr_dev_inst *sdi, const struct sr_channel* ch) { int i; @@ -1059,12 +1043,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_OPERATION_MODE: if (!sdi) return SR_ERR; - *data = g_variant_new_string(get_opmodes(devc)[devc->op_mode]); + *data = g_variant_new_string(opmodes[devc->op_mode]); break; case SR_CONF_BANDWIDTH_LIMIT: if (!sdi) return SR_ERR; - *data = g_variant_new_string(get_bandwidths(devc)[devc->bw_limit]); + *data = g_variant_new_string(bandwidths[devc->bw_limit]); break; case SR_CONF_CALI: if (!sdi) @@ -1385,10 +1369,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, sr_dbg("%s: setting mode to %d", __func__, sdi->mode); } else if (id == SR_CONF_OPERATION_MODE) { stropt = g_variant_get_string(data, NULL); - if (!strcmp(stropt, get_opmodes(devc)[OP_NORMAL])) { + if (!strcmp(stropt, opmodes[OP_NORMAL])) { devc->op_mode = OP_NORMAL; devc->test_mode = SR_TEST_NONE; - } else if (!strcmp(stropt, get_opmodes(devc)[OP_INTEST])) { + } else if (!strcmp(stropt, opmodes[OP_INTEST])) { devc->op_mode = OP_INTEST; devc->test_mode = SR_TEST_INTERNAL; } else { @@ -1398,10 +1382,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, __func__, devc->op_mode); } else if (id == SR_CONF_BANDWIDTH_LIMIT) { stropt = g_variant_get_string(data, NULL); - if (!strcmp(stropt, get_bandwidths(devc)[BW_FULL])) { + if (!strcmp(stropt, bandwidths[BW_FULL])) { devc->bw_limit = BW_FULL; dsl_wr_reg(sdi, CTR0_ADDR, bmBW20M_CLR); - } else if (!strcmp(stropt, get_bandwidths(devc)[BW_20M])) { + } else if (!strcmp(stropt, bandwidths[BW_20M])) { devc->bw_limit = BW_20M; dsl_wr_reg(sdi, CTR0_ADDR, bmBW20M_SET); } else { @@ -1727,10 +1711,10 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, sessions_daq, ARRAY_SIZE(sessions_daq)*sizeof(int32_t), TRUE, NULL, NULL); break; case SR_CONF_OPERATION_MODE: - *data = g_variant_new_strv(get_opmodes(devc), ARRAY_SIZE(opmodes)); + *data = g_variant_new_strv(opmodes, ARRAY_SIZE(opmodes)); break; case SR_CONF_BANDWIDTH_LIMIT: - *data = g_variant_new_strv(get_bandwidths(devc), ARRAY_SIZE(bandwidths)); + *data = g_variant_new_strv(bandwidths, ARRAY_SIZE(bandwidths)); break; default: return SR_ERR_NA; diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index a89d7844..7e92f12b 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -1479,11 +1479,6 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd (void)cg; switch (id) { - case SR_CONF_LANGUAGE: - if (!sdi) - return SR_ERR; - *data = g_variant_new_int16(devc->language); - break; case SR_CONF_CONN: if (!sdi || !sdi->conn) return SR_ERR_ARG; @@ -1715,9 +1710,7 @@ SR_PRIV int dsl_config_set(int id, GVariant *data, struct sr_dev_inst *sdi, struct DSL_context *devc = sdi->priv; int ret = SR_OK; - if (id == SR_CONF_LANGUAGE) { - devc->language = g_variant_get_int16(data); - } else if (id == SR_CONF_ZERO_COMB) { + if (id == SR_CONF_ZERO_COMB) { devc->zero_comb = g_variant_get_boolean(data); } else if (id == SR_CONF_PROBE_MAP_DEFAULT) { ch->map_default = g_variant_get_boolean(data); diff --git a/libsigrok4DSL/hardware/DSL/dsl.h b/libsigrok4DSL/hardware/DSL/dsl.h index e8a5289b..7226c8ea 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.h +++ b/libsigrok4DSL/hardware/DSL/dsl.h @@ -141,11 +141,6 @@ */ #define CALI_VGAIN_RANGE 200 -enum LANGUAGE { - LANGUAGE_CN = 25, - LANGUAGE_EN = 31, -}; - struct DSL_caps { uint64_t mode_caps; uint64_t feature_caps; @@ -350,48 +345,8 @@ static const struct DSL_vga vga_defaults[] = { {0, 0, 0, 0, 0} }; -enum CHANNEL_ID { - DSL_STREAM20x16 = 0, - DSL_STREAM25x12, - DSL_STREAM50x6, - DSL_STREAM100x3, - - DSL_STREAM20x16_3DN2, - DSL_STREAM25x12_3DN2, - DSL_STREAM50x6_3DN2, - DSL_STREAM100x3_3DN2, - - DSL_STREAM10x32_32_3DN2, - DSL_STREAM20x16_32_3DN2, - DSL_STREAM25x12_32_3DN2, - DSL_STREAM50x6_32_3DN2, - DSL_STREAM100x3_32_3DN2, - - DSL_STREAM50x32, - DSL_STREAM100x30, - DSL_STREAM250x12, - DSL_STREAM125x16_16, - DSL_STREAM250x12_16, - DSL_STREAM500x6, - DSL_STREAM1000x3, - - DSL_BUFFER100x16, - DSL_BUFFER200x8, - DSL_BUFFER400x4, - - DSL_BUFFER250x32, - DSL_BUFFER500x16, - DSL_BUFFER1000x8, - - DSL_ANALOG10x2, - DSL_ANALOG10x2_500, - - DSL_DSO200x2, - DSL_DSO1000x2, -}; - struct DSL_channels { - enum CHANNEL_ID id; + enum DSL_CHANNEL_ID id; enum OPERATION_MODE mode; enum CHANNEL_TYPE type; gboolean stream; @@ -404,81 +359,80 @@ struct DSL_channels { uint64_t hw_max_samplerate; uint8_t pre_div; const char *descr; - const char *descr_cn; }; static const struct DSL_channels channel_modes[] = { // LA Stream {DSL_STREAM20x16, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 16, 1, SR_KHZ(10), SR_MHZ(20), - SR_KHZ(10), SR_MHZ(100), 1, "Use 16 Channels (Max 20MHz)", "使用16个通道(最大采样率 20MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use 16 Channels (Max 20MHz)"}, {DSL_STREAM25x12, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 12, 1, SR_KHZ(10), SR_MHZ(25), - SR_KHZ(10), SR_MHZ(100), 1, "Use 12 Channels (Max 25MHz)", "使用12个通道(最大采样率 25MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use 12 Channels (Max 25MHz)"}, {DSL_STREAM50x6, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 6, 1, SR_KHZ(10), SR_MHZ(50), - SR_KHZ(10), SR_MHZ(100), 1, "Use 6 Channels (Max 50MHz)", "使用6个通道(最大采样率 50MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use 6 Channels (Max 50MHz)"}, {DSL_STREAM100x3, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 3, 1, SR_KHZ(10), SR_MHZ(100), - SR_KHZ(10), SR_MHZ(100), 1, "Use 3 Channels (Max 100MHz)", "使用3个通道(最大采样率 100MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use 3 Channels (Max 100MHz)"}, {DSL_STREAM20x16_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 16, 1, SR_KHZ(10), SR_MHZ(20), - SR_KHZ(10), SR_MHZ(500), 5, "Use 16 Channels (Max 20MHz)", "使用16个通道(最大采样率 20MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 16 Channels (Max 20MHz)"}, {DSL_STREAM25x12_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 12, 1, SR_KHZ(10), SR_MHZ(25), - SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 25MHz)", "使用12个通道(最大采样率 25MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 25MHz)"}, {DSL_STREAM50x6_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 6, 1, SR_KHZ(10), SR_MHZ(50), - SR_KHZ(10), SR_MHZ(500), 5, "Use 6 Channels (Max 50MHz)", "使用6个通道(最大采样率 50MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 6 Channels (Max 50MHz)"}, {DSL_STREAM100x3_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 3, 1, SR_KHZ(10), SR_MHZ(100), - SR_KHZ(10), SR_MHZ(500), 5, "Use 3 Channels (Max 100MHz)", "使用3个通道(最大采样率 100MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 3 Channels (Max 100MHz)"}, {DSL_STREAM10x32_32_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 32, 1, SR_KHZ(10), SR_MHZ(10), - SR_KHZ(10), SR_MHZ(500), 5, "Use 32 Channels (Max 10MHz)", "使用32个通道(最大采样率 10MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 32 Channels (Max 10MHz)"}, {DSL_STREAM20x16_32_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 16, 1, SR_KHZ(10), SR_MHZ(20), - SR_KHZ(10), SR_MHZ(500), 5, "Use 16 Channels (Max 20MHz)", "使用16个通道(最大采样率 20MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 16 Channels (Max 20MHz)"}, {DSL_STREAM25x12_32_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 12, 1, SR_KHZ(10), SR_MHZ(25), - SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 25MHz)", "使用12个通道(最大采样率 25MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 25MHz)"}, {DSL_STREAM50x6_32_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 6, 1, SR_KHZ(10), SR_MHZ(50), - SR_KHZ(10), SR_MHZ(500), 5, "Use 6 Channels (Max 50MHz)", "使用6个通道(最大采样率 50MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 6 Channels (Max 50MHz)"}, {DSL_STREAM100x3_32_3DN2, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 3, 1, SR_KHZ(10), SR_MHZ(100), - SR_KHZ(10), SR_MHZ(500), 5, "Use 3 Channels (Max 100MHz)", "使用3个通道(最大采样率 100MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 3 Channels (Max 100MHz)"}, {DSL_STREAM50x32, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 32, 1, SR_KHZ(10), SR_MHZ(50), - SR_KHZ(10), SR_MHZ(500), 5, "Use 32 Channels (Max 50MHz)", "使用32个通道(最大采样率 50MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 32 Channels (Max 50MHz)"}, {DSL_STREAM100x30, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 30, 1, SR_KHZ(10), SR_MHZ(100), - SR_KHZ(10), SR_MHZ(500), 5, "Use 30 Channels (Max 100MHz)", "使用30个通道(最大采样率 100MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 30 Channels (Max 100MHz)"}, {DSL_STREAM250x12, LOGIC, SR_CHANNEL_LOGIC, TRUE, 32, 12, 1, SR_KHZ(10), SR_MHZ(250), - SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 250MHz)", "使用12个通道(最大采样率 250MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 250MHz)"}, {DSL_STREAM125x16_16, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 16, 1, SR_KHZ(10), SR_MHZ(125), - SR_KHZ(10), SR_MHZ(500), 5, "Use 16 Channels (Max 125MHz)", "使用16个通道(最大采样率 125MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 16 Channels (Max 125MHz)"}, {DSL_STREAM250x12_16, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 12, 1, SR_KHZ(10), SR_MHZ(250), - SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 250MHz)", "使用12个通道(最大采样率 250MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 12 Channels (Max 250MHz)"}, {DSL_STREAM500x6, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 6, 1, SR_KHZ(10), SR_MHZ(500), - SR_KHZ(10), SR_MHZ(500), 5, "Use 6 Channels (Max 500MHz)", "使用6个通道(最大采样率 500MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 6 Channels (Max 500MHz)"}, {DSL_STREAM1000x3, LOGIC, SR_CHANNEL_LOGIC, TRUE, 8, 3, 1, SR_KHZ(10), SR_GHZ(1), - SR_KHZ(10), SR_MHZ(500), 5, "Use 3 Channels (Max 1GHz)", "使用3个通道(最大采样率 1GHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use 3 Channels (Max 1GHz)"}, // LA Buffer {DSL_BUFFER100x16, LOGIC, SR_CHANNEL_LOGIC, FALSE, 16, 16, 1, SR_KHZ(10), SR_MHZ(100), - SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~15 (Max 100MHz)", "使用通道 0~15 (最大采样率 100MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~15 (Max 100MHz)"}, {DSL_BUFFER200x8, LOGIC, SR_CHANNEL_LOGIC, FALSE, 8, 8, 1, SR_KHZ(10), SR_MHZ(200), - SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~7 (Max 200MHz)", "使用通道 0~7 (最大采样率 200MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~7 (Max 200MHz)"}, {DSL_BUFFER400x4, LOGIC, SR_CHANNEL_LOGIC, FALSE, 4, 4, 1, SR_KHZ(10), SR_MHZ(400), - SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~3 (Max 400MHz)", "使用通道 0~3 (最大采样率 400MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~3 (Max 400MHz)"}, {DSL_BUFFER250x32, LOGIC, SR_CHANNEL_LOGIC, FALSE, 32, 32, 1, SR_KHZ(10), SR_MHZ(250), - SR_KHZ(10), SR_MHZ(500), 5, "Use Channels 0~31 (Max 250MHz)", "使用通道 0~31 (最大采样率 250MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use Channels 0~31 (Max 250MHz)"}, {DSL_BUFFER500x16, LOGIC, SR_CHANNEL_LOGIC, FALSE, 16, 16, 1, SR_KHZ(10), SR_MHZ(500), - SR_KHZ(10), SR_MHZ(500), 5, "Use Channels 0~15 (Max 500MHz)", "使用通道 0~15 (最大采样率 500MHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use Channels 0~15 (Max 500MHz)"}, {DSL_BUFFER1000x8, LOGIC, SR_CHANNEL_LOGIC, FALSE, 8, 8, 1, SR_KHZ(10), SR_GHZ(1), - SR_KHZ(10), SR_MHZ(500), 5, "Use Channels 0~7 (Max 1GHz)", "使用通道 0~7 (最大采样率 1GHz)"}, + SR_KHZ(10), SR_MHZ(500), 5, "Use Channels 0~7 (Max 1GHz)"}, // DAQ {DSL_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, TRUE, 2, 2, 8, SR_HZ(10), SR_MHZ(10), - SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~1 (Max 10MHz)", "使用通道 0~1 (最大采样率 10MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~1 (Max 10MHz)"}, {DSL_ANALOG10x2_500, ANALOG, SR_CHANNEL_ANALOG, TRUE, 2, 2, 8, SR_HZ(10), SR_MHZ(10), - SR_KHZ(10), SR_MHZ(500), 1, "Use Channels 0~1 (Max 10MHz)", "使用通道 0~1 (最大采样率 10MHz)"}, + SR_KHZ(10), SR_MHZ(500), 1, "Use Channels 0~1 (Max 10MHz)"}, // OSC {DSL_DSO200x2, DSO, SR_CHANNEL_DSO, FALSE, 2, 2, 8, SR_KHZ(10), SR_MHZ(200), - SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~1 (Max 200MHz)", "使用通道 0~1 (最大采样率 200MHz)"}, + SR_KHZ(10), SR_MHZ(100), 1, "Use Channels 0~1 (Max 200MHz)"}, {DSL_DSO1000x2, DSO, SR_CHANNEL_DSO, FALSE, 2, 2, 8, SR_KHZ(10), SR_GHZ(1), - SR_KHZ(10), SR_MHZ(500), 1, "Use Channels 0~1 (Max 1GHz)", "使用通道 0~1 (最大采样率 1GHz)"} + SR_KHZ(10), SR_MHZ(500), 1, "Use Channels 0~1 (Max 1GHz)"} }; /* hardware Capabilities */ @@ -1083,7 +1037,7 @@ struct DSL_context { gboolean stream; uint8_t test_mode; uint16_t buf_options; - enum CHANNEL_ID ch_mode; + enum DSL_CHANNEL_ID ch_mode; uint16_t samplerates_min_index; uint16_t samplerates_max_index; uint16_t th_level; @@ -1140,8 +1094,6 @@ struct DSL_context { gboolean overflow; int bw_limit; int empty_poll_count; - - int language; }; /* diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index 8d213074..4db45030 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -38,7 +38,8 @@ static const char *maxHeights[] = { "5X", }; -enum { +enum DSLOGIC_OPERATION_MODE +{ /** Buffer mode */ OP_BUFFER = 0, /** Stream mode */ @@ -51,27 +52,13 @@ enum { OP_LPTEST = 4, }; -static const char *opmodes_cn[] = { - "Buffer模式", - "Stream模式", - "内部测试", - "外部测试", - "内存回环测试", -}; - -static const char *bufoptions_cn[] = { - "立即停止", - "上传已采集的数据", -}; - -static const char *thresholds_cn[] = { - "1.8/2.5/3.3V Level", - "5.0V Level", -}; - -static const char *filters_cn[] = { - "无", - "1个采样周期", +/** Device buffer mode */ +enum DSLOGIC_BUFFER_OPT_MODE +{ + /** Stop immediately */ + SR_BUF_STOP = 0, + /** Upload captured data */ + SR_BUF_UPLOAD = 1, }; static const char *opmodes[] = { @@ -97,6 +84,24 @@ static const char *filters[] = { "1 Sample Clock", }; +static struct lang_text_map_item opmodes_map[] = +{ + {SR_CONF_OPERATION_MODE, OP_BUFFER, "Buffer Mode", "Buffer模式"}, + {SR_CONF_OPERATION_MODE, OP_STREAM, "Stream Mode", "Stream模式"}, + {SR_CONF_OPERATION_MODE, OP_INTEST, "Internal Test", "内部测试"}, + {SR_CONF_OPERATION_MODE, OP_EXTEST, "External Test", "外部测试"}, + {SR_CONF_OPERATION_MODE, OP_LPTEST, "DRAM Loopback Test", "内存回环测试"}, + + {SR_CONF_BUFFER_OPTIONS, SR_BUF_STOP, "Stop immediately", "立即停止"}, + {SR_CONF_BUFFER_OPTIONS, SR_BUF_UPLOAD, "Upload captured data", "上传已采集的数据"}, + + {SR_CONF_THRESHOLD, SR_TH_3V3, "1.8/2.5/3.3V Level", NULL}, + {SR_CONF_THRESHOLD, SR_TH_5V0, "5.0V Level", NULL}, + + {SR_CONF_FILTER, SR_FILTER_NONE, "None", "无"}, + {SR_CONF_FILTER, SR_FILTER_1T, "1 Sample Clock", "1个采样周期"}, +}; + static const int32_t hwoptions[] = { SR_CONF_OPERATION_MODE, SR_CONF_BUFFER_OPTIONS, @@ -164,38 +169,6 @@ static uint16_t opmodes_show_count = 3; SR_PRIV struct sr_dev_driver DSLogic_driver_info; static struct sr_dev_driver *di = &DSLogic_driver_info; -static const char ** get_opmodes(struct DSL_context *devc) -{ - if (devc->language == LANGUAGE_CN) - return opmodes_cn; - else - return opmodes; -} - -static const char ** get_bufoptions(struct DSL_context *devc) -{ - if (devc->language == LANGUAGE_CN) - return bufoptions_cn; - else - return bufoptions; -} - -static const char ** get_thresholds(struct DSL_context *devc) -{ - if (devc->language == LANGUAGE_CN) - return thresholds_cn; - else - return thresholds; -} - -static const char ** get_filters(struct DSL_context *devc) -{ - if (devc->language == LANGUAGE_CN) - return filters_cn; - else - return filters; -} - static struct DSL_context *DSLogic_dev_new(const struct DSL_profile *prof) { struct DSL_context *devc; @@ -615,12 +588,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_OPERATION_MODE: if (!sdi) return SR_ERR; - *data = g_variant_new_string(get_opmodes(devc)[devc->op_mode]); + *data = g_variant_new_string(opmodes[devc->op_mode]); break; case SR_CONF_FILTER: if (!sdi) return SR_ERR; - *data = g_variant_new_string(get_filters(devc)[devc->filter]); + *data = g_variant_new_string(filters[devc->filter]); break; case SR_CONF_RLE: if (!sdi) @@ -647,15 +620,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_BUFFER_OPTIONS: if (!sdi) return SR_ERR; - *data = g_variant_new_string(get_bufoptions(devc)[devc->buf_options]); + *data = g_variant_new_string(bufoptions[devc->buf_options]); break; case SR_CONF_CHANNEL_MODE: if (!sdi) return SR_ERR; - if (devc->language == LANGUAGE_CN) - *data = g_variant_new_string(channel_modes[devc->ch_mode].descr_cn); - else - *data = g_variant_new_string(channel_modes[devc->ch_mode].descr); + *data = g_variant_new_string(channel_modes[devc->ch_mode].descr); break; case SR_CONF_MAX_HEIGHT: if (!sdi) @@ -670,7 +640,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_THRESHOLD: if (!sdi) return SR_ERR; - *data = g_variant_new_string(get_thresholds(devc)[devc->th_level]); + *data = g_variant_new_string(thresholds[devc->th_level]); break; case SR_CONF_VTH: if (!sdi) @@ -744,13 +714,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, ret = SR_OK; if (id == SR_CONF_CLOCK_TYPE) { devc->clock_type = g_variant_get_boolean(data); - } else if (id == SR_CONF_RLE_SUPPORT) { + } + else if (id == SR_CONF_RLE_SUPPORT) { devc->rle_support = g_variant_get_boolean(data); - } else if (id == SR_CONF_CLOCK_EDGE) { + } + else if (id == SR_CONF_CLOCK_EDGE) { devc->clock_edge = g_variant_get_boolean(data); - } else if (id == SR_CONF_LIMIT_SAMPLES) { + } + else if (id == SR_CONF_LIMIT_SAMPLES) { devc->limit_samples = g_variant_get_uint64(data); - } else if (id == SR_CONF_PROBE_VDIV) { + } + else if (id == SR_CONF_PROBE_VDIV) { ch->vdiv = g_variant_get_uint64(data); if (sdi->mode != LOGIC) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_PROBE_VDIV)); @@ -761,13 +735,16 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting VDIV of channel %d to %d mv failed", __func__, ch->index, ch->vdiv); - } else if (id == SR_CONF_PROBE_FACTOR) { + } + else if (id == SR_CONF_PROBE_FACTOR) { ch->vfactor = g_variant_get_uint64(data); sr_dbg("%s: setting Factor of channel %d to %d", __func__, ch->index, ch->vfactor); - } else if (id == SR_CONF_TIMEBASE) { + } + else if (id == SR_CONF_TIMEBASE) { devc->timebase = g_variant_get_uint64(data); - } else if (id == SR_CONF_PROBE_COUPLING) { + } + else if (id == SR_CONF_PROBE_COUPLING) { ch->coupling = g_variant_get_byte(data); if (ch->coupling == SR_GND_COUPLING) ch->coupling = SR_DC_COUPLING; @@ -780,7 +757,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting AC COUPLING of channel %d to %d failed", __func__, ch->index, ch->coupling); - } else if (id == SR_CONF_TRIGGER_SLOPE) { + } + else if (id == SR_CONF_TRIGGER_SLOPE) { devc->trigger_slope = g_variant_get_byte(data); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SLOPE)); @@ -791,7 +769,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting DSO Trigger Slope to %d failed", __func__, devc->trigger_slope); - } else if (id == SR_CONF_TRIGGER_VALUE) { + } + else if (id == SR_CONF_TRIGGER_VALUE) { ch->trig_value = g_variant_get_byte(data); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_TRIGGER_VALUE)); @@ -802,7 +781,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting DSO Trigger Value to %d failed", __func__, ch->index, ch->trig_value); - } else if (id == SR_CONF_HORIZ_TRIGGERPOS) { + } + else if (id == SR_CONF_HORIZ_TRIGGERPOS) { if (sdi->mode == DSO) { devc->trigger_hrate = g_variant_get_byte(data); //devc->trigger_hpos = devc->trigger_hrate * dsl_en_ch_num(sdi) * devc->limit_samples / 200.0; @@ -820,7 +800,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } else { devc->trigger_hpos = g_variant_get_byte(data) * devc->limit_samples / 100.0; } - } else if (id == SR_CONF_TRIGGER_HOLDOFF) { + } + else if (id == SR_CONF_TRIGGER_HOLDOFF) { devc->trigger_holdoff = g_variant_get_uint64(data); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_HOLDOFF)); @@ -831,7 +812,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting Trigger Holdoff Time to %d failed", __func__, devc->trigger_holdoff); - } else if (id == SR_CONF_TRIGGER_MARGIN) { + } + else if (id == SR_CONF_TRIGGER_MARGIN) { devc->trigger_margin = g_variant_get_byte(data); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_MARGIN)); @@ -842,27 +824,31 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting Trigger Margin to %d failed", __func__, devc->trigger_margin); - } else if (id == SR_CONF_SAMPLERATE) { + } + else if (id == SR_CONF_SAMPLERATE) { if (devc->test_mode == SR_TEST_NONE) { devc->cur_samplerate = g_variant_get_uint64(data); if(sdi->mode != LOGIC) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, 0, SR_CONF_SAMPLERATE)); } } - } else if (id == SR_CONF_FILTER) { + } + else if (id == SR_CONF_FILTER) { stropt = g_variant_get_string(data, NULL); - if (!strcmp(stropt, get_filters(devc)[SR_FILTER_NONE])) { + if (!strcmp(stropt, filters[SR_FILTER_NONE])) { devc->filter = SR_FILTER_NONE; - } else if (!strcmp(stropt, get_filters(devc)[SR_FILTER_1T])) { + } else if (!strcmp(stropt, filters[SR_FILTER_1T])) { devc->filter = SR_FILTER_1T; } else { ret = SR_ERR; } sr_dbg("%s: setting filter to %d", __func__, devc->filter); - } else if (id == SR_CONF_RLE) { + } + else if (id == SR_CONF_RLE) { devc->rle_mode = g_variant_get_boolean(data); - } else if (id == SR_CONF_INSTANT) { + } + else if (id == SR_CONF_INSTANT) { if (sdi->mode == DSO) { devc->instant = g_variant_get_boolean(data); if (dsl_en_ch_num(sdi) != 0) { @@ -872,7 +858,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, devc->limit_samples = devc->profile->dev_caps.dso_depth / dsl_en_ch_num(sdi); } } - } else if (id == SR_CONF_DEVICE_MODE) { + } + else if (id == SR_CONF_DEVICE_MODE) { sdi->mode = g_variant_get_int16(data); if (sdi->mode == LOGIC) { dsl_wr_reg(sdi, CTR0_ADDR, bmSCOPE_CLR); @@ -886,7 +873,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, break; } } - } else if (sdi->mode == DSO) { + } + else if (sdi->mode == DSO) { dsl_wr_reg(sdi, CTR0_ADDR, bmSCOPE_SET); ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_DSO_SYNC)); if (ret != SR_OK) @@ -903,7 +891,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } } devc->limit_samples = devc->profile->dev_caps.dso_depth / num_probes; - } else if (sdi->mode == ANALOG) { + } + else if (sdi->mode == ANALOG) { dsl_wr_reg(sdi, CTR0_ADDR, bmSCOPE_SET); ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_DSO_SYNC)); if (ret != SR_OK) @@ -920,7 +909,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, break; } } - } else { + } + else { ret = SR_ERR; } assert(num_probes != 0); @@ -934,7 +924,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else if (id == SR_CONF_OPERATION_MODE) { stropt = g_variant_get_string(data, NULL); if (sdi->mode == LOGIC) { - if (!strcmp(stropt, get_opmodes(devc)[OP_BUFFER])) { + if (!strcmp(stropt, opmodes[OP_BUFFER])) { if (devc->op_mode != OP_BUFFER) { devc->op_mode = OP_BUFFER; devc->test_mode = SR_TEST_NONE; @@ -948,7 +938,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } } } - } else if (!strcmp(stropt, get_opmodes(devc)[OP_STREAM])) { + } + else if (!strcmp(stropt, opmodes[OP_STREAM])) { if (devc->op_mode != OP_STREAM) { devc->op_mode = OP_STREAM; devc->test_mode = SR_TEST_NONE; @@ -962,14 +953,16 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } } } - } else if (!strcmp(stropt, get_opmodes(devc)[OP_INTEST])) { + } + else if (!strcmp(stropt, opmodes[OP_INTEST])) { if (devc->op_mode != OP_INTEST) { devc->op_mode = OP_INTEST; devc->test_mode = SR_TEST_INTERNAL; devc->ch_mode = devc->profile->dev_caps.intest_channel; devc->stream = !(devc->profile->dev_caps.feature_caps & CAPS_FEATURE_BUF); } - } else { + } + else { ret = SR_ERR; } dsl_adjust_probes(sdi, channel_modes[devc->ch_mode].num); @@ -983,29 +976,24 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } sr_dbg("%s: setting pattern to %d", __func__, devc->op_mode); - } else if (id == SR_CONF_BUFFER_OPTIONS) { + } + else if (id == SR_CONF_BUFFER_OPTIONS) { stropt = g_variant_get_string(data, NULL); if (sdi->mode == LOGIC) { - if (!strcmp(stropt, get_bufoptions(devc)[SR_BUF_STOP])) + if (!strcmp(stropt, bufoptions[SR_BUF_STOP])) devc->buf_options = SR_BUF_STOP; - else if (!strcmp(stropt, get_bufoptions(devc)[SR_BUF_UPLOAD])) + else if (!strcmp(stropt, bufoptions[SR_BUF_UPLOAD])) devc->buf_options = SR_BUF_UPLOAD; } - } else if (id == SR_CONF_CHANNEL_MODE) { + } + else if (id == SR_CONF_CHANNEL_MODE) { stropt = g_variant_get_string(data, NULL); if (sdi->mode == LOGIC) { for (i = 0; i < ARRAY_SIZE(channel_modes); i++) { if (devc->profile->dev_caps.channels & (1 << i)) { - if (devc->language == LANGUAGE_CN) { - if (!strcmp(stropt, channel_modes[i].descr_cn)) { - devc->ch_mode = channel_modes[i].id; - break; - } - } else { - if (!strcmp(stropt, channel_modes[i].descr)) { - devc->ch_mode = channel_modes[i].id; - break; - } + if (!strcmp(stropt, channel_modes[i].descr)) { + devc->ch_mode = channel_modes[i].id; + break; } } } @@ -1014,13 +1002,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } sr_dbg("%s: setting channel mode to %d", __func__, devc->ch_mode); - } else if (id == SR_CONF_THRESHOLD) { + } + else if (id == SR_CONF_THRESHOLD) { if (sdi->mode == LOGIC) { stropt = g_variant_get_string(data, NULL); - if (strcmp(stropt, get_thresholds(devc)[devc->th_level])) { - if (!strcmp(stropt, get_thresholds(devc)[SR_TH_3V3])) { + if (strcmp(stropt, thresholds[devc->th_level])) { + if (!strcmp(stropt, thresholds[SR_TH_3V3])) { devc->th_level = SR_TH_3V3; - } else if (!strcmp(stropt, get_thresholds(devc)[SR_TH_5V0])) { + } else if (!strcmp(stropt, thresholds[SR_TH_5V0])) { devc->th_level = SR_TH_5V0; } else { ret = SR_ERR; @@ -1051,10 +1040,12 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, sr_dbg("%s: setting threshold to %d", __func__, devc->th_level); } - } else if (id == SR_CONF_VTH) { + } + else if (id == SR_CONF_VTH) { devc->vth = g_variant_get_double(data); ret = dsl_wr_reg(sdi, VTH_ADDR, (uint8_t)(devc->vth/5.0*255)); - } else if (id == SR_CONF_MAX_HEIGHT) { + } + else if (id == SR_CONF_MAX_HEIGHT) { stropt = g_variant_get_string(data, NULL); for (i = 0; i < ARRAY_SIZE(maxHeights); i++) { if (!strcmp(stropt, maxHeights[i])) { @@ -1064,7 +1055,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, } sr_dbg("%s: setting Signal Max Height to %d", __func__, devc->max_height); - } else if (id == SR_CONF_PROBE_EN) { + } + else if (id == SR_CONF_PROBE_EN) { ch->enabled = g_variant_get_boolean(data); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_PROBE_EN)); @@ -1083,11 +1075,13 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting ENABLE of channel %d to %d", __func__, ch->index, ch->enabled); - } else if (id == SR_CONF_PROBE_OFFSET) { + } + else if (id == SR_CONF_PROBE_OFFSET) { ch->offset = g_variant_get_uint16(data); sr_dbg("%s: setting OFFSET of channel %d to %d", __func__, ch->index, ch->offset); - } else if (id == SR_CONF_TRIGGER_SOURCE) { + } + else if (id == SR_CONF_TRIGGER_SOURCE) { devc->trigger_source = g_variant_get_byte(data); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SOURCE)); @@ -1098,7 +1092,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting DSO Trigger Source to %d failed", __func__, devc->trigger_source); - } else if (id == SR_CONF_TRIGGER_CHANNEL) { + } + else if (id == SR_CONF_TRIGGER_CHANNEL) { devc->trigger_source = (g_variant_get_byte(data) << 4) + (devc->trigger_source & 0x0f); if (sdi->mode == DSO) { ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, NULL, SR_CONF_TRIGGER_SOURCE)); @@ -1109,9 +1104,11 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, else sr_dbg("%s: setting DSO Trigger Source to %d failed", __func__, devc->trigger_source); - } else if (id == SR_CONF_STREAM) { + } + else if (id == SR_CONF_STREAM) { devc->stream = g_variant_get_boolean(data); - } else { + } + else { ret = SR_ERR_NA; } @@ -1150,10 +1147,10 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, sessions, ARRAY_SIZE(sessions)*sizeof(int32_t), TRUE, NULL, NULL); break; case SR_CONF_OPERATION_MODE: - *data = g_variant_new_strv(get_opmodes(devc), opmodes_show_count); + *data = g_variant_new_strv(opmodes, opmodes_show_count); break; case SR_CONF_BUFFER_OPTIONS: - *data = g_variant_new_strv(get_bufoptions(devc), ARRAY_SIZE(bufoptions)); + *data = g_variant_new_strv(bufoptions, ARRAY_SIZE(bufoptions)); break; case SR_CONF_CHANNEL_MODE: g_variant_builder_init(&gvb, G_VARIANT_TYPE("as")); @@ -1162,19 +1159,16 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, devc->profile->dev_caps.channels & (1 << i)) { if (devc->test_mode != SR_TEST_NONE && devc->profile->dev_caps.intest_channel != channel_modes[i].id) continue; - if (devc->language == LANGUAGE_CN) - g_variant_builder_add(&gvb, "s", channel_modes[i].descr_cn); - else - g_variant_builder_add(&gvb, "s", channel_modes[i].descr); + g_variant_builder_add(&gvb, "s", channel_modes[i].descr); } } *data = g_variant_builder_end(&gvb); break; case SR_CONF_THRESHOLD: - *data = g_variant_new_strv(get_thresholds(devc), ARRAY_SIZE(thresholds)); + *data = g_variant_new_strv(thresholds, ARRAY_SIZE(thresholds)); break; case SR_CONF_FILTER: - *data = g_variant_new_strv(get_filters(devc), ARRAY_SIZE(filters)); + *data = g_variant_new_strv(filters, ARRAY_SIZE(filters)); break; case SR_CONF_MAX_HEIGHT: *data = g_variant_new_strv(maxHeights, ARRAY_SIZE(maxHeights)); diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index cb1c45c4..ffc852ea 100644 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -280,9 +280,6 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_TEST: *data = g_variant_new_boolean(FALSE); break; - case SR_CONF_LANGUAGE: - *data = g_variant_new_int16(devc->language); - break; case SR_CONF_INSTANT: *data = g_variant_new_boolean(devc->instant); break; @@ -578,10 +575,6 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, ch->map_max = g_variant_get_double(data); ret = SR_OK; } - else if (id == SR_CONF_LANGUAGE) { - devc->language = g_variant_get_int16(data); - ret = SR_OK; - } else { ret = SR_ERR_NA; } diff --git a/libsigrok4DSL/hardware/demo/demo.h b/libsigrok4DSL/hardware/demo/demo.h index 23c90296..483b8000 100644 --- a/libsigrok4DSL/hardware/demo/demo.h +++ b/libsigrok4DSL/hardware/demo/demo.h @@ -75,14 +75,14 @@ static const uint64_t vdivs10to2000[] = { 0, }; -enum CHANNEL_ID { +enum DEMO_CHANNEL_ID { DEMO_LOGIC100x16 = 0, DEMO_ANALOG10x2, DEMO_DSO200x2, }; struct DEMO_channels { - enum CHANNEL_ID id; + enum DEMO_CHANNEL_ID id; enum OPERATION_MODE mode; enum CHANNEL_TYPE type; @@ -111,7 +111,7 @@ struct demo_context { int64_t starttime; int stop; uint64_t timebase; - enum CHANNEL_ID ch_mode; + enum DEMO_CHANNEL_ID ch_mode; uint16_t samplerates_min_index; uint16_t samplerates_max_index; gboolean instant; @@ -128,8 +128,6 @@ struct demo_context { uint16_t trigger_edge; uint8_t trigger_slope; uint8_t trigger_source; - - int language; }; static const uint64_t samplerates[] = { diff --git a/libsigrok4DSL/hwdriver.c b/libsigrok4DSL/hwdriver.c index 5f90b934..aeb2281a 100644 --- a/libsigrok4DSL/hwdriver.c +++ b/libsigrok4DSL/hwdriver.c @@ -44,84 +44,47 @@ * @{ */ static struct sr_config_info sr_config_info_data[] = { - {SR_CONF_CONN, SR_T_CHAR, "conn", - "Connection", "Connection", "连接", NULL}, - {SR_CONF_SERIALCOMM, SR_T_CHAR, "serialcomm", - "Serial communication", "Serial communication", "串口通讯", NULL}, - {SR_CONF_SAMPLERATE, SR_T_UINT64, "samplerate", - "Sample rate", "Sample rate", "采样率", NULL}, - {SR_CONF_LIMIT_SAMPLES, SR_T_UINT64, "samplecount", - "Sample count", "Sample count", "采样深度", NULL}, - {SR_CONF_ACTUAL_SAMPLES, SR_T_UINT64, "samplecount", - "Sample count", "Sample count", "实际采样数", NULL}, - {SR_CONF_CLOCK_TYPE, SR_T_BOOL, "clocktype", - "Using External Clock", "Using External Clock", "使用外部输入时钟采样", NULL}, - {SR_CONF_CLOCK_EDGE, SR_T_BOOL, "clockedge", - "Using Clock Negedge", "Using Clock Negedge", "使用时钟下降沿采样", NULL}, - {SR_CONF_CAPTURE_RATIO, SR_T_UINT64, "captureratio", - "Pre-trigger capture ratio", "Pre-trigger capture ratio", "触发前采样比例", NULL}, - {SR_CONF_PATTERN_MODE, SR_T_CHAR, "pattern", - "Pattern mode", "Pattern mode", "信号模式", NULL}, - {SR_CONF_RLE, SR_T_BOOL, "rle", - "Run Length Encoding", "Run Length Encoding", "RLE编码", NULL}, - {SR_CONF_WAIT_UPLOAD, SR_T_BOOL, "buf_upload", - "Wait Buffer Upload", "Wait Buffer Upload", "上传已采集数据", NULL}, - {SR_CONF_TRIGGER_SLOPE, SR_T_UINT8, "triggerslope", - "Trigger slope", "Trigger slope", "触发沿", NULL}, - {SR_CONF_TRIGGER_SOURCE, SR_T_UINT8, "triggersource", - "Trigger source", "Trigger source", "触发源", NULL}, - {SR_CONF_TRIGGER_CHANNEL, SR_T_UINT8, "triggerchannel", - "Trigger channel", "Trigger channel", "触发通道", NULL}, - {SR_CONF_HORIZ_TRIGGERPOS, SR_T_UINT8, "horiz_triggerpos", - "Horizontal trigger position", "Horizontal trigger position", "触发位置", NULL}, - {SR_CONF_TRIGGER_HOLDOFF, SR_T_UINT64, "triggerholdoff", - "Trigger hold off", "Trigger hold off", "触发释抑时间", NULL}, - {SR_CONF_TRIGGER_MARGIN, SR_T_UINT8, "triggermargin", - "Trigger margin", "Trigger margin", "触发灵敏度", NULL}, - {SR_CONF_BUFFERSIZE, SR_T_UINT64, "buffersize", - "Buffer size", "Buffer size", "缓存大小", NULL}, - {SR_CONF_TIMEBASE, SR_T_UINT64, "timebase", - "Time base", "Time base", "时基", NULL}, - {SR_CONF_MAX_HEIGHT, SR_T_CHAR, "height", - "Max Height", "Max Height", "最大高度", NULL}, - {SR_CONF_MAX_HEIGHT_VALUE, SR_T_UINT8, "height", - "Max Height", "Max Height", "最大高度值", NULL}, - {SR_CONF_FILTER, SR_T_CHAR, "filter", - "Filter Targets", "Filter Targets", "滤波器设置", NULL}, - {SR_CONF_DATALOG, SR_T_BOOL, "datalog", - "Datalog", "Datalog", "数据记录", NULL}, - {SR_CONF_OPERATION_MODE, SR_T_CHAR, "operation", - "Operation Mode", "Operation Mode", "运行模式", NULL}, - {SR_CONF_BUFFER_OPTIONS, SR_T_CHAR, "stopoptions", - "Stop Options", "Stop Options", "停止选项", NULL}, - {SR_CONF_CHANNEL_MODE, SR_T_CHAR, "channel", - "Channel Mode", "Channel Mode", "通道模式", NULL}, - {SR_CONF_THRESHOLD, SR_T_CHAR, "threshold", - "Threshold Level", "Threshold Level", "阈值电压", NULL}, - {SR_CONF_VTH, SR_T_FLOAT, "threshold", - "Threshold Level", "Threshold Level", "阈值电压", NULL}, - {SR_CONF_RLE_SUPPORT, SR_T_BOOL, "rle", - "Enable RLE Compress", "Enable RLE Compress", "RLE硬件压缩", NULL}, - {SR_CONF_BANDWIDTH_LIMIT, SR_T_CHAR, "bandwidth", - "Bandwidth Limit", "Bandwidth Limit", "带宽限制", NULL}, - - {SR_CONF_PROBE_COUPLING, SR_T_CHAR, "coupling", - "Coupling", "Coupling", "耦合", NULL}, - {SR_CONF_PROBE_VDIV, SR_T_RATIONAL_VOLT, "vdiv", - "Volts/div", "Volts/div", "电压/格", NULL}, - {SR_CONF_PROBE_FACTOR, SR_T_UINT64, "factor", - "Probe Factor", "Probe Factor", "探头衰减", NULL}, - {SR_CONF_PROBE_MAP_DEFAULT, SR_T_BOOL, "mdefault", - "Map Default", "Map Default", "默认电压", NULL}, - {SR_CONF_PROBE_MAP_UNIT, SR_T_CHAR, "munit", - "Map Unit", "Map Unit", "对应单位", NULL}, - {SR_CONF_PROBE_MAP_MIN, SR_T_FLOAT, "MMIN", - "Map Min", "Map Min", "对应最小值", NULL}, - {SR_CONF_PROBE_MAP_MAX, SR_T_FLOAT, "MMAX", - "Map Max", "Map Max", "对应最大值", NULL}, - {0, 0, NULL, NULL, NULL, NULL, NULL}, + {SR_CONF_CONN, SR_T_CHAR, "Connection"}, + {SR_CONF_SERIALCOMM, SR_T_CHAR,"Serial communication"}, + {SR_CONF_SAMPLERATE, SR_T_UINT64,"Sample rate"}, + {SR_CONF_LIMIT_SAMPLES, SR_T_UINT64,"Sample depth"}, + {SR_CONF_ACTUAL_SAMPLES, SR_T_UINT64,"Sample count"}, + {SR_CONF_CLOCK_TYPE, SR_T_BOOL,"Using External Clock"}, + {SR_CONF_CLOCK_EDGE, SR_T_BOOL, "Using Clock Negedge"}, + {SR_CONF_CAPTURE_RATIO, SR_T_UINT64,"Pre-trigger capture ratio"}, + {SR_CONF_PATTERN_MODE, SR_T_CHAR,"Pattern mode"}, + {SR_CONF_RLE, SR_T_BOOL,"Run Length Encoding"}, + {SR_CONF_WAIT_UPLOAD, SR_T_BOOL,"Wait Buffer Upload"}, + {SR_CONF_TRIGGER_SLOPE, SR_T_UINT8,"Trigger slope"}, + {SR_CONF_TRIGGER_SOURCE, SR_T_UINT8,"Trigger source"}, + {SR_CONF_TRIGGER_CHANNEL, SR_T_UINT8,"Trigger channel"}, + {SR_CONF_HORIZ_TRIGGERPOS, SR_T_UINT8,"Horizontal trigger position"}, + {SR_CONF_TRIGGER_HOLDOFF, SR_T_UINT64,"Trigger hold off"}, + {SR_CONF_TRIGGER_MARGIN, SR_T_UINT8,"Trigger margin"}, + {SR_CONF_BUFFERSIZE, SR_T_UINT64,"Buffer size"}, + {SR_CONF_TIMEBASE, SR_T_UINT64,"Time base"}, + {SR_CONF_MAX_HEIGHT, SR_T_CHAR,"Max Height"}, + {SR_CONF_MAX_HEIGHT_VALUE, SR_T_UINT8,"Max Height value"}, + {SR_CONF_FILTER, SR_T_CHAR,"Filter Targets"}, + {SR_CONF_DATALOG, SR_T_BOOL,"Datalog"}, + {SR_CONF_OPERATION_MODE, SR_T_CHAR,"Operation Mode"}, + {SR_CONF_BUFFER_OPTIONS, SR_T_CHAR,"Stop Options"}, + {SR_CONF_CHANNEL_MODE, SR_T_CHAR,"Channel Mode"}, + {SR_CONF_THRESHOLD, SR_T_CHAR,"Threshold Levels"}, + {SR_CONF_VTH, SR_T_FLOAT,"Threshold Level"}, + {SR_CONF_RLE_SUPPORT, SR_T_BOOL,"Enable RLE Compress"}, + {SR_CONF_BANDWIDTH_LIMIT, SR_T_CHAR,"Bandwidth Limit"}, + {SR_CONF_PROBE_COUPLING, SR_T_CHAR,"Coupling"}, + {SR_CONF_PROBE_VDIV, SR_T_RATIONAL_VOLT,"Volts/div"}, + {SR_CONF_PROBE_FACTOR, SR_T_UINT64,"Probe Factor"}, + {SR_CONF_PROBE_MAP_DEFAULT, SR_T_BOOL,"Map Default"}, + {SR_CONF_PROBE_MAP_UNIT, SR_T_CHAR,"Map Unit"}, + {SR_CONF_PROBE_MAP_MIN, SR_T_FLOAT,"Map Min"}, + {SR_CONF_PROBE_MAP_MAX, SR_T_FLOAT,"Map Max"}, + {0, 0, NULL, NULL}, }; + /** @cond PRIVATE */ #ifdef HAVE_LA_DEMO extern SR_PRIV struct sr_dev_driver demo_driver_info; @@ -154,6 +117,12 @@ SR_PRIV struct sr_dev_driver **sr_driver_list(void) return drivers_list; } +SR_API int ds_map_lang_text_id(int conf_id, int item_id, char *text) +{ + + return -1; +} + /** * Initialize a hardware driver. * @@ -387,26 +356,6 @@ SR_PRIV int sr_status_get(const struct sr_dev_inst *sdi, return ret; } -/** - * Get status about an acquisition. - * - * @param optname The configuration key. - * - * @return A pointer to a struct sr_config_info, or NULL if the key - * was not found. - */ -SR_PRIV const struct sr_config_info *sr_config_info_name_get(const char *optname) -{ - int i; - - for (i = 0; sr_config_info_data[i].key; i++) { - if (!strcmp(sr_config_info_data[i].id, optname)) - return &sr_config_info_data[i]; - } - - return NULL; -} - /* Unnecessary level of indirection follows. */ /** @private */ diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c index 8729c209..1b527af0 100644 --- a/libsigrok4DSL/lib_main.c +++ b/libsigrok4DSL/lib_main.c @@ -898,16 +898,6 @@ SR_API const struct sr_config_info *ds_get_actived_device_config_info(int key) return sr_config_info_get(key); } -SR_API const struct sr_config_info *ds_get_actived_device_config_info_by_name(const char *optname) -{ - if (lib_ctx.actived_device_instance == NULL) - { - sr_err("%s", "Have no actived device."); - return SR_ERR_CALL_STATUS; - } - return sr_config_info_name_get(optname); -} - SR_API int ds_get_actived_device_status(struct sr_status *status, gboolean prg) { if (lib_ctx.actived_device_instance == NULL) diff --git a/libsigrok4DSL/libsigrok-internal.h b/libsigrok4DSL/libsigrok-internal.h index 7727e500..947cdc62 100644 --- a/libsigrok4DSL/libsigrok-internal.h +++ b/libsigrok4DSL/libsigrok-internal.h @@ -82,6 +82,13 @@ enum sr_dev_driver_type DRIVER_TYPE_HARDWARE = 2 }; +struct lang_text_map_item{ + int config_id; + int id; + char *en_name; + char *cn_name; +}; + struct sr_dev_driver { /* Driver-specific */ char *name; @@ -413,7 +420,6 @@ SR_PRIV int sr_config_list(const struct sr_dev_driver *driver, const struct sr_channel_group *cg, int key, GVariant **data); SR_PRIV const struct sr_config_info *sr_config_info_get(int key); -SR_PRIV const struct sr_config_info *sr_config_info_name_get(const char *optname); SR_PRIV int sr_status_get(const struct sr_dev_inst *sdi, struct sr_status *status, gboolean prg); SR_PRIV struct sr_config *sr_config_new(int key, GVariant *data); SR_PRIV void sr_config_free(struct sr_config *src); diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 2607d1a0..0e0a7daf 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -100,6 +100,7 @@ enum { #define SAMPLES_ALIGN 1023ULL +#define STR_ID(id) #id /* Handy little macros */ #define SR_HZ(n) (n) @@ -180,6 +181,7 @@ enum { SR_T_RATIONAL_PERIOD, SR_T_RATIONAL_VOLT, SR_T_KEYVALUE, + SR_T_LIST, }; /** Value for sr_datafeed_packet.type. */ @@ -681,13 +683,9 @@ struct sr_config { }; struct sr_config_info { - int key; - int datatype; - char *id; + int key; + int datatype; char *name; - char *label; - char *label_cn; - char *description; }; struct sr_status { @@ -744,7 +742,8 @@ struct sr_status { uint32_t ch1_acc_mean_p3; }; -enum sr_config_option_id{ +enum sr_config_option_id +{ /*--- Device classes ------------------------------------------------*/ /** The device can act as logic analyzer. */ @@ -1017,9 +1016,6 @@ enum sr_config_option_id{ /** The device supports setting the number of data blocks. */ SR_CONF_NUM_BLOCKS = 30104, - /** language (string code) **/ - SR_CONF_LANGUAGE = 30105, - /*--- Acquisition modes ---------------------------------------------*/ /** @@ -1095,16 +1091,8 @@ enum { SR_TEST_LOOPBACK, }; -/** Device buffer mode */ -enum { - /** Stop immediately */ - SR_BUF_STOP = 0, - /** Upload captured data */ - SR_BUF_UPLOAD = 1, -}; - /** Device threshold level. */ -enum { +enum DSL_THRESHOLD_LEVEL{ /** 1.8/2.5/3.3 level */ SR_TH_3V3 = 0, /** 5.0 level */ @@ -1162,8 +1150,86 @@ struct ds_trigger_pos { uint32_t status; }; +enum DSL_CHANNEL_ID { + DSL_STREAM20x16 = 0, + DSL_STREAM25x12, + DSL_STREAM50x6, + DSL_STREAM100x3, - + DSL_STREAM20x16_3DN2, + DSL_STREAM25x12_3DN2, + DSL_STREAM50x6_3DN2, + DSL_STREAM100x3_3DN2, + + DSL_STREAM10x32_32_3DN2, + DSL_STREAM20x16_32_3DN2, + DSL_STREAM25x12_32_3DN2, + DSL_STREAM50x6_32_3DN2, + DSL_STREAM100x3_32_3DN2, + + DSL_STREAM50x32, + DSL_STREAM100x30, + DSL_STREAM250x12, + DSL_STREAM125x16_16, + DSL_STREAM250x12_16, + DSL_STREAM500x6, + DSL_STREAM1000x3, + + DSL_BUFFER100x16, + DSL_BUFFER200x8, + DSL_BUFFER400x4, + + DSL_BUFFER250x32, + DSL_BUFFER500x16, + DSL_BUFFER1000x8, + + DSL_ANALOG10x2, + DSL_ANALOG10x2_500, + + DSL_DSO200x2, + DSL_DSO1000x2, +}; + +static char* DSL_CHANNEL_ID_NAMES[] = +{ + "DSL_STREAM20x16", + "DSL_STREAM25x12", + "DSL_STREAM50x6", + "DSL_STREAM100x3", + + "DSL_STREAM20x16_3DN2", + "DSL_STREAM25x12_3DN2", + "DSL_STREAM50x6_3DN2", + "DSL_STREAM100x3_3DN2", + + "DSL_STREAM10x32_32_3DN2", + "DSL_STREAM20x16_32_3DN2", + "DSL_STREAM25x12_32_3DN2", + "DSL_STREAM50x6_32_3DN2", + "DSL_STREAM100x3_32_3DN2", + + "DSL_STREAM50x32", + "DSL_STREAM100x30", + "DSL_STREAM250x12", + "DSL_STREAM125x16_16", + "DSL_STREAM250x12_16", + "DSL_STREAM500x6", + "DSL_STREAM1000x3", + + "DSL_BUFFER100x16", + "DSL_BUFFER200x8", + "DSL_BUFFER400x4", + + "DSL_BUFFER250x32", + "DSL_BUFFER500x16", + "DSL_BUFFER1000x8", + + "DSL_ANALOG10x2", + "DSL_ANALOG10x2_500", + + "DSL_DSO200x2", + "DSL_DSO1000x2", +}; /*--- input/input.c ---------------------------------------------------------*/ diff --git a/libsigrok4DSL/session_driver.c b/libsigrok4DSL/session_driver.c index 168b29a7..770dffc0 100644 --- a/libsigrok4DSL/session_driver.c +++ b/libsigrok4DSL/session_driver.c @@ -97,8 +97,7 @@ static void get_file_short_name(const char *file, char *buf, int buflen) } struct session_vdev -{ - int language; +{ int version; unzFile archive; // zip document int capfile; // current inner file open status @@ -526,12 +525,6 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, switch (id) { - case SR_CONF_LANGUAGE: - if (!sdi) - return SR_ERR; - vdev = sdi->priv; - *data = g_variant_new_int16(vdev->language); - break; case SR_CONF_SAMPLERATE: if (sdi) { @@ -756,9 +749,6 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, switch (id) { - case SR_CONF_LANGUAGE: - vdev->language = g_variant_get_int16(data); - break; case SR_CONF_SAMPLERATE: vdev->samplerate = g_variant_get_uint64(data); samplerates[0] = vdev->samplerate;