2
0
forked from Ivasoft/DSView

Improve the hardware abstraction layer

This commit is contained in:
DreamSourceLab
2018-07-08 17:48:18 +08:00
parent c7cba6a79b
commit 856e1803a7
105 changed files with 2745 additions and 2944 deletions

View File

@@ -66,5 +66,6 @@
<file>icons/manual.png</file>
<file>icons/bug.png</file>
<file>icons/support.png</file>
<file>icons/showDoc.png</file>
</qresource>
</RCC>

BIN
DSView/icons/showDoc.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -33,6 +33,8 @@
#include <QFile>
#include <QDir>
#include <QTranslator>
#include <QSettings>
#include <QDesktopServices>
#include "dsapplication.h"
#include "pv/devicemanager.h"
@@ -158,6 +160,7 @@ int main(int argc, char *argv[])
qss.close();
w.show();
w.readSettings();
w.show_doc();
// Run the application
ret = a.exec();

View File

@@ -273,9 +273,9 @@ void AnalogSnapshot::append_payload_to_envelope_levels()
// Break off if there are no new samples to compute
if (e0.ring_length == prev_length)
return;
continue;
if (e0.length == 0)
return;
continue;
reallocate_envelope(e0);

View File

@@ -174,7 +174,7 @@ void MathStack::calc_fft()
boost::shared_ptr<pv::data::Dso> data;
boost::shared_ptr<pv::view::DsoSignal> dsoSig;
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (dsoSig->get_index() == _index && dsoSig->enabled()) {
data = dsoSig->dso_data();
break;

View File

@@ -69,12 +69,12 @@ QString Device::format_device_title() const
assert(_sdi);
if (_sdi->vendor && _sdi->vendor[0]) {
s << _sdi->vendor;
if ((_sdi->model && _sdi->model[0]) ||
(_sdi->version && _sdi->version[0]))
s << ' ';
}
// if (_sdi->vendor && _sdi->vendor[0]) {
// s << _sdi->vendor;
// if ((_sdi->model && _sdi->model[0]) ||
// (_sdi->version && _sdi->version[0]))
// s << ' ';
// }
if (_sdi->model && _sdi->model[0]) {
s << _sdi->model;

View File

@@ -174,7 +174,7 @@ double DevInst::get_sample_time()
return sample_time;
}
GSList* DevInst::get_dev_mode_list()
const GSList* DevInst::get_dev_mode_list()
{
assert(_owner);
sr_dev_inst *const sdi = dev_inst();

View File

@@ -107,7 +107,7 @@ public:
* @return The returned device mode list from the driver, or NULL if the
* mode list could not be read.
*/
GSList* get_dev_mode_list();
const GSList *get_dev_mode_list();
/**
* @brief Get the device name from the driver

View File

@@ -58,8 +58,8 @@ About::About(QWidget *parent) :
QString thanks = tr("<font size=16>Special Thanks</font><br />"
"<a href=\"%1\" style=\"color:#C0C0C0\">All backers on kickstarter</a><br />"
"<a href=\"%1\" style=\"color:#C0C0C0\">All members of Sigrok project</a><br />"
"All contributors of open-source projects</a><br />"
"<a href=\"%2\" style=\"color:#C0C0C0\">All members of Sigrok project</a><br />"
"All contributors of all open-source projects</a><br />"
"<br /><br />")
.arg("https://www.kickstarter.com/projects/dreamsourcelab/dslogic-multifunction-instruments-for-everyone")
.arg("http://sigrok.org/");

View File

@@ -48,10 +48,11 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
_props_box->setLayout(get_property_form(_props_box));
_layout.addWidget(_props_box);
QGroupBox *dynamic_box = new QGroupBox(dynamic_widget(_dynamic_layout),
_dynamic_box = new QGroupBox(dynamic_widget(_dynamic_layout),
this);
dynamic_box->setLayout(&_dynamic_layout);
_layout.addWidget(dynamic_box);
_dynamic_box->setLayout(&_dynamic_layout);
_layout.addWidget(_dynamic_box);
_dynamic_box->setVisible(_dynamic_box->title() != NULL);
_layout.addStretch(1);
_layout.addWidget(&_button_box);
@@ -333,6 +334,7 @@ void DeviceOptions::mode_check()
if (mode != _mode) {
dynamic_widget(_dynamic_layout);
_dynamic_box->setVisible(_dynamic_box->title() != NULL);
_mode = mode;
}
}
@@ -356,9 +358,12 @@ void DeviceOptions::mode_check()
void DeviceOptions::channel_check()
{
QRadioButton* sc=dynamic_cast<QRadioButton*>(sender());
QString text = sc->text();
text.remove('&');
if(sc != NULL)
_dev_inst->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, g_variant_new_string(sc->text().toUtf8().data()));
_dev_inst->set_config(NULL, NULL, SR_CONF_CHANNEL_MODE, g_variant_new_string(text.toUtf8().data()));
dynamic_widget(_dynamic_layout);
_dynamic_box->setVisible(_dynamic_box->title() != NULL);
}
void DeviceOptions::channel_enable()
@@ -424,20 +429,27 @@ QString DeviceOptions::dynamic_widget(QGridLayout& inner_layout) {
logic_probes(inner_layout);
return tr("Channels");
} else if (_dev_inst->dev_inst()->mode == DSO) {
_config_button = new QPushButton(tr("Auto Calibration"), this);
inner_layout.addWidget(_config_button, 0, 0, 1, 1);
connect(_config_button, SIGNAL(clicked()), this, SLOT(zero_adj()));
_cali_button = new QPushButton(tr("Manual Calibration"), this);
inner_layout.addWidget(_cali_button, 1, 0, 1, 1);
connect(_cali_button, SIGNAL(clicked()), this, SLOT(on_calibration()));
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_HAVE_ZERO);
if (gvar != NULL) {
bool have_zero = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
return tr("Calibration");
if (have_zero) {
_config_button = new QPushButton(tr("Auto Calibration"), this);
inner_layout.addWidget(_config_button, 0, 0, 1, 1);
connect(_config_button, SIGNAL(clicked()), this, SLOT(zero_adj()));
_cali_button = new QPushButton(tr("Manual Calibration"), this);
inner_layout.addWidget(_cali_button, 1, 0, 1, 1);
connect(_cali_button, SIGNAL(clicked()), this, SLOT(on_calibration()));
return tr("Calibration");
}
}
} else if (_dev_inst->dev_inst()->mode == ANALOG) {
analog_probes(inner_layout);
return tr("Channels");
} else {
return tr("Undefined");
}
return NULL;
}
void DeviceOptions::analog_probes(QGridLayout &layout)

View File

@@ -86,6 +86,7 @@ private:
QVBoxLayout _layout;
toolbars::TitleBar *_titlebar;
QGroupBox *_dynamic_box;
QGridLayout _dynamic_layout;
QVector <QLabel *> _probes_label_list;
QVector <QCheckBox *> _probes_checkBox_list;

View File

@@ -57,7 +57,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
// setup _ch_combobox
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
_ch_combobox->addItem(dsoSig->get_name(), qVariantFromValue(dsoSig->get_index()));
}
}
@@ -77,7 +77,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
std::vector<int> dbv_ranges;
BOOST_FOREACH(const boost::shared_ptr<view::Trace> t, _session.get_math_signals()) {
boost::shared_ptr<view::MathTrace> mathTrace;
if (mathTrace = dynamic_pointer_cast<view::MathTrace>(t)) {
if ((mathTrace = dynamic_pointer_cast<view::MathTrace>(t))) {
windows = mathTrace->get_math_stack()->get_windows_support();
length = mathTrace->get_math_stack()->get_length_support();
view_modes = mathTrace->get_view_modes_support();
@@ -127,7 +127,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
// load current settings
BOOST_FOREACH(const boost::shared_ptr<view::Trace> t, _session.get_math_signals()) {
boost::shared_ptr<view::MathTrace> mathTrace;
if (mathTrace = dynamic_pointer_cast<view::MathTrace>(t)) {
if ((mathTrace = dynamic_pointer_cast<view::MathTrace>(t))) {
if (mathTrace->enabled()) {
_en_checkbox->setChecked(true);
for (int i = 0; i < _ch_combobox->count(); i++) {
@@ -216,7 +216,7 @@ void FftOptions::accept()
BOOST_FOREACH(const boost::shared_ptr<view::Trace> t, _session.get_math_signals()) {
boost::shared_ptr<view::MathTrace> mathTrace;
if (mathTrace = dynamic_pointer_cast<view::MathTrace>(t)) {
if ((mathTrace = dynamic_pointer_cast<view::MathTrace>(t))) {
mathTrace->set_enable(false);
if (mathTrace->get_index() == _ch_combobox->currentData().toInt()) {
mathTrace->get_math_stack()->set_dc_ignore(_dc_checkbox->isChecked());

View File

@@ -54,7 +54,7 @@ Search::Search(QWidget *parent, SigSession &session, std::map<uint16_t, QString>
_session.get_signals()) {
assert(sig);
boost::shared_ptr<view::LogicSignal> logic_sig;
if (logic_sig = boost::dynamic_pointer_cast<view::LogicSignal>(sig)) {
if ((logic_sig = boost::dynamic_pointer_cast<view::LogicSignal>(sig))) {
QLineEdit *search_lineEdit = new QLineEdit(this);
if (pattern.find(logic_sig->get_index()) != pattern.end())
search_lineEdit->setText(pattern[logic_sig->get_index()]);
@@ -115,7 +115,7 @@ std::map<uint16_t, QString> Search::get_pattern()
_session.get_signals()) {
assert(sig);
boost::shared_ptr<view::LogicSignal> logic_sig;
if (logic_sig = boost::dynamic_pointer_cast<view::LogicSignal>(sig)) {
if ((logic_sig = boost::dynamic_pointer_cast<view::LogicSignal>(sig))) {
pattern[logic_sig->get_index()] = _search_lineEdit_vec[index]->text();
index++;
}

View File

@@ -356,7 +356,7 @@ void DsoTriggerDock::init()
channel_comboBox->clear();
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
channel_comboBox->addItem(dsoSig->get_name(), qVariantFromValue(dsoSig->get_index()));
}
}

View File

@@ -254,6 +254,7 @@ void MeasureDock::cursor_moving()
void MeasureDock::reCalc()
{
cursor_update();
update_dist();
update_edge();
}

View File

@@ -22,6 +22,8 @@
#include "mainframe.h"
#include "toolbars/titlebar.h"
#include "dialogs/dsmessagebox.h"
#include "dialogs/dsdialog.h"
#include "mainwindow.h"
#include <QVBoxLayout>
@@ -30,9 +32,14 @@
#include <QHoverEvent>
#include <QPixmap>
#include <QPainter>
#include <QLabel>
#include <QDialogButtonBox>
#include <QBitmap>
#include <QResizeEvent>
#include <QDesktopWidget>
#include <QDesktopServices>
#include <QPushButton>
#include <QMessageBox>
#include <QApplication>
#include <algorithm>
@@ -357,8 +364,8 @@ void MainFrame::readSettings()
QSettings settings;
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect deskRect = desktopWidget->availableGeometry();
QPoint default_upleft = QPoint((deskRect.width() - minWidth)/2, (deskRect.height() - minHeight)/2);
QSize default_size = QSize(minWidth, minHeight);
QPoint default_upleft = QPoint((deskRect.width() - defWidth)/2, (deskRect.height() - defHeight)/2);
QSize default_size = QSize(defWidth, defHeight);
settings.beginGroup("MainFrame");
bool isMax = settings.value("isMax", false).toBool();
@@ -386,4 +393,47 @@ void MainFrame::readSettings()
}
}
void MainFrame::setTaskbarProgress(int progress)
{
(void)progress;
}
void MainFrame::show_doc()
{
const QString DOC_KEY("ShowDocuments");
QSettings settings;
if (!settings.contains(DOC_KEY)) {
dialogs::DSDialog dlg(this);
dlg.setTitle(tr("Document"));
QLabel tipsLabel;
tipsLabel.setPixmap(QPixmap(":/icons/showDoc.png"));
QMessageBox msg;
msg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
msg.setContentsMargins(0, 0, 0, 0);
connect(&msg, SIGNAL(buttonClicked(QAbstractButton*)), &dlg, SLOT(accept()));
QPushButton *noMoreButton = msg.addButton(tr("Not Show Again"), QMessageBox::ActionRole);
msg.addButton(tr("Ignore"), QMessageBox::ActionRole);
QPushButton *openButton = msg.addButton(tr("Open"), QMessageBox::ActionRole);
QVBoxLayout layout;
layout.addWidget(&tipsLabel);
layout.addWidget(&msg, 0, Qt::AlignRight);
layout.setContentsMargins(0, 0, 0, 0);
dlg.layout()->addLayout(&layout);
dlg.exec();
if (msg.clickedButton() == openButton) {
QDir dir(DS_RES_PATH);
dir.cdUp();
QDesktopServices::openUrl(
QUrl("file:///"+dir.absolutePath() + "/ug.pdf"));
}
if (msg.clickedButton() == noMoreButton)
settings.setValue(DOC_KEY, false);
}
}
} // namespace pv

View File

@@ -38,12 +38,19 @@ namespace toolbars {
class TitleBar;
}
namespace dialogs {
class DSMessageBox;
class DSDialog;
}
class MainFrame : public QFrame
{
Q_OBJECT
public:
static const int minWidth = 800;
static const int minHeight = 680;
static const int minWidth = 600;
static const int minHeight = 500;
static const int defWidth = 900;
static const int defHeight = 680;
public:
static const int Margin = 5;
@@ -77,6 +84,8 @@ public slots:
void showNormal();
void showMaximized();
void showMinimized();
void show_doc();
void setTaskbarProgress(int progress);
private:
void hide_border();

View File

@@ -43,6 +43,7 @@
#include <QDockWidget>
#include <QDebug>
#include <QDesktopWidget>
#include <QDesktopServices>
#include <QKeyEvent>
#include <QEvent>
#include <QtGlobal>
@@ -176,12 +177,12 @@ void MainWindow::setup_ui()
SLOT(run_stop()));
connect(_sampling_bar, SIGNAL(instant_stop()), this,
SLOT(instant_stop()));
connect(_sampling_bar, SIGNAL(sample_count_changed()), _trigger_widget,
connect(_sampling_bar, SIGNAL(duration_changed()), _trigger_widget,
SLOT(device_updated()));
connect(_sampling_bar, SIGNAL(duration_changed()), _view,
SLOT(timebase_changed()));
connect(_sampling_bar, SIGNAL(show_calibration()), _view,
SLOT(show_calibration()));
connect(_sampling_bar, SIGNAL(hide_calibration()), _view,
SLOT(hide_calibration()));
connect(_dso_trigger_widget, SIGNAL(set_trig_pos(int)), _view,
SLOT(set_trig_pos(int)));
connect(_view, SIGNAL(auto_trig(int)), _dso_trigger_widget,
@@ -252,7 +253,11 @@ void MainWindow::setup_ui()
SLOT(reCalc()));
connect(&_session, SIGNAL(repeat_resume()), this,
SLOT(repeat_resume()));
connect(&_session, SIGNAL(update_capture()), _view,
SLOT(update_hori_res()), Qt::DirectConnection);
connect(&_session, SIGNAL(cur_samplerate_changed()), _measure_widget,
SLOT(cursor_update()));
connect(_view, SIGNAL(cursor_update()), _measure_widget,
SLOT(cursor_update()));
connect(_view, SIGNAL(cursor_moving()), _measure_widget,
@@ -307,11 +312,11 @@ void MainWindow::update_device_list()
shared_ptr<pv::device::DevInst> selected_device = _session.get_device();
_device_manager.add_device(selected_device);
_sampling_bar->set_device_list(_device_manager.devices(), selected_device);
_session.init_signals();
_sampling_bar->set_device_list(_device_manager.devices(), selected_device);
shared_ptr<pv::device::File> file_dev;
if(file_dev = dynamic_pointer_cast<pv::device::File>(selected_device)) {
if((file_dev = dynamic_pointer_cast<pv::device::File>(selected_device))) {
#ifdef ENABLE_DECODE
// load decoders
StoreSession ss(_session);
@@ -457,7 +462,7 @@ void MainWindow::run_stop()
_session.start_capture(false,
boost::bind(&MainWindow::session_error, this,
QString(tr("Capture failed")), _1));
_view->capture_init(false);
_view->capture_init();
break;
case SigSession::Running:
@@ -475,7 +480,7 @@ void MainWindow::instant_stop()
_session.start_capture(true,
boost::bind(&MainWindow::session_error, this,
QString(tr("Capture failed")), _1));
_view->capture_init(true);
_view->capture_init();
break;
case SigSession::Running:
@@ -633,6 +638,10 @@ void MainWindow::on_trigger(bool visible)
void MainWindow::commit_trigger(bool instant)
{
int i = 0;
const QString TRIG_KEY("WarnofMultiTrig");
QSettings settings;
ds_trigger_init();
if (_session.get_device()->dev_inst()->mode != LOGIC ||
@@ -645,8 +654,37 @@ void MainWindow::commit_trigger(bool instant)
{
assert(s);
boost::shared_ptr<view::LogicSignal> logicSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s))
logicSig->commit_trig();
if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(s))) {
if (logicSig->commit_trig())
i++;
}
}
if (!settings.contains(TRIG_KEY) &&
i > 1) {
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(tr("Trigger"));
msg.mBox()->setInformativeText(tr("Trigger setted on multiple channels! "
"Capture will Only triggered when all setted channels fullfill at one sample"));
msg.mBox()->setIcon(QMessageBox::Information);
QPushButton *noMoreButton = msg.mBox()->addButton(tr("Not Show Again"), QMessageBox::ActionRole);
QPushButton *cancelButton = msg.mBox()->addButton(tr("Clear Trig"), QMessageBox::ActionRole);
msg.mBox()->addButton(tr("Continue"), QMessageBox::ActionRole);
msg.exec();
if (msg.mBox()->clickedButton() == cancelButton) {
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals())
{
assert(s);
boost::shared_ptr<view::LogicSignal> logicSig;
if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(s))) {
logicSig->set_trig(view::LogicSignal::NONTRIG);
logicSig->commit_trig();
}
}
}
if (msg.mBox()->clickedButton() == noMoreButton)
settings.setValue(TRIG_KEY, false);
}
}
}
@@ -783,8 +821,6 @@ bool MainWindow::load_session(QString name)
if (!isEnabled)
probe->enabled = false;
}
_sampling_bar->update_sample_rate_selector();
_trigger_widget->device_updated();
//_session.init_signals();
_session.reload();
@@ -799,12 +835,12 @@ bool MainWindow::load_session(QString name)
s->set_name(g_strdup(obj["name"].toString().toStdString().c_str()));
boost::shared_ptr<view::LogicSignal> logicSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(s))) {
logicSig->set_trig(obj["strigger"].toDouble());
}
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
dsoSig->load_settings();
dsoSig->set_zero_vrate(obj["zeroPos"].toDouble(), true);
dsoSig->set_trig_vrate(obj["trigValue"].toDouble());
@@ -812,7 +848,7 @@ bool MainWindow::load_session(QString name)
}
boost::shared_ptr<view::AnalogSignal> analogSig;
if (analogSig = dynamic_pointer_cast<view::AnalogSignal>(s)) {
if ((analogSig = dynamic_pointer_cast<view::AnalogSignal>(s))) {
analogSig->set_zero_vrate(obj["zeroPos"].toDouble(), true);
analogSig->commit_settings();
}
@@ -822,6 +858,10 @@ bool MainWindow::load_session(QString name)
}
}
// update UI settings
_sampling_bar->update_sample_rate_selector();
_trigger_widget->device_updated();
// load trigger settings
if (sessionObj.contains("trigger")) {
_trigger_widget->set_session(sessionObj["trigger"].toObject());
@@ -898,12 +938,12 @@ bool MainWindow::store_session(QString name)
s_obj["colour"] = QJsonValue::fromVariant(s->get_colour());
boost::shared_ptr<view::LogicSignal> logicSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(s))) {
s_obj["strigger"] = logicSig->get_trig();
}
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
s_obj["vdiv"] = QJsonValue::fromVariant(static_cast<qulonglong>(dsoSig->get_vDialValue()));
s_obj["vfactor"] = QJsonValue::fromVariant(static_cast<qulonglong>(dsoSig->get_factor()));
s_obj["coupling"] = dsoSig->get_acCoupling();
@@ -912,7 +952,7 @@ bool MainWindow::store_session(QString name)
}
boost::shared_ptr<view::AnalogSignal> analogSig;
if (analogSig = dynamic_pointer_cast<view::AnalogSignal>(s)) {
if ((analogSig = dynamic_pointer_cast<view::AnalogSignal>(s))) {
s_obj["vdiv"] = QJsonValue::fromVariant(static_cast<qulonglong>(analogSig->get_vdiv()));
s_obj["coupling"] = analogSig->get_acCoupling();
s_obj["zeroPos"] = analogSig->get_zero_vrate();
@@ -992,7 +1032,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
case Qt::Key_0:
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (dsoSig->get_index() == 0)
dsoSig->set_vDialActive(!dsoSig->get_vDialActive());
else
@@ -1005,7 +1045,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
case Qt::Key_1:
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (dsoSig->get_index() == 1)
dsoSig->set_vDialActive(!dsoSig->get_vDialActive());
else
@@ -1018,7 +1058,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
case Qt::Key_Up:
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (dsoSig->get_vDialActive()) {
dsoSig->go_vDialNext();
update();
@@ -1030,7 +1070,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
case Qt::Key_Down:
BOOST_FOREACH(const shared_ptr<view::Signal> s, sigs) {
shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (dsoSig->get_vDialActive()) {
dsoSig->go_vDialPre();
update();

View File

@@ -47,7 +47,7 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
GVariant *gvar_opts, *gvar_list;
gsize num_opts;
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_CONFIGS,
if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS,
&gvar_opts) != SR_OK))
/* Driver supports no device instance options. */
return;
@@ -109,7 +109,6 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
case SR_CONF_CLOCK_TYPE:
case SR_CONF_CLOCK_EDGE:
case SR_CONF_INSTANT:
case SR_CONF_DATALOCK:
bind_bool(name, key);
break;

View File

@@ -215,11 +215,11 @@ QString ProbeOptions::print_gvariant(GVariant *const gvar)
QString ProbeOptions::print_vdiv(GVariant *const gvar)
{
uint64_t p, q;
uint64_t p, q;
g_variant_get(gvar, "t", &p);
if (p < 1000ULL) {
q = 1000;
} else if (p < 1000000ULL) {
} else {
q = 1;
p /= 1000;
}

View File

@@ -172,11 +172,10 @@ void SigSession::set_device(boost::shared_ptr<device::DevInst> dev_inst) throw(Q
_cur_samplerate = _dev_inst->get_sample_rate();
_cur_samplelimits = _dev_inst->get_sample_limit();
// if (_dev_inst->dev_inst()->mode == DSO)
// set_run_mode(Repetitive);
// else
// set_run_mode(Single);
set_run_mode(Single);
if (_dev_inst->dev_inst()->mode == DSO)
set_run_mode(Repetitive);
else
set_run_mode(Single);
} catch(const QString e) {
throw(e);
return;
@@ -289,6 +288,8 @@ void SigSession::set_cur_samplerate(uint64_t samplerate)
// MathStack
BOOST_FOREACH(const boost::shared_ptr<view::MathTrace> m, _math_traces)
m->get_math_stack()->set_samplerate(_cur_samplerate);
cur_samplerate_changed();
}
void SigSession::set_cur_samplelimits(uint64_t samplelimits)
@@ -302,8 +303,12 @@ void SigSession::capture_init()
{
if (!_instant)
set_repeating(get_run_mode() == Repetitive);
_cur_samplerate = _dev_inst->get_sample_rate();
_cur_samplelimits = _dev_inst->get_sample_limit();
// update instant setting
_dev_inst->set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(_instant));
update_capture();
set_cur_samplerate(_dev_inst->get_sample_rate());
set_cur_samplelimits(_dev_inst->get_sample_limit());
_data_updated = false;
_trigger_flag = false;
_hw_replied = false;
@@ -314,62 +319,58 @@ void SigSession::capture_init()
_noData_cnt = 0;
data_unlock();
// Init and Set sample rate for all SignalData
// Analog/Dso
if (_analog_data) {
_analog_data->init();
_analog_data->set_samplerate(_cur_samplerate);
}
if (_dso_data) {
_dso_data->init();
_dso_data->set_samplerate(_cur_samplerate);
}
// MathStack
BOOST_FOREACH(const boost::shared_ptr<view::MathTrace> m, _math_traces)
{
assert(m);
m->get_math_stack()->init();
m->get_math_stack()->set_samplerate(_cur_samplerate);
}
// container init
container_init();
// update current hw offset
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _signals)
{
assert(s);
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
dsoSig->set_zero_vrate(dsoSig->get_zero_vrate(), true);
}
boost::shared_ptr<view::AnalogSignal> analogSig;
if (analogSig = dynamic_pointer_cast<view::AnalogSignal>(s)) {
if ((analogSig = dynamic_pointer_cast<view::AnalogSignal>(s))) {
analogSig->set_zero_vrate(analogSig->get_zero_vrate(), true);
}
}
}
void SigSession::logic_init()
void SigSession::container_init()
{
// Logic
if (_logic_data) {
if (_logic_data)
_logic_data->init();
_logic_data->set_samplerate(_cur_samplerate);
}
// Group
if (_group_data) {
if (_group_data)
_group_data->init();
_group_data->set_samplerate(_cur_samplerate);
// Dso
if (_analog_data)
_analog_data->init();
// Analog
if (_dso_data)
_dso_data->init();
// MathStack
BOOST_FOREACH(const boost::shared_ptr<view::MathTrace> m, _math_traces)
{
assert(m);
m->get_math_stack()->init();
}
#ifdef ENABLE_DECODE
// DecoderModel
pv::data::DecoderModel *decoder_model = get_decoder_model();
decoder_model->setDecoderStack(NULL);
//pv::data::DecoderModel *decoder_model = get_decoder_model();
//decoder_model->setDecoderStack(NULL);
// DecoderStack
BOOST_FOREACH(const boost::shared_ptr<view::DecodeTrace> d, _decode_traces)
{
assert(d);
d->decoder()->init();
d->decoder()->set_samplerate(_cur_samplerate);
}
#endif
}
@@ -426,7 +427,7 @@ void SigSession::start_capture(bool instant,
void SigSession::stop_capture()
{
_instant = false;
data_unlock();
#ifdef ENABLE_DECODE
for (vector< boost::shared_ptr<view::DecodeTrace> >::iterator i =
_decode_traces.begin();
@@ -533,6 +534,7 @@ void SigSession::sample_thread_proc(boost::shared_ptr<device::DevInst> dev_inst,
void SigSession::check_update()
{
data_unlock();
if (_capture_state != Running)
return;
@@ -540,6 +542,7 @@ void SigSession::check_update()
data_updated();
_data_updated = false;
_noData_cnt = 0;
data_auto_unlock();
} else {
if (++_noData_cnt >= (WaitShowTime/ViewTime))
nodata_timeout();
@@ -737,7 +740,7 @@ void SigSession::reload()
while (i != _signals.end()) {
if ((*i)->get_index() == probe->index) {
boost::shared_ptr<view::LogicSignal> logicSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(*i))
if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(*i)))
signal = boost::shared_ptr<view::Signal>(
new view::LogicSignal(logicSig, _logic_data, probe));
break;
@@ -761,7 +764,7 @@ void SigSession::reload()
while (i != _signals.end()) {
if ((*i)->get_index() == probe->index) {
boost::shared_ptr<view::AnalogSignal> analogSig;
if (analogSig = dynamic_pointer_cast<view::AnalogSignal>(*i))
if ((analogSig = dynamic_pointer_cast<view::AnalogSignal>(*i)))
signal = boost::shared_ptr<view::Signal>(
new view::AnalogSignal(analogSig, _analog_data, probe));
break;
@@ -792,7 +795,7 @@ void SigSession::refresh(int holdtime)
{
boost::lock_guard<boost::mutex> lock(_data_mutex);
_data_lock = true;
data_lock();
QTimer::singleShot(holdtime, this, SLOT(data_unlock()));
if (_logic_data) {
@@ -823,6 +826,11 @@ void SigSession::refresh(int holdtime)
_data_updated = true;
}
void SigSession::data_lock()
{
_data_lock = true;
}
void SigSession::data_unlock()
{
_data_lock = false;
@@ -833,6 +841,21 @@ bool SigSession::get_data_lock()
return _data_lock;
}
void SigSession::data_auto_lock(int lock) {
_data_auto_lock = lock;
}
void SigSession::data_auto_unlock() {
if (_data_auto_lock > 0)
_data_auto_lock--;
else if (_data_auto_lock < 0)
_data_auto_lock = 0;
}
bool SigSession::get_data_auto_lock() {
return _data_auto_lock != 0;
}
void SigSession::feed_in_header(const sr_dev_inst *sdi)
{
(void)sdi;
@@ -920,7 +943,6 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic)
}
if (_cur_logic_snapshot->last_ended()) {
logic_init();
_cur_logic_snapshot->first_payload(logic, _dev_inst->get_sample_limit(), _dev_inst->dev_inst()->channels);
// @todo Putting this here means that only listeners querying
// for logic will be notified. Currently the only user of
@@ -962,7 +984,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso)
{
assert(s);
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
dsoSig->set_scale(dsoSig->get_view_rect().height());
sig_enable[dsoSig->get_index()] = dsoSig->enabled();
}
@@ -991,6 +1013,8 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso)
_trigger_flag = dso.trig_flag;
receive_data(dso.num_samples);
//data_updated();
if (!_instant)
data_lock();
_data_updated = true;
}
@@ -1032,7 +1056,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
boost::lock_guard<boost::mutex> lock(_data_mutex);
if (_data_lock)
if (_data_lock && packet->type != SR_DF_END)
return;
if (packet->type != SR_DF_END &&
packet->status != SR_PKT_OK) {
@@ -1095,10 +1119,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
_cur_group_snapshot.reset();
}
}
if (!_cur_logic_snapshot->last_ended())
_cur_logic_snapshot->capture_ended();
else if (get_run_mode() != SigSession::Repetitive)
logic_init();
_cur_logic_snapshot->capture_ended();
_cur_dso_snapshot->capture_ended();
_cur_analog_snapshot->capture_ended();
#ifdef ENABLE_DECODE
@@ -1405,7 +1426,7 @@ void SigSession::mathTraces_rebuild()
bool has_dso_signal = false;
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _signals) {
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
has_dso_signal = true;
// check already have
std::vector< boost::shared_ptr<view::MathTrace> >::iterator iter = _math_traces.begin();

View File

@@ -96,7 +96,7 @@ private:
static const int RepeatHoldDiv = 20;
public:
static const int ViewTime = 100;
static const int ViewTime = 50;
static const int WaitShowTime = 500;
public:
@@ -155,7 +155,7 @@ public:
boost::function<void (const QString)> error_handler);
void capture_init();
bool get_capture_status(bool &triggered, int &progress);
void logic_init();
void container_init();
std::set< boost::shared_ptr<data::SignalData> > get_data() const;
@@ -201,6 +201,9 @@ public:
bool get_instant();
bool get_data_lock();
void data_auto_lock(int lock);
void data_auto_unlock();
bool get_data_auto_lock();
void mathTraces_rebuild();
bool trigd() const;
@@ -307,6 +310,7 @@ private:
int _noData_cnt;
bool _data_lock;
bool _data_updated;
int _data_auto_lock;
QDateTime _trigger_time;
uint64_t _trigger_pos;
@@ -365,6 +369,10 @@ signals:
void repeat_hold(int percent);
void repeat_resume();
void cur_samplerate_changed();
void update_capture();
public slots:
void reload();
void refresh(int holdtime);
@@ -374,6 +382,7 @@ public slots:
void set_map_zoom(int index);
private slots:
void data_lock();
void data_unlock();
void check_update();
void nodata_timeout();

View File

@@ -190,7 +190,7 @@ void StoreSession::save_proc(shared_ptr<data::Snapshot> snapshot)
shared_ptr<data::AnalogSnapshot> analog_snapshot;
shared_ptr<data::DsoSnapshot> dso_snapshot;
if (logic_snapshot = boost::dynamic_pointer_cast<data::LogicSnapshot>(snapshot)) {
if ((logic_snapshot = boost::dynamic_pointer_cast<data::LogicSnapshot>(snapshot))) {
uint16_t to_save_probes = 0;
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
if (s->enabled() && logic_snapshot->has_data(s->get_index()))
@@ -330,7 +330,7 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
}
shared_ptr<data::LogicSnapshot> logic_snapshot;
if (logic_snapshot = dynamic_pointer_cast<data::LogicSnapshot>(snapshot)) {
if ((logic_snapshot = dynamic_pointer_cast<data::LogicSnapshot>(snapshot))) {
uint16_t to_save_probes = 0;
for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data;
@@ -361,7 +361,7 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
fprintf(meta, "trigger time = %lld\n", _session.get_trigger_time().toMSecsSinceEpoch());
} else if (sdi->mode == ANALOG) {
shared_ptr<data::AnalogSnapshot> analog_snapshot;
if (analog_snapshot = dynamic_pointer_cast<data::AnalogSnapshot>(snapshot)) {
if ((analog_snapshot = dynamic_pointer_cast<data::AnalogSnapshot>(snapshot))) {
uint8_t tmp_u8 = analog_snapshot->get_unit_bytes();
fprintf(meta, "bits = %d\n", tmp_u8*8);
}
@@ -373,7 +373,7 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
probe = (struct sr_channel *)l->data;
if (snapshot->has_data(probe->index)) {
if (probe->name)
fprintf(meta, "probe%d = %s\n", probecnt, probe->name);
fprintf(meta, "probe%d = %s\n", (sdi->mode == LOGIC) ? probe->index : probecnt, probe->name);
if (probe->trigger)
fprintf(meta, " trigger%d = %s\n", probecnt, probe->trigger);
if (sdi->mode == DSO) {
@@ -493,11 +493,11 @@ void StoreSession::export_proc(shared_ptr<data::Snapshot> snapshot)
shared_ptr<data::DsoSnapshot> dso_snapshot;
int channel_type;
if (logic_snapshot = boost::dynamic_pointer_cast<data::LogicSnapshot>(snapshot)) {
if ((logic_snapshot = boost::dynamic_pointer_cast<data::LogicSnapshot>(snapshot))) {
channel_type = SR_CHANNEL_LOGIC;
} else if (dso_snapshot = boost::dynamic_pointer_cast<data::DsoSnapshot>(snapshot)) {
} else if ((dso_snapshot = boost::dynamic_pointer_cast<data::DsoSnapshot>(snapshot))) {
channel_type = SR_CHANNEL_DSO;
} else if (analog_snapshot = boost::dynamic_pointer_cast<data::AnalogSnapshot>(snapshot)) {
} else if ((analog_snapshot = boost::dynamic_pointer_cast<data::AnalogSnapshot>(snapshot))) {
channel_type = SR_CHANNEL_ANALOG;
} else {
_has_error = true;

View File

@@ -118,7 +118,7 @@ void LogoBar::on_actionAbout_triggered()
void LogoBar::on_actionManual_triggered()
{
QDir dir(DS_RES_PATH);
dir.cdUp();
dir.cdUp();
QDesktopServices::openUrl(
QUrl("file:///"+dir.absolutePath() + "/ug.pdf"));
}

View File

@@ -260,7 +260,7 @@ void SamplingBar::zero_adj()
boost::shared_ptr<view::DsoSignal> dsoSig;
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals())
{
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)))
dsoSig->set_enable(true);
}
run_stop();
@@ -269,7 +269,7 @@ void SamplingBar::zero_adj()
if (wait.start() ==QDialog::Rejected) {
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals())
{
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)))
dsoSig->commit_settings();
}
}
@@ -427,6 +427,7 @@ void SamplingBar::update_sample_count_selector()
uint64_t hw_depth = 0;
uint64_t sw_depth;
uint64_t rle_depth = 0;
uint64_t max_timebase = 0;
double pre_duration = SR_SEC(1);
double duration;
bool rle_support = false;
@@ -474,6 +475,12 @@ void SamplingBar::update_sample_count_selector()
}
if (rle_support)
rle_depth = min(hw_depth*SR_KB(1), sw_depth);
} else if (dev_inst->dev_inst()->mode == DSO) {
gvar = dev_inst->get_config(NULL, NULL, SR_CONF_MAX_TIMEBASE);
if (gvar != NULL) {
max_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
}
if (0 != _sample_count.count())
@@ -484,7 +491,7 @@ void SamplingBar::update_sample_count_selector()
_sample_rate.currentIndex()).value<uint64_t>();
const double hw_duration = hw_depth / (samplerate * (1.0 / SR_SEC(1)));
if (dev_inst->dev_inst()->mode == DSO)
duration = SR_SEC(10);
duration = max_timebase;
else if (stream_mode)
duration = sw_depth / (samplerate * (1.0 / SR_SEC(1)));
else if (rle_support)
@@ -492,10 +499,11 @@ void SamplingBar::update_sample_count_selector()
else
duration = hw_duration;
assert(duration > 0);
bool not_last = true;
do {
QString suffix = (dev_inst->dev_inst()->mode == DSO) ? DIVString :
(!stream_mode & duration > hw_duration) ? RLEString : "";
(!stream_mode && duration > hw_duration) ? RLEString : "";
char *const s = sr_time_string(duration);
_sample_count.addItem(QString(s) + suffix,
qVariantFromValue(duration));
@@ -526,6 +534,9 @@ void SamplingBar::update_sample_count_selector()
if (dev_inst->dev_inst()->mode == DSO)
not_last = duration >= SR_NS(10);
else if (dev_inst->dev_inst()->mode == ANALOG)
not_last = (duration >= SR_MS(100)) &&
(duration / SR_SEC(1) * samplerate >= SR_KB(1));
else
not_last = (duration / SR_SEC(1) * samplerate >= SR_KB(1));
} while(not_last);
@@ -542,11 +553,11 @@ void SamplingBar::update_sample_count_selector()
_sample_count.setCurrentIndex(i);
break;
}
sample_count_changed();
}
_updating_sample_count = false;
update_sample_count_selector_value();
on_samplecount_sel(_sample_count.currentIndex());
connect(&_sample_count, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_samplecount_sel(int)));
}
@@ -604,8 +615,7 @@ void SamplingBar::on_samplecount_sel(int index)
const shared_ptr<device::DevInst> dev_inst = get_selected_device();
if (dev_inst->dev_inst()->mode == DSO)
commit_hori_res();
else
sample_count_changed();
duration_changed();
}
double SamplingBar::get_hori_res()
@@ -616,6 +626,9 @@ double SamplingBar::get_hori_res()
double SamplingBar::hori_knob(int dir)
{
double hori_res = -1;
disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_samplecount_sel(int)));
if (0 == dir) {
hori_res = commit_hori_res();
} else if ((dir > 0) && (_sample_count.currentIndex() > 0)) {
@@ -625,6 +638,10 @@ double SamplingBar::hori_knob(int dir)
_sample_count.setCurrentIndex(_sample_count.currentIndex() + 1);
hori_res = commit_hori_res();
}
connect(&_sample_count, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_samplecount_sel(int)));
return hori_res;
}
@@ -649,7 +666,7 @@ double SamplingBar::commit_hori_res()
const uint64_t sample_rate = min((uint64_t)(sample_limit * SR_SEC(1) /
(hori_res * DS_CONF_DSO_HDIVS)),
(uint64_t)(max_sample_rate /
(_session.get_ch_num(DSO) ? _session.get_ch_num(DSO) : 1)));
(_session.get_ch_num(SR_CHANNEL_DSO) ? _session.get_ch_num(SR_CHANNEL_DSO) : 1)));
set_sample_rate(sample_rate);
if (_session.get_capture_state() != SigSession::Stopped)
_session.set_cur_samplerate(dev_inst->get_sample_rate());

View File

@@ -100,7 +100,7 @@ signals:
void instant_stop();
void device_selected();
void device_updated();
void sample_count_changed();
void duration_changed();
void show_calibration();
void hide_calibration();

View File

@@ -89,7 +89,7 @@ void TitleBar::paintEvent(QPaintEvent *)
p.setBrush(QColor(48, 47, 47, 255));
p.drawRect(rect());
const int xgap = 2.5;
const int xgap = 2;
const int xstart = 10;
p.setPen(QPen(QColor(213, 15, 37, 255), 2, Qt::SolidLine));
p.drawLine(xstart + xgap*0, height()*0.50, xstart + xgap*0, height()*0.66);

View File

@@ -112,6 +112,10 @@ int AnalogSignal::commit_settings()
{
int ret;
// -- enable
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_EN,
g_variant_new_boolean(enabled()));
// -- vdiv
ret = _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_probe->vdiv));
@@ -169,7 +173,7 @@ QString AnalogSignal::get_mapUnit() const
double AnalogSignal::get_mapMin() const
{
double min;
double min = -1;
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MIN);
if (gvar != NULL) {
min = g_variant_get_double(gvar);
@@ -180,7 +184,7 @@ double AnalogSignal::get_mapMin() const
double AnalogSignal::get_mapMax() const
{
double max;
double max = 1;
GVariant* gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_MAP_MAX);
if (gvar != NULL) {
max = g_variant_get_double(gvar);
@@ -196,14 +200,14 @@ void AnalogSignal::set_zero_vpos(int pos)
{
if (enabled()) {
const int height = get_totalHeight();
const int bottom = get_y() + height / 2;
set_zero_vrate(min(max(bottom - pos, 0), height) * 1.0 / height, false);
const int top = get_y() - height / 2;
set_zero_vrate(min(max(pos - top, 0), height) * 1.0 / height, false);
}
}
int AnalogSignal::get_zero_vpos() const
{
return (0.5 - _zero_vrate) * get_totalHeight() + get_y();
return (_zero_vrate - 0.5) * get_totalHeight() + get_y();
}
void AnalogSignal::set_zero_vrate(double rate, bool force_update)
@@ -271,7 +275,7 @@ void AnalogSignal::paint_back(QPainter &p, int left, int right)
// paint rule
double y = get_y() - height * 0.5;
double mapValue = get_mapMax() + (0.5 - _zero_vrate) * (get_mapMax() - get_mapMin());
double mapValue = get_mapMax() + (_zero_vrate - 0.5) * (get_mapMax() - get_mapMin());
for (i = 0; i < DIVS; i++) {
p.drawLine(left, y, left+10, y);
if (i == 0 || i == DIVS/2)
@@ -310,7 +314,7 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right)
const int height = get_totalHeight();
const int top = get_y() - height * 0.5;
const int bottom = get_y() + height * 0.5;
const float zeroY = bottom - _zero_vrate * height ;
const float zeroY = _zero_vrate * height + top;
const double scale = _view->scale();
assert(scale > 0);
@@ -461,10 +465,10 @@ void AnalogSignal::paint_envelope(QPainter &p,
_rects = new QRectF[width+3];
QRectF *rect = _rects;
int px = -1, pre_px;
int y_min, y_max, pre_y_min, pre_y_max;
int y_min = zeroY, y_max = zeroY, pre_y_min = zeroY, pre_y_max = zeroY;
int pcnt = 0;
const double scale_samples_pre_pixel = samples_per_pixel / e.scale;
const uint64_t ring_end = snapshot->get_ring_end() / e.scale;
const uint64_t ring_end = max((int64_t)0, (int64_t)snapshot->get_ring_end() / e.scale - 1);
// const int64_t start_offset = start_pixel -
// (int64_t)(e.start / scale_samples_pre_pixel + 0.5);
// for(uint64_t sample = 0; sample < e.length; sample++) {

View File

@@ -60,7 +60,7 @@ void DevMode::set_device()
assert(dev_inst);
for(std::map<QPushButton *, sr_dev_mode *>::const_iterator i = _mode_button_list.begin();
for(std::map<QPushButton *, const sr_dev_mode *>::const_iterator i = _mode_button_list.begin();
i != _mode_button_list.end(); i++) {
(*i).first->setParent(NULL);
_layout->removeWidget((*i).first);
@@ -68,9 +68,9 @@ void DevMode::set_device()
}
_mode_button_list.clear();
for (GSList *l = dev_inst->get_dev_mode_list();
for (const GSList *l = dev_inst->get_dev_mode_list();
l; l = l->next) {
sr_dev_mode *mode = (sr_dev_mode *)l->data;
const sr_dev_mode *mode = (const sr_dev_mode *)l->data;
QPushButton *mode_button = new QPushButton(this);
//mode_button->setFlat(true);
@@ -111,7 +111,7 @@ void DevMode::on_mode_change()
if (dev_inst->dev_inst()->mode == _mode_button_list[button]->mode)
return;
for(std::map<QPushButton *, sr_dev_mode *>::const_iterator i = _mode_button_list.begin();
for(std::map<QPushButton *, const sr_dev_mode *>::const_iterator i = _mode_button_list.begin();
i != _mode_button_list.end(); i++) {
if ((*i).first == button) {
if (dev_inst->dev_inst()->mode != (*i).second->mode) {

View File

@@ -80,7 +80,7 @@ private:
SigSession &_session;
QGridLayout * _layout;
std::map <QPushButton *, sr_dev_mode *> _mode_button_list;
std::map <QPushButton *, const sr_dev_mode *> _mode_button_list;
QPoint _mouse_point;
};

View File

@@ -41,16 +41,6 @@ using namespace std;
namespace pv {
namespace view {
const uint64_t DsoSignal::vDialValue[DsoSignal::vDialValueCount] = {
10,
20,
50,
100,
200,
500,
1000,
2000,
};
const QString DsoSignal::vDialUnit[DsoSignal::vDialUnitCount] = {
"mv",
"v",
@@ -72,6 +62,7 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
Signal(dev_inst, probe),
_data(data),
_scale(0),
_en_lock(false),
_vDialActive(false),
_autoV(false),
_autoH(false),
@@ -84,13 +75,26 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
{
QVector<uint64_t> vValue;
QVector<QString> vUnit;
for(uint64_t i = 0; i < vDialValueCount; i++)
vValue.append(vDialValue[i]);
for(uint64_t i = 0; i < vDialUnitCount; i++)
vUnit.append(vDialUnit[i]);
_vDial = new dslDial(vDialValueCount, vDialValueStep, vValue, vUnit);
GVariant *gvar_list, *gvar_list_vdivs;
if (sr_config_list(dev_inst->dev_inst()->driver, dev_inst->dev_inst(),
NULL, SR_CONF_PROBE_VDIV, &gvar_list) == SR_OK) {
assert(gvar_list);
if ((gvar_list_vdivs = g_variant_lookup_value(gvar_list,
"vdivs", G_VARIANT_TYPE("at")))) {
GVariant *gvar;
GVariantIter iter;
g_variant_iter_init(&iter, gvar_list_vdivs);
while(NULL != (gvar = g_variant_iter_next_value(&iter)))
vValue.push_back(g_variant_get_uint64(gvar));
g_variant_unref(gvar);
g_variant_unref(gvar_list_vdivs);
g_variant_unref(gvar_list);
}
}
_vDial = new dslDial(vValue.count(), vDialValueStep, vValue, vUnit);
_colour = SignalColours[probe->index % countof(SignalColours)];
load_settings();
@@ -144,6 +148,7 @@ void DsoSignal::set_enable(bool enable)
get_index() == 0)
return;
_en_lock = true;
GVariant* gvar;
bool cur_enable;
gvar = _dev_inst->get_config(_probe, NULL, SR_CONF_PROBE_EN);
@@ -151,11 +156,14 @@ void DsoSignal::set_enable(bool enable)
cur_enable = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
} else {
qDebug() << "ERROR: config_get SR_CONF_MAX_DSO_SAMPLERATE failed.";
qDebug() << "ERROR: config_get SR_CONF_PROBE_EN failed.";
_en_lock = false;
return;
}
if (cur_enable == enable)
if (cur_enable == enable) {
_en_lock = false;
return;
}
bool running = false;
if (_view->session().get_capture_state() == SigSession::Running) {
@@ -169,14 +177,14 @@ void DsoSignal::set_enable(bool enable)
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_EN,
g_variant_new_boolean(enable));
_view->update_hori_res();
if (running) {
//_view->session().refresh(RefreshShort);
_view->update_hori_res();
_view->session().repeat_resume();
}
_view->set_update(_viewport, true);
_view->update();
_en_lock = false;
}
bool DsoSignal::get_vDialActive() const
@@ -203,11 +211,12 @@ bool DsoSignal::go_vDialPre()
_scale *= pre_vdiv/_vDial->get_value();
update_vpos();
_view->update_calibration();
//_view->set_update(_viewport, true);
//_view->update();
_view->set_update(_viewport, true);
_view->update();
return true;
} else {
autoV_end();
if (_autoV)
autoV_end();
return false;
}
}
@@ -225,11 +234,12 @@ bool DsoSignal::go_vDialNext()
_scale *= pre_vdiv/_vDial->get_value();
update_vpos();
_view->update_calibration();
//_view->set_update(_viewport, true);
//_view->update();
_view->set_update(_viewport, true);
_view->update();
return true;
} else {
autoV_end();
if (_autoV)
autoV_end();
return false;
}
}
@@ -598,8 +608,8 @@ void DsoSignal::paint_back(QPainter &p, int left, int right)
p.setPen(Trace::dsLightBlue);
p.drawLine(left, UpMargin/2, left + width, UpMargin/2);
const uint64_t sample_len = _dev_inst->get_sample_limit();
const double samplerate = _dev_inst->get_sample_rate();
const uint64_t sample_len = _view->session().cur_samplelimits();
const double samplerate = _view->session().cur_samplerate();
const double samples_per_pixel = samplerate * _view->scale();
const double shown_rate = min(samples_per_pixel * width * 1.0 / sample_len, 1.0);
const double start = _view->offset() * samples_per_pixel;
@@ -917,11 +927,13 @@ void DsoSignal::paint_type_options(QPainter &p, int right, const QPoint pt)
p.drawText(acdc_rect, Qt::AlignCenter | Qt::AlignVCenter, (_acCoupling == SR_GND_COUPLING) ? tr("GND") :
(_acCoupling == SR_DC_COUPLING) ? tr("DC") : tr("AC"));
p.setPen(Qt::transparent);
p.setBrush(enabled() ? (auto_rect.contains(pt) ? _colour.darker() : _colour) : dsDisable);
p.drawRect(auto_rect);
p.setPen(Qt::white);
p.drawText(auto_rect, Qt::AlignCenter | Qt::AlignVCenter, tr("AUTO"));
if (!_dev_inst->name().contains("virtual")) {
p.setPen(Qt::transparent);
p.setBrush(enabled() ? (auto_rect.contains(pt) ? _colour.darker() : _colour) : dsDisable);
p.drawRect(auto_rect);
p.setPen(Qt::white);
p.drawText(auto_rect, Qt::AlignCenter | Qt::AlignVCenter, tr("AUTO"));
}
// paint the probe factor selector
GVariant* gvar;
@@ -962,8 +974,9 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
if (chEn_rect.contains(pt)) {
if (_dev_inst->name() != "virtual-session" &&
!_view->session().get_data_lock())
!_en_lock) {
set_enable(!enabled());
}
return true;
} else if (enabled()) {
if (vDial_rect.contains(pt) && pt.x() > vDial_rect.center().x()) {
@@ -978,7 +991,8 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
else
set_acCoupling((get_acCoupling()+1)%2);
} else if (auto_rect.contains(pt)) {
auto_start();
if (!_dev_inst->name().contains("virtual"))
auto_start();
} else if (x1_rect.contains(pt)) {
set_factor(1);
} else if (x10_rect.contains(pt)) {
@@ -1068,7 +1082,7 @@ void DsoSignal::paint_measure(QPainter &p)
double value_max = (_hw_offset - _min) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
double value_min = (_hw_offset - _max) * _scale * _vDial->get_value() * _vDial->get_factor() * DS_CONF_DSO_VDIVS / get_view_rect().height();
double value_p2p = value_max - value_min;
_period = (count == 0) ? period * 10.0 : period * 10.0 / count;
_period = (count == 0) ? 0 : period * 10.0 / count;
const int channel_count = _view->session().get_ch_num(SR_CHANNEL_DSO);
uint64_t sample_rate = _dev_inst->get_sample_rate();
_period = _period * 200.0 / (channel_count * sample_rate * 1.0 / SR_MHZ(1));
@@ -1161,7 +1175,7 @@ void DsoSignal::paint_measure(QPainter &p)
autoH_end();
}
if (_autoV && !_view->session().get_data_lock()) {
if (_autoV && !_view->session().get_data_auto_lock()) {
set_zero_vrate(0.5, true);
const uint8_t vscale = abs(_max - _min);
if (_max == 0xff || _min == 0x00 || vscale > 0xCC) {
@@ -1171,17 +1185,21 @@ void DsoSignal::paint_measure(QPainter &p)
} else {
go_vDialPre();
}
_view->session().data_auto_lock(AutoLock);
}
if (_autoH && !_view->session().get_data_lock()) {
if (_autoH && !_view->session().get_data_auto_lock()) {
const double hori_res = _view->get_hori_res();
if (_period < 1.5*hori_res) {
if (_period <= 0) {
_view->zoom(-1);
} else if (_period < 1.5*hori_res) {
_view->zoom(1);
} else if (_period > 6*hori_res) {
_view->zoom(-1);
} else {
autoH_end();
}
_view->session().data_auto_lock(AutoLock);
}
}
@@ -1215,6 +1233,7 @@ void DsoSignal::auto_start()
if (_autoV || _autoH)
return;
if (_view->session().get_capture_state() == SigSession::Running) {
_view->session().data_auto_lock(AutoLock);
_autoV = true;
_autoH = true;
QTimer::singleShot(AutoTime, this, SLOT(auto_end()));
@@ -1261,7 +1280,7 @@ bool DsoSignal::measure(const QPointF &p)
const double scale = _view->scale();
assert(scale > 0);
const int64_t pixels_offset = _view->offset();
const double samplerate = _dev_inst->get_sample_rate();
const double samplerate = _view->session().cur_samplerate();
const double samples_per_pixel = samplerate * scale;
_hover_index = floor((p.x() + pixels_offset) * samples_per_pixel+0.5);

View File

@@ -47,10 +47,8 @@ private:
static const float EnvelopeThreshold;
static const int HitCursorMargin = 3;
static const uint64_t vDialValueCount = 8;
static const uint64_t vDialValueStep = 1000;
static const uint64_t vDialUnitCount = 2;
static const uint64_t vDialValue[vDialValueCount];
static const QString vDialUnit[vDialUnitCount];
static const int UpMargin = 30;
@@ -62,6 +60,7 @@ private:
static const int RefreshShort = 200;
static const int RefreshLong = 800;
static const int AutoTime = 10000;
static const int AutoLock = 3;
public:
enum DsoSetRegions {
@@ -213,6 +212,7 @@ private:
private:
boost::shared_ptr<pv::data::Dso> _data;
float _scale;
bool _en_lock;
dslDial *_vDial;
bool _vDialActive;

View File

@@ -298,14 +298,14 @@ void Header::mouseMoveEvent(QMouseEvent *event)
int y = (*i).second + delta;
if (sig->get_type() == SR_CHANNEL_DSO) {
boost::shared_ptr<DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<DsoSignal>(sig)) {
if ((dsoSig = dynamic_pointer_cast<DsoSignal>(sig))) {
dsoSig->set_zero_vpos(y);
_moveFlag = true;
traces_moved();
}
} else if (sig->get_type() == SR_CHANNEL_ANALOG) {
boost::shared_ptr<AnalogSignal> analogSig;
if (analogSig = dynamic_pointer_cast<AnalogSignal>(sig)) {
if ((analogSig = dynamic_pointer_cast<AnalogSignal>(sig))) {
analogSig->set_zero_vpos(y);
_moveFlag = true;
traces_moved();

View File

@@ -106,12 +106,13 @@ void LogicSignal::set_trig(int trig)
_trig = NONTRIG;
}
void LogicSignal::commit_trig()
bool LogicSignal::commit_trig()
{
if (_trig == NONTRIG)
if (_trig == NONTRIG) {
ds_trigger_probe_set(_index_list.front(), 'X', 'X');
else {
return false;
} else {
ds_trigger_set_en(true);
if (_trig == POSTRIG)
ds_trigger_probe_set(_index_list.front(), 'R', 'X');
@@ -123,6 +124,7 @@ void LogicSignal::commit_trig()
ds_trigger_probe_set(_index_list.front(), '0', 'X');
else if (_trig == EDGTRIG)
ds_trigger_probe_set(_index_list.front(), 'C', 'X');
return true;
}
}

View File

@@ -55,6 +55,7 @@ private:
static const int TogMaxScale = 10;
public:
enum LogicSetRegions{
NONTRIG = 0,
POSTRIG,
@@ -86,7 +87,7 @@ public:
*/
LogicSetRegions get_trig() const;
void set_trig(int trig);
void commit_trig();
bool commit_trig();
/**
* Paints the signal with a QPainter

View File

@@ -292,7 +292,7 @@ void MathTrace::paint_mid(QPainter &p, int left, int right)
double vfactor = 0;
BOOST_FOREACH(const boost::shared_ptr<Signal> s, _session.get_signals()) {
boost::shared_ptr<DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<DsoSignal>(s))) {
if(dsoSig->get_index() == _math_stack->get_index()) {
vdiv = dsoSig->get_vDialValue();
vfactor = dsoSig->get_factor();
@@ -358,8 +358,8 @@ void MathTrace::paint_fore(QPainter &p, int left, int right)
double blank_right = width;
// horizontal ruler
const double NyFreq = _session.get_device()->get_sample_rate() / (2.0 * _math_stack->get_sample_interval());
const double deltaFreq = _session.get_device()->get_sample_rate() * 1.0 /
const double NyFreq = _session.cur_samplerate() / (2.0 * _math_stack->get_sample_interval());
const double deltaFreq = _session.cur_samplerate() * 1.0 /
(_math_stack->get_sample_num() * _math_stack->get_sample_interval());
const double FreqRange = NyFreq * _scale;
const double FreqOffset = NyFreq * _offset;

View File

@@ -220,19 +220,16 @@ double View::get_maxscale() const
return _maxscale;
}
void View::capture_init(bool instant)
void View::capture_init()
{
_maxscale = _session.cur_sampletime() / (get_view_width() * MaxViewRate);
if (_session.get_device()->dev_inst()->mode == DSO)
show_trig_cursor(true);
else if (!_session.isRepeating())
show_trig_cursor(false);
_maxscale = _session.cur_sampletime() / (get_view_width() * MaxViewRate);
if (_session.get_device()->dev_inst()->mode == ANALOG)
set_scale_offset(_maxscale, 0);
_session.get_device()->set_config(NULL, NULL, SR_CONF_INSTANT, g_variant_new_boolean(instant));
update_hori_res();
status_clear();
}
@@ -259,12 +256,9 @@ double View::get_hori_res()
void View::update_hori_res()
{
if (_session.get_device()->dev_inst()->mode == DSO)
if (_session.get_device()->dev_inst()->mode == DSO) {
_sampling_bar->hori_knob(0);
const uint64_t final_limit = _session.get_device()->get_sample_limit();
_trig_cursor->set_index(_trig_cursor->index() * 1.0 / _session.cur_samplelimits() * final_limit);
_session.set_cur_samplelimits(final_limit);
}
}
void View::zoom(double steps, int offset)
@@ -274,8 +268,7 @@ void View::zoom(double steps, int offset)
_preOffset = _offset;
if (_session.get_device()->dev_inst()->mode != DSO) {
//_scale *= std::pow(3.0/2.0, -steps);
_scale *= std::pow(2, -steps);
_scale *= std::pow(3.0/2.0, -steps);
_scale = max(min(_scale, _maxscale), _minscale);
} else {
if (_session.get_capture_state() == SigSession::Running &&
@@ -306,6 +299,18 @@ void View::zoom(double steps, int offset)
//}
}
void View::timebase_changed()
{
if (_session.get_device()->dev_inst()->mode != DSO)
return;
double scale = this->scale();
double hori_res = _sampling_bar->get_hori_res();
if (hori_res > 0)
scale = hori_res * DS_CONF_DSO_HDIVS / SR_SEC(1) / get_view_width();
set_scale_offset(scale, this->offset());
}
void View::set_scale_offset(double scale, int64_t offset)
{
//if (_session.get_capture_state() == SigSession::Stopped) {
@@ -417,6 +422,8 @@ void View::show_search_cursor(bool show)
void View::status_clear()
{
_time_viewport->clear_dso_xm();
_time_viewport->clear_measure();
_viewbottom->clear();
}
@@ -694,7 +701,7 @@ void View::signals_changed()
next_v_offset += traceHeight + 2 * SignalMargin;
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(t))) {
dsoSig->set_scale(dsoSig->get_view_rect().height());
}
}

View File

@@ -104,7 +104,7 @@ public:
int64_t get_min_offset();
int64_t get_max_offset();
void capture_init(bool instant);
void capture_init();
void zoom(double steps);
void zoom(double steps, int offset);
@@ -183,7 +183,6 @@ public:
int get_view_width();
int get_view_height();
void update_hori_res();
double get_hori_res();
QString get_measure(QString option);
@@ -244,6 +243,10 @@ public slots:
void repeat_unshow();
// -- repeat
void repeat_show();
// --
void timebase_changed();
// --
void update_hori_res();
private slots:

View File

@@ -90,6 +90,9 @@ Viewport::Viewport(View &parent, View_type type) :
_drag_strength = 0;
_drag_timer.setSingleShot(true);
_pixmap = new QPixmap(size());
_pixmap->fill(Qt::transparent);
connect(&trigger_timer, SIGNAL(timeout()),
this, SLOT(on_trigger_timer()));
connect(&_drag_timer, SIGNAL(timeout()),
@@ -183,8 +186,8 @@ void Viewport::paintEvent(QPaintEvent *event)
void Viewport::paintSignals(QPainter &p)
{
if (_view.session().get_data_lock())
return;
// if (_view.session().get_data_lock())
// return;
const vector< boost::shared_ptr<Trace> > traces(_view.get_traces(_type));
if (_view.scale() != _curScale ||
_view.offset() != _curOffset ||
@@ -194,20 +197,24 @@ void Viewport::paintSignals(QPainter &p)
_curOffset = _view.offset();
_curSignalHeight = _view.get_signalHeight();
pixmap = QPixmap(size());
pixmap.fill(Qt::transparent);
QPainter dbp(&pixmap);
dbp.initFrom(this);
//p.setRenderHint(QPainter::Antialiasing, false);
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
{
assert(t);
if (t->enabled())
t->paint_mid(dbp, 0, t->get_view_rect().width());
//pixmap = QPixmap(size());
//pixmap.fill(Qt::transparent);
if (_pixmap->size() == size()) {
_pixmap->fill(Qt::transparent);
QPainter dbp(_pixmap);
dbp.initFrom(this);
//p.setRenderHint(QPainter::Antialiasing, false);
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
{
assert(t);
if (t->enabled())
t->paint_mid(dbp, 0, t->get_view_rect().right());
}
_need_update = false;
}
_need_update = false;
}
p.drawPixmap(0, 0, pixmap);
if (_pixmap->size() == size())
p.drawPixmap(0, 0, *_pixmap);
// plot cursors
const double samples_per_pixel = _view.session().cur_samplerate() * _view.scale();
@@ -422,7 +429,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
if (!s->enabled())
continue;
boost::shared_ptr<DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<DsoSignal>(s))) {
if (dsoSig->get_ms_show_hover()) {
dsoSig->set_ms_show(!dsoSig->get_ms_show());
break;
@@ -459,7 +466,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
if (!s->enabled())
continue;
boost::shared_ptr<DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<DsoSignal>(s))) {
if (dsoSig->get_trig_rect(0, _view.get_view_width()).contains(_mouse_point)) {
_drag_sig = s;
_action_type = DSO_TRIG_MOVE;
@@ -530,7 +537,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
if (_action_type == DSO_TRIG_MOVE) {
if (_drag_sig) {
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(_drag_sig)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(_drag_sig))) {
dsoSig->set_trig_vpos(event->pos().y(), true);
_dso_trig_moved = true;
}
@@ -593,12 +600,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
BOOST_FOREACH(const boost::shared_ptr<Signal> s, _view.session().get_signals()) {
assert(s);
if (!s->get_view_rect().contains(event->pos())) {
_dso_xm_valid = false;
_mm_width = "#####";
_mm_period = "#####";
_mm_freq = "#####";
_mm_duty = "#####";
_action_type = NO_ACTION;
clear_dso_xm();
}
break;
}
@@ -723,12 +725,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_action_type = DSO_XM_STEP2;
} else if (event->button() == Qt::RightButton) {
_action_type = NO_ACTION;
_dso_xm_valid = false;
_mm_width = "#####";
_mm_period = "#####";
_mm_freq = "#####";
_mm_duty = "#####";
clear_dso_xm();
measure_updated();
}
} else if (_action_type == DSO_XM_STEP2) {
@@ -744,12 +741,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_action_type = NO_ACTION;
} else if (event->button() == Qt::RightButton) {
_action_type = NO_ACTION;
_dso_xm_valid = false;
_mm_width = "#####";
_mm_period = "#####";
_mm_freq = "#####";
_mm_duty = "#####";
clear_dso_xm();
measure_updated();
}
} else if (_action_type == CURS_MOVE) {
@@ -854,12 +846,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
_view.session().get_capture_state() != SigSession::Init &&
event->button() == Qt::LeftButton) {
if (_dso_xm_valid) {
_dso_xm_valid = false;
_action_type = NO_ACTION;
_mm_width = "#####";
_mm_period = "#####";
_mm_freq = "#####";
_mm_duty = "#####";
clear_dso_xm();
measure_updated();
} else if (_action_type == NO_ACTION) {
BOOST_FOREACH(const boost::shared_ptr<Signal> s, _view.session().get_signals()) {
@@ -906,7 +893,7 @@ void Viewport::wheelEvent(QWheelEvent *event)
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
assert(s);
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
dsoSig->auto_end();
}
}
@@ -932,19 +919,20 @@ void Viewport::leaveEvent(QEvent *)
_drag_timer.stop();
_action_type = NO_ACTION;
} else if (_action_type == DSO_XM_STEP1 || _action_type == DSO_XM_STEP2) {
_dso_xm_valid = false;
_mm_width = "#####";
_mm_period = "#####";
_mm_freq = "#####";
_mm_duty = "#####";
_action_type = NO_ACTION;
clear_dso_xm();
} else if (_action_type == DSO_YM) {
_dso_ym_valid = false;
_action_type = NO_ACTION;
}
measure();
update();
clear_measure();
}
void Viewport::resizeEvent(QResizeEvent*)
{
if (_pixmap)
delete _pixmap;
_pixmap = new QPixmap(size());
}
void Viewport::set_receive_len(quint64 length)
@@ -968,6 +956,16 @@ void Viewport::clear_measure()
update();
}
void Viewport::clear_dso_xm()
{
_dso_xm_valid = false;
_mm_width = "#####";
_mm_period = "#####";
_mm_freq = "#####";
_mm_duty = "#####";
_action_type = NO_ACTION;
}
void Viewport::measure()
{
if (_view.session().get_data_lock())
@@ -980,7 +978,7 @@ void Viewport::measure()
assert(s);
boost::shared_ptr<view::LogicSignal> logicSig;
boost::shared_ptr<view::DsoSignal> dsoSig;
if (logicSig = dynamic_pointer_cast<view::LogicSignal>(s)) {
if ((logicSig = dynamic_pointer_cast<view::LogicSignal>(s))) {
if (_action_type == NO_ACTION) {
if (logicSig->measure(_mouse_point, _cur_sample, _nxt_sample, _thd_sample)) {
_measure_type = LOGIC_FREQ;
@@ -1031,7 +1029,7 @@ void Viewport::measure()
_cur_aftY = _view.hover_point().y();
_edge_hit = false;
}
} else if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
} else if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (_measure_en && dsoSig->measure(_view.hover_point())) {
_measure_type = DSO_VALUE;
break;
@@ -1116,7 +1114,7 @@ void Viewport::paintMeasure(QPainter &p)
_measure_type == DSO_VALUE) {
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
uint64_t index;
double value;
QPointF hpoint;
@@ -1175,7 +1173,7 @@ void Viewport::paintMeasure(QPainter &p)
if (_dso_ym_valid) {
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
boost::shared_ptr<view::DsoSignal> dsoSig;
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(s)) {
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
if (dsoSig->get_index() == _dso_ym_sig_index) {
p.setPen(QPen(dsoSig->get_colour(), 1, Qt::DotLine));
const int text_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,

View File

@@ -100,6 +100,8 @@ public:
void clear_measure();
void clear_dso_xm();
void set_need_update(bool update);
bool get_dso_trig_moved() const;
@@ -114,6 +116,7 @@ private:
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void leaveEvent(QEvent *);
void resizeEvent(QResizeEvent *e);
void paintSignals(QPainter& p);
void paintProgress(QPainter& p);
@@ -139,6 +142,8 @@ private:
View_type _type;
bool _need_update;
QPixmap *_pixmap;
uint64_t _sample_received;
QPoint _mouse_point;
QPoint _mouse_down_point;
@@ -147,7 +152,7 @@ private:
int64_t _curOffset;
int _curSignalHeight;
QPixmap pixmap;
//QPixmap pixmap;
bool _measure_en;
ActionType _action_type;

Binary file not shown.

View File

@@ -2,15 +2,14 @@
"Device": "DSCope",
"DeviceMode": 1,
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "1048576",
"Sample rate": "100000000",
"Operation Mode": "正常",
"Time base": "10000",
"Trigger channel": "0",
"Trigger hold off": "0",
"Trigger margin": "8",
"Trigger slope": "0",
"Trigger source": "0",
"Version": 2,
"channel": [
{
"colour": "#eeb211",
@@ -36,5 +35,7 @@
"vfactor": 1,
"zeroPos": 0.5
}
],
"decoder": [
]
}

View File

@@ -1,10 +1,10 @@
{
"Device": "DSCope",
"DeviceMode": 1,
"DeviceMode": 2,
"Horizontal trigger position": "0",
"Operation Mode": "Normal",
"Sample count": "1048576",
"Sample rate": "100000000",
"Operation Mode": "正常",
"Sample count": "10000000",
"Sample rate": "10000000",
"Time base": "10000",
"Trigger channel": "0",
"Trigger hold off": "0",
@@ -18,24 +18,26 @@
"coupling": 0,
"enabled": true,
"index": 0,
"mapMax": 1,
"mapMin": -1,
"mapUnit": "V",
"name": "0",
"trigValue": 0.50196078431372548,
"type": 10001,
"type": 10002,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.4
"zeroPos": 0.5
},
{
"colour": "#009925",
"coupling": 0,
"enabled": true,
"index": 1,
"mapMax": 1,
"mapMin": -1,
"mapUnit": "V",
"name": "1",
"trigValue": 0.50196078431372548,
"type": 10001,
"type": 10002,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.6
"zeroPos": 0.5
}
],
"decoder": [

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
DSView/res/DSCopeC20B.bin Executable file

Binary file not shown.

BIN
DSView/res/DSCopeC20B.fw Executable file

Binary file not shown.

BIN
DSView/res/DSCopeC20P.bin Executable file

Binary file not shown.

Binary file not shown.

View File

@@ -1,12 +1,15 @@
{
"Channel Mode": "Use Channels 0~15 (Max 100MHz)",
"Channel Mode": "使用16个通道(最大采样率 20MHz)",
"Device": "DSLogic",
"DeviceMode": 0,
"Filter Targets": "None",
"Enable RLE Compress": 1,
"Filter Targets": "无",
"Horizontal trigger position": "0",
"Operation Mode": "Buffer Mode",
"Sample count": "1048576",
"Max Height": "1X",
"Operation Mode": "Stream模式",
"Sample count": "1000000",
"Sample rate": "1000000",
"Stop Options": "上传已采集的数据",
"Threshold Level": 1,
"Trigger channel": "0",
"Trigger hold off": "0",
@@ -14,7 +17,8 @@
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 1,
"Using External Clock": 0,
"Version": 2,
"channel": [
{
"colour": "#969696",
@@ -145,128 +149,130 @@
"type": 10000
}
],
"decoder": [
],
"trigger": {
"triggerChannel": 0,
"triggerClock": "X X X X X X X X X X X X X X X X",
"triggerCount00": 1,
"triggerCount01": 1,
"triggerCount010": 1,
"triggerCount011": 1,
"triggerCount012": 1,
"triggerCount013": 1,
"triggerCount014": 1,
"triggerCount015": 1,
"triggerCount02": 1,
"triggerCount03": 1,
"triggerCount04": 1,
"triggerCount05": 1,
"triggerCount06": 1,
"triggerCount07": 1,
"triggerCount08": 1,
"triggerCount09": 1,
"triggerCount10": 1,
"triggerCount11": 1,
"triggerCount110": 1,
"triggerCount111": 1,
"triggerCount112": 1,
"triggerCount113": 1,
"triggerCount114": 1,
"triggerCount115": 1,
"triggerCount12": 1,
"triggerCount13": 1,
"triggerCount14": 1,
"triggerCount15": 1,
"triggerCount16": 1,
"triggerCount17": 1,
"triggerCount18": 1,
"triggerCount19": 1,
"triggerData": "X X X X X X X X X X X X X X X X",
"triggerInv00": 0,
"triggerInv01": 0,
"triggerInv010": 0,
"triggerInv011": 0,
"triggerInv012": 0,
"triggerInv013": 0,
"triggerInv014": 0,
"triggerInv015": 0,
"triggerInv02": 0,
"triggerInv03": 0,
"triggerInv04": 0,
"triggerInv05": 0,
"triggerInv06": 0,
"triggerInv07": 0,
"triggerInv08": 0,
"triggerInv09": 0,
"triggerInv10": 0,
"triggerInv11": 0,
"triggerInv110": 0,
"triggerInv111": 0,
"triggerInv112": 0,
"triggerInv113": 0,
"triggerInv114": 0,
"triggerInv115": 0,
"triggerInv12": 0,
"triggerInv13": 0,
"triggerInv14": 0,
"triggerInv15": 0,
"triggerInv16": 0,
"triggerInv17": 0,
"triggerInv18": 0,
"triggerInv19": 0,
"triggerLogic0": 1,
"triggerLogic1": 1,
"triggerLogic10": 1,
"triggerLogic11": 1,
"triggerLogic12": 1,
"triggerLogic13": 1,
"triggerLogic14": 1,
"triggerLogic15": 1,
"triggerLogic2": 1,
"triggerLogic3": 1,
"triggerLogic4": 1,
"triggerLogic5": 1,
"triggerLogic6": 1,
"triggerLogic7": 1,
"triggerLogic8": 1,
"triggerLogic9": 1,
"triggerMode": 0,
"advTriggerMode": false,
"serialTriggerBits": 0,
"serialTriggerChannel": 0,
"serialTriggerClock": "X X X X X X X X X X X X X X X X",
"serialTriggerData": "X X X X X X X X X X X X X X X X",
"serialTriggerStart": "X X X X X X X X X X X X X X X X",
"serialTriggerStop": "X X X X X X X X X X X X X X X X",
"stageTriggerContiguous0": false,
"stageTriggerContiguous1": false,
"stageTriggerContiguous10": false,
"stageTriggerContiguous11": false,
"stageTriggerContiguous12": false,
"stageTriggerContiguous13": false,
"stageTriggerContiguous14": false,
"stageTriggerContiguous15": false,
"stageTriggerContiguous2": false,
"stageTriggerContiguous3": false,
"stageTriggerContiguous4": false,
"stageTriggerContiguous5": false,
"stageTriggerContiguous6": false,
"stageTriggerContiguous7": false,
"stageTriggerContiguous8": false,
"stageTriggerContiguous9": false,
"stageTriggerCount0": 1,
"stageTriggerCount1": 1,
"stageTriggerCount10": 1,
"stageTriggerCount11": 1,
"stageTriggerCount12": 1,
"stageTriggerCount13": 1,
"stageTriggerCount14": 1,
"stageTriggerCount15": 1,
"stageTriggerCount2": 1,
"stageTriggerCount3": 1,
"stageTriggerCount4": 1,
"stageTriggerCount5": 1,
"stageTriggerCount6": 1,
"stageTriggerCount7": 1,
"stageTriggerCount8": 1,
"stageTriggerCount9": 1,
"stageTriggerInv00": 0,
"stageTriggerInv01": 0,
"stageTriggerInv010": 0,
"stageTriggerInv011": 0,
"stageTriggerInv012": 0,
"stageTriggerInv013": 0,
"stageTriggerInv014": 0,
"stageTriggerInv015": 0,
"stageTriggerInv02": 0,
"stageTriggerInv03": 0,
"stageTriggerInv04": 0,
"stageTriggerInv05": 0,
"stageTriggerInv06": 0,
"stageTriggerInv07": 0,
"stageTriggerInv08": 0,
"stageTriggerInv09": 0,
"stageTriggerInv10": 0,
"stageTriggerInv11": 0,
"stageTriggerInv110": 0,
"stageTriggerInv111": 0,
"stageTriggerInv112": 0,
"stageTriggerInv113": 0,
"stageTriggerInv114": 0,
"stageTriggerInv115": 0,
"stageTriggerInv12": 0,
"stageTriggerInv13": 0,
"stageTriggerInv14": 0,
"stageTriggerInv15": 0,
"stageTriggerInv16": 0,
"stageTriggerInv17": 0,
"stageTriggerInv18": 0,
"stageTriggerInv19": 0,
"stageTriggerLogic0": 1,
"stageTriggerLogic1": 1,
"stageTriggerLogic10": 1,
"stageTriggerLogic11": 1,
"stageTriggerLogic12": 1,
"stageTriggerLogic13": 1,
"stageTriggerLogic14": 1,
"stageTriggerLogic15": 1,
"stageTriggerLogic2": 1,
"stageTriggerLogic3": 1,
"stageTriggerLogic4": 1,
"stageTriggerLogic5": 1,
"stageTriggerLogic6": 1,
"stageTriggerLogic7": 1,
"stageTriggerLogic8": 1,
"stageTriggerLogic9": 1,
"stageTriggerValue00": "X X X X X X X X X X X X X X X X",
"stageTriggerValue01": "X X X X X X X X X X X X X X X X",
"stageTriggerValue010": "X X X X X X X X X X X X X X X X",
"stageTriggerValue011": "X X X X X X X X X X X X X X X X",
"stageTriggerValue012": "X X X X X X X X X X X X X X X X",
"stageTriggerValue013": "X X X X X X X X X X X X X X X X",
"stageTriggerValue014": "X X X X X X X X X X X X X X X X",
"stageTriggerValue015": "X X X X X X X X X X X X X X X X",
"stageTriggerValue02": "X X X X X X X X X X X X X X X X",
"stageTriggerValue03": "X X X X X X X X X X X X X X X X",
"stageTriggerValue04": "X X X X X X X X X X X X X X X X",
"stageTriggerValue05": "X X X X X X X X X X X X X X X X",
"stageTriggerValue06": "X X X X X X X X X X X X X X X X",
"stageTriggerValue07": "X X X X X X X X X X X X X X X X",
"stageTriggerValue08": "X X X X X X X X X X X X X X X X",
"stageTriggerValue09": "X X X X X X X X X X X X X X X X",
"stageTriggerValue10": "X X X X X X X X X X X X X X X X",
"stageTriggerValue11": "X X X X X X X X X X X X X X X X",
"stageTriggerValue110": "X X X X X X X X X X X X X X X X",
"stageTriggerValue111": "X X X X X X X X X X X X X X X X",
"stageTriggerValue112": "X X X X X X X X X X X X X X X X",
"stageTriggerValue113": "X X X X X X X X X X X X X X X X",
"stageTriggerValue114": "X X X X X X X X X X X X X X X X",
"stageTriggerValue115": "X X X X X X X X X X X X X X X X",
"stageTriggerValue12": "X X X X X X X X X X X X X X X X",
"stageTriggerValue13": "X X X X X X X X X X X X X X X X",
"stageTriggerValue14": "X X X X X X X X X X X X X X X X",
"stageTriggerValue15": "X X X X X X X X X X X X X X X X",
"stageTriggerValue16": "X X X X X X X X X X X X X X X X",
"stageTriggerValue17": "X X X X X X X X X X X X X X X X",
"stageTriggerValue18": "X X X X X X X X X X X X X X X X",
"stageTriggerValue19": "X X X X X X X X X X X X X X X X",
"triggerPos": 1,
"triggerSerial": 0,
"triggerStages": 0,
"triggerStart": "X X X X X X X X X X X X X X X X",
"triggerStop": "X X X X X X X X X X X X X X X X",
"triggerValue00": "X X X X X X X X X X X X X X X X",
"triggerValue01": "X X X X X X X X X X X X X X X X",
"triggerValue010": "X X X X X X X X X X X X X X X X",
"triggerValue011": "X X X X X X X X X X X X X X X X",
"triggerValue012": "X X X X X X X X X X X X X X X X",
"triggerValue013": "X X X X X X X X X X X X X X X X",
"triggerValue014": "X X X X X X X X X X X X X X X X",
"triggerValue015": "X X X X X X X X X X X X X X X X",
"triggerValue02": "X X X X X X X X X X X X X X X X",
"triggerValue03": "X X X X X X X X X X X X X X X X",
"triggerValue04": "X X X X X X X X X X X X X X X X",
"triggerValue05": "X X X X X X X X X X X X X X X X",
"triggerValue06": "X X X X X X X X X X X X X X X X",
"triggerValue07": "X X X X X X X X X X X X X X X X",
"triggerValue08": "X X X X X X X X X X X X X X X X",
"triggerValue09": "X X X X X X X X X X X X X X X X",
"triggerValue10": "X X X X X X X X X X X X X X X X",
"triggerValue11": "X X X X X X X X X X X X X X X X",
"triggerValue110": "X X X X X X X X X X X X X X X X",
"triggerValue111": "X X X X X X X X X X X X X X X X",
"triggerValue112": "X X X X X X X X X X X X X X X X",
"triggerValue113": "X X X X X X X X X X X X X X X X",
"triggerValue114": "X X X X X X X X X X X X X X X X",
"triggerValue115": "X X X X X X X X X X X X X X X X",
"triggerValue12": "X X X X X X X X X X X X X X X X",
"triggerValue13": "X X X X X X X X X X X X X X X X",
"triggerValue14": "X X X X X X X X X X X X X X X X",
"triggerValue15": "X X X X X X X X X X X X X X X X",
"triggerValue16": "X X X X X X X X X X X X X X X X",
"triggerValue17": "X X X X X X X X X X X X X X X X",
"triggerValue18": "X X X X X X X X X X X X X X X X",
"triggerValue19": "X X X X X X X X X X X X X X X X",
"triggerVcnt": 1
"triggerTab": 0
}
}

View File

@@ -1,43 +1,49 @@
{
"Channel Mode": "Use Channels 0~15 (Max 100MHz)",
"Device": "DSLogic",
"DeviceMode": 1,
"Filter Targets": "None",
"Horizontal trigger position": "1",
"Operation Mode": "Buffer Mode",
"Sample count": "1048576",
"Sample rate": "100000000",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger margin": "8",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"channel": [
{
"colour": "#eeb211",
"coupling": 0,
"enabled": true,
"index": 0,
"name": "0",
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
},
{
"colour": "#009925",
"coupling": 0,
"enabled": true,
"index": 1,
"name": "1",
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
}
]
}
{
"Channel Mode": "使用通道 0~1 (最大采样率 200MHz)",
"Device": "DSLogic",
"DeviceMode": 1,
"Enable RLE Compress": 1,
"Filter Targets": "",
"Horizontal trigger position": "0",
"Max Height": "1X",
"Operation Mode": "Stream模式",
"Sample count": "1000000",
"Sample rate": "100000000",
"Stop Options": "上传已采集的数据",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger margin": "8",
"Trigger slope": "0",
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"Version": 2,
"channel": [
{
"colour": "#eeb211",
"coupling": 0,
"enabled": true,
"index": 0,
"name": "0",
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
},
{
"colour": "#009925",
"coupling": 0,
"enabled": true,
"index": 1,
"name": "1",
"trigValue": 0.5,
"type": 10001,
"vdiv": 1000,
"vfactor": 1,
"zeroPos": 0.5
}
],
"decoder": [
]
}

View File

@@ -1,12 +1,15 @@
{
"Channel Mode": "Use Channels 0~15 (Max 10MHz)",
"Channel Mode": "使用通道 0~1 (最大采样率 10MHz)",
"Device": "DSLogic",
"DeviceMode": 2,
"Filter Targets": "None",
"Enable RLE Compress": 1,
"Filter Targets": "无",
"Horizontal trigger position": "0",
"Operation Mode": "Stream Mode",
"Sample count": "1048576",
"Max Height": "1X",
"Operation Mode": "Stream模式",
"Sample count": "1000000",
"Sample rate": "1000000",
"Stop Options": "上传已采集的数据",
"Threshold Level": "1.8/2.5/3.3V Level",
"Trigger hold off": "0",
"Trigger margin": "8",
@@ -14,69 +17,35 @@
"Trigger source": "0",
"Using Clock Negedge": 0,
"Using External Clock": 0,
"Version": 2,
"channel": [
{
"colour": "#1185d1",
"colour": "#eeb211",
"coupling": 0,
"enabled": true,
"index": 0,
"mapMax": 1,
"mapMin": -1,
"mapUnit": "V",
"name": "0",
"type": 10002
"type": 10002,
"vdiv": 1000,
"zeroPos": 0.5
},
{
"colour": "#eeb211",
"colour": "#009925",
"coupling": 0,
"enabled": true,
"index": 1,
"mapMax": 1,
"mapMin": -1,
"mapUnit": "V",
"name": "1",
"type": 10002
},
{
"colour": "#d50f25",
"enabled": true,
"index": 2,
"name": "2",
"type": 10002
},
{
"colour": "#009925",
"enabled": true,
"index": 3,
"name": "3",
"type": 10002
},
{
"colour": "#1185d1",
"enabled": true,
"index": 4,
"name": "4",
"type": 10002
},
{
"colour": "#eeb211",
"enabled": true,
"index": 5,
"name": "5",
"type": 10002
},
{
"colour": "#d50f25",
"enabled": true,
"index": 6,
"name": "6",
"type": 10002
},
{
"colour": "#009925",
"enabled": true,
"index": 7,
"name": "7",
"type": 10002
},
{
"colour": "#1185d1",
"enabled": true,
"index": 8,
"name": "8",
"type": 10002
"type": 10002,
"vdiv": 1000,
"zeroPos": 0.5
}
],
"decoder": [
]
}

Binary file not shown.

Binary file not shown.

View File

@@ -62,6 +62,7 @@ SR_PRIV struct sr_channel *sr_channel_new(uint16_t index, int type,
probe->enabled = enabled;
if (name)
probe->name = g_strdup(name);
probe->vga_ptr = NULL;
return probe;
}
@@ -181,49 +182,6 @@ SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, uint16_t probenum,
return ret;
}
/**
* Determine whether the specified device instance has the specified
* capability.
*
* @param sdi Pointer to the device instance to be checked. Must not be NULL.
* If the device's 'driver' field is NULL (virtual device), this
* function will always return FALSE (virtual devices don't have
* a hardware capabilities list).
* @param key The option that should be checked for support on the
* specified device.
*
* @return TRUE if the device has the specified option, FALSE otherwise.
* FALSE is also returned on invalid input parameters or other
* error conditions.
*
* @since 0.1.0 (but the API changed in 0.2.0)
*/
SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key)
{
GVariant *gvar;
const int *devopts;
gsize num_opts, i;
int ret;
if (!sdi || !sdi->driver || !sdi->driver->config_list)
return FALSE;
if (sdi->driver->config_list(SR_CONF_DEVICE_OPTIONS, &gvar, sdi, NULL) != SR_OK)
return FALSE;
ret = FALSE;
devopts = g_variant_get_fixed_array(gvar, &num_opts, sizeof(int32_t));
for (i = 0; i < num_opts; i++) {
if (devopts[i] == key) {
ret = TRUE;
break;
}
}
g_variant_unref(gvar);
return ret;
}
/** @private */
SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int mode, int index, int status,
const char *vendor, const char *model, const char *version)
@@ -260,6 +218,8 @@ SR_PRIV void sr_dev_probes_free(struct sr_dev_inst *sdi)
probe = l->data;
g_free(probe->name);
g_free(probe->trigger);
if (probe->vga_ptr)
g_free(probe->vga_ptr);
g_free(probe);
}
@@ -369,7 +329,7 @@ SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver)
return NULL;
}
SR_API GSList *sr_dev_mode_list(const struct sr_dev_inst *sdi)
SR_API const GSList *sr_dev_mode_list(const struct sr_dev_inst *sdi)
{
if (sdi && sdi->driver && sdi->driver->dev_mode_list)
return sdi->driver->dev_mode_list(sdi);

View File

@@ -29,9 +29,15 @@
#define CMD_CTL_RD_PRE 0xb1
#define CMD_CTL_RD 0xb2
// read only
#define bmGPIF_DONE (1 << 7)
#define bmFPGA_DONE (1 << 6)
#define bmFPGA_INIT_B (1 << 5)
// write only
#define bmCH_CH0 (1 << 7)
#define bmCH_COM (1 << 6)
#define bmCH_CH1 (1 << 5)
// read/write
#define bmSYS_OVERFLOW (1 << 4)
#define bmSYS_CLR (1 << 3)
#define bmSYS_EN (1 << 2)
@@ -43,11 +49,31 @@
#define bmWR_WORDWIDE (1 << 0)
#define VTH_ADDR 0x78
#define EEWP_ADDR 0x70
#define CTR1_ADDR 0x71
#define CTR0_ADDR 0x70
#define COMB_ADDR 0x68
#define EXT_I2CSEL 0x71
#define FPGA_I2CADDR 0x21
#define EXT_I2CADDR 0x50
#define EI2C_ADDR 0x60
#define EI2C_CTR_OFF 0x2
#define EI2C_RXR_OFF 0x3
#define EI2C_SR_OFF 0x4
#define EI2C_TXR_OFF 0x3
#define EI2C_CR_OFF 0x4
#define EI2C_SEL_OFF 0x7
#define bmEI2C_EN (1 << 7)
#define bmEI2C_STA (1 << 7)
#define bmEI2C_STO (1 << 6)
#define bmEI2C_RD (1 << 5)
#define bmEI2C_WR (1 << 4)
#define bmEI2C_NACK (1 << 3)
#define bmEI2C_RXNACK (1 << 7)
#define bmEI2C_TIP (1 << 1)
#define EI2C_AWR 0xA0
#define EI2C_ARD 0xA1
enum {
DSL_CTL_FW_VERSION = 0,
@@ -67,7 +93,7 @@ enum {
DSL_CTL_I2C_DSO = 13,
DSL_CTL_I2C_REG = 14,
DSL_CTL_DSO_MEASURE = 15,
DSL_CTL_I2C_STATUS = 15,
DSL_CTL_DSO_EN0 = 16,
DSL_CTL_DSO_DC0 = 17,

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,169 @@ static const unsigned int total_buffer_time = 100;
static const unsigned int instant_buffer_size = 1024 * 1024;
static uint16_t test_init = 1;
static const int32_t probeOptions[] = {
SR_CONF_PROBE_COUPLING,
SR_CONF_PROBE_VDIV,
SR_CONF_PROBE_MAP_UNIT,
SR_CONF_PROBE_MAP_MIN,
SR_CONF_PROBE_MAP_MAX,
};
static const int32_t probeSessions[] = {
SR_CONF_PROBE_COUPLING,
SR_CONF_PROBE_VDIV,
SR_CONF_PROBE_MAP_UNIT,
SR_CONF_PROBE_MAP_MIN,
SR_CONF_PROBE_MAP_MAX,
};
static const uint8_t probeCoupling[] = {
SR_DC_COUPLING,
SR_AC_COUPLING,
};
const char *probeMapUnits[] = {
"V",
"A",
"",
"",
"g",
"m",
"m/s",
};
static const char *probe_names[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
NULL,
};
static struct sr_dev_mode mode_list[] = {
{"LA", LOGIC},
{"DAQ", ANALOG},
{"OSC", DSO},
};
SR_PRIV void dsl_probe_init(struct sr_dev_inst *sdi)
{
int i;
GSList *l;
struct DSL_context *devc = sdi->priv;
for (l = sdi->channels; l; l = l->next) {
struct sr_channel *probe = (struct sr_channel *)l->data;
probe->vdiv = 1000;
probe->vfactor = 1;
probe->vpos = 0;
probe->coupling = SR_DC_COUPLING;
probe->trig_value = 0x80;
probe->vpos_trans = devc->profile->dev_caps.default_pwmtrans;
probe->ms_show = TRUE;
for (i = DSO_MS_BEGIN; i < DSO_MS_END; i++)
probe->ms_en[i] = default_ms_en[i];
probe->map_unit = probeMapUnits[0];
probe->map_min = -1;
probe->map_max = 1;
if (devc->profile->dev_caps.vdivs &&
probe->vga_ptr == NULL) {
for (i = 0; devc->profile->dev_caps.vdivs[i]; i++);
probe->vga_ptr = g_try_malloc((i+1)*sizeof(struct DSL_vga));
(probe->vga_ptr + i)->id = 0;
(probe->vga_ptr + i)->key = 0;
(probe->vga_ptr + i)->vgain = 0;
(probe->vga_ptr + i)->voff = 0;
(probe->vga_ptr + i)->voff_comp = 0;
for (i = 0; devc->profile->dev_caps.vdivs[i]; i++) {
(probe->vga_ptr + i)->id = devc->profile->dev_caps.vga_id;
(probe->vga_ptr + i)->key = devc->profile->dev_caps.vdivs[i];
}
}
}
}
SR_PRIV int dsl_setup_probes(struct sr_dev_inst *sdi, int num_probes)
{
uint16_t j;
struct sr_channel *probe;
struct DSL_context *devc = sdi->priv;
for (j = 0; j < num_probes; j++) {
if (!(probe = sr_channel_new(j, channel_modes[devc->ch_mode].type,
TRUE, probe_names[j])))
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, probe);
}
dsl_probe_init(sdi);
return SR_OK;
}
SR_PRIV int dsl_adjust_probes(struct sr_dev_inst *sdi, int num_probes)
{
uint16_t j;
struct sr_channel *probe;
struct DSL_context *devc = sdi->priv;
GSList *l;
assert(num_probes > 0);
j = g_slist_length(sdi->channels);
while(j < num_probes) {
if (!(probe = sr_channel_new(j, channel_modes[devc->ch_mode].type,
TRUE, probe_names[j])))
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, probe);
j++;
}
while(j > num_probes) {
sdi->channels = g_slist_delete_link(sdi->channels, g_slist_last(sdi->channels));
j--;
}
for(l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data;
probe->enabled = TRUE;
probe->type = channel_modes[devc->ch_mode].type;
}
return SR_OK;
}
SR_PRIV const GSList *dsl_mode_list(const struct sr_dev_inst *sdi)
{
struct DSL_context *devc;
GSList *l = NULL;
unsigned int i;
devc = sdi->priv;
for (i = 0; i < ARRAY_SIZE(mode_list); i++) {
if (devc->profile->dev_caps.mode_caps & (1 << i))
l = g_slist_append(l, &mode_list[i]);
}
return l;
}
SR_PRIV void dsl_adjust_samplerate(struct DSL_context *devc)
{
devc->samplerates_max_index = ARRAY_SIZE(samplerates) - 1;
while (samplerates[devc->samplerates_max_index] >
channel_modes[devc->ch_mode].max_samplerate)
devc->samplerates_max_index--;
devc->samplerates_min_index = 0;
while (samplerates[devc->samplerates_min_index] <
channel_modes[devc->ch_mode].min_samplerate)
devc->samplerates_min_index++;
assert(devc->samplerates_max_index >= devc->samplerates_min_index);
if (devc->cur_samplerate > samplerates[devc->samplerates_max_index])
devc->cur_samplerate = samplerates[devc->samplerates_max_index];
if (devc->cur_samplerate < samplerates[devc->samplerates_min_index])
devc->cur_samplerate = samplerates[devc->samplerates_min_index];
}
SR_PRIV int dsl_en_ch_num(const struct sr_dev_inst *sdi)
{
GSList *l;
@@ -100,7 +263,6 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
struct drv_context *drvc;
struct version_info vi;
int ret, skip, i, device_count;
uint8_t revid;
struct ctl_rd_cmd rd_cmd;
uint8_t rd_cmd_data[2];
@@ -172,20 +334,11 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
vi.major = rd_cmd_data[0];
vi.minor = rd_cmd_data[1];
rd_cmd.header.dest = DSL_CTL_REVID_VERSION;
rd_cmd.header.size = 1;
rd_cmd.data = &revid;
if ((ret = command_ctl_rd(usb->devhdl, rd_cmd)) != SR_OK) {
sr_err("Failed to get REVID.");
break;
}
/*
* Different versions may have incompatible issue,
* Mark for up level process
*/
if (vi.major != DSL_REQUIRED_VERSION_MAJOR ||
vi.minor != DSL_REQUIRED_VERSION_MINOR) {
if (vi.major != DSL_REQUIRED_VERSION_MAJOR) {
sr_err("Expected firmware version %d.%d, "
"got %d.%d.", DSL_REQUIRED_VERSION_MAJOR, DSL_REQUIRED_VERSION_MINOR,
vi.major, vi.minor);
@@ -199,9 +352,6 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
sdi->index, usb->bus, usb->address,
USB_INTERFACE, vi.major, vi.minor);
sr_info("Detected REVID=%d, it's a Cypress CY7C68013%s.",
revid, (revid != 1) ? " (FX2)" : "A (FX2LP)");
break;
}
libusb_free_device_list(devlist, 1);
@@ -253,11 +403,9 @@ SR_PRIV int dsl_configure_probes(const struct sr_dev_inst *sdi)
SR_PRIV uint64_t dsl_channel_depth(const struct sr_dev_inst *sdi)
{
struct DSL_context *devc = sdi->priv;
int ch_num = dsl_en_ch_num(sdi);
if (strcmp(sdi->model, "DSLogic Basic") == 0)
return DSLOGIC_BASIC_MEM_DEPTH / (ch_num ? ch_num : 1);
else
return DSLOGIC_MEM_DEPTH / (ch_num ? ch_num : 1);
return devc->profile->dev_caps.hw_depth / (ch_num ? ch_num : 1);
}
SR_PRIV int dsl_wr_reg(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t value)
@@ -271,7 +419,7 @@ SR_PRIV int dsl_wr_reg(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t valu
hdl = usb->devhdl;
wr_cmd.header.dest = DSL_CTL_I2C_REG;
wr_cmd.header.offset = (FPGA_I2CADDR << 8) + addr;
wr_cmd.header.offset = addr;
wr_cmd.header.size = 1;
wr_cmd.data[0] = value;
if ((ret = command_ctl_wr(hdl, wr_cmd)) != SR_OK) {
@@ -282,28 +430,110 @@ SR_PRIV int dsl_wr_reg(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t valu
return SR_OK;
}
SR_PRIV int dsl_wr_ext(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t value)
SR_PRIV int dsl_rd_reg(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t *value)
{
struct sr_usb_dev_inst *usb;
struct libusb_device_handle *hdl;
struct ctl_wr_cmd wr_cmd;
struct ctl_rd_cmd rd_cmd;
int ret;
usb = sdi->conn;
hdl = usb->devhdl;
wr_cmd.header.dest = DSL_CTL_I2C_REG;
wr_cmd.header.offset = (EXT_I2CADDR << 8) + addr;
wr_cmd.header.size = 1;
wr_cmd.data[0] = value;
if ((ret = command_ctl_wr(hdl, wr_cmd)) != SR_OK) {
sr_err("Sent DSL_CTL_I2C_REG command failed.");
rd_cmd.header.dest = DSL_CTL_I2C_STATUS;
rd_cmd.header.offset = addr;
rd_cmd.header.size = 1;
rd_cmd.data = value;
if ((ret = command_ctl_rd(usb->devhdl, rd_cmd)) != SR_OK) {
sr_err("Sent DSL_CTL_I2C_STATUS read command failed.");
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int dsl_wr_ext(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t value)
{
uint8_t rdata;
int ret;
// write addr + wr
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_TXR_OFF, EI2C_AWR);
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STA | bmEI2C_WR);
// check done
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_SR_OFF, &rdata);
if (rdata & bmEI2C_RXNACK) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
return SR_ERR;
}
// write offset + wr
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_TXR_OFF, addr);
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_WR);
// check done
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_SR_OFF, &rdata);
if (rdata & bmEI2C_RXNACK) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
return SR_ERR;
}
// write value + wr
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_TXR_OFF, value);
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
// check done
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_SR_OFF, &rdata);
if (rdata & bmEI2C_RXNACK) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
return SR_ERR;
}
return ret;
}
SR_PRIV int dsl_rd_ext(const struct sr_dev_inst *sdi, unsigned char *ctx, uint16_t addr, uint8_t len)
{
uint8_t rdata;
int ret;
// write addr + wr
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_TXR_OFF, EI2C_AWR);
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STA | bmEI2C_WR);
// check done
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_SR_OFF, &rdata);
if (rdata & bmEI2C_RXNACK) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
return SR_ERR;
}
// write offset + wr
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_TXR_OFF, addr);
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_WR);
// check done
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_SR_OFF, &rdata);
if (rdata & bmEI2C_RXNACK) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
return SR_ERR;
}
// write read addr + wr
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_TXR_OFF, EI2C_ARD);
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STA | bmEI2C_WR);
// check done
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_SR_OFF, &rdata);
if (rdata & bmEI2C_RXNACK) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_WR);
return SR_ERR;
}
while(--len) {
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_RD);
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_RXR_OFF, ctx);
ctx++;
}
ret = dsl_wr_reg(sdi, EI2C_ADDR+EI2C_CR_OFF, bmEI2C_STO | bmEI2C_RD | bmEI2C_NACK);
ret = dsl_rd_reg(sdi, EI2C_ADDR+EI2C_RXR_OFF, ctx);
return ret;
}
SR_PRIV int dsl_wr_dso(const struct sr_dev_inst *sdi, uint64_t cmd)
{
struct sr_usb_dev_inst *usb;
@@ -432,8 +662,8 @@ SR_PRIV int dsl_fpga_arm(const struct sr_dev_inst *sdi)
(devc->clock_edge << CLK_EDGE_BIT) +
(devc->rle_mode << RLE_MODE_BIT) +
((sdi->mode == DSO) << DSO_MODE_BIT) +
(((devc->cur_samplerate == (2 * DSLOGIC_MAX_LOGIC_SAMPLERATE)) && sdi->mode != DSO) << HALF_MODE_BIT) +
((devc->cur_samplerate == (4 * DSLOGIC_MAX_LOGIC_SAMPLERATE)) << QUAR_MODE_BIT) +
(((devc->cur_samplerate == (2 * channel_modes[devc->ch_mode].hw_max_samplerate)) && sdi->mode != DSO) << HALF_MODE_BIT) +
((devc->cur_samplerate == (4 * channel_modes[devc->ch_mode].hw_max_samplerate)) << QUAR_MODE_BIT) +
((sdi->mode == ANALOG) << ANALOG_MODE_BIT) +
((devc->filter == SR_FILTER_1T) << FILTER_BIT) +
(devc->instant << INSTANT_BIT) +
@@ -444,18 +674,16 @@ SR_PRIV int dsl_fpga_arm(const struct sr_dev_inst *sdi)
((devc->test_mode == SR_TEST_INTERNAL) << INT_TEST_BIT);
// sample rate divider
tmp_u32 = (sdi->mode == DSO) ? (uint32_t)ceil(DSLOGIC_MAX_DSO_SAMPLERATE * 1.0 / devc->cur_samplerate / ch_num) :
(sdi->mode == ANALOG) ? (uint32_t)ceil(DSCOPE_MAX_DAQ_SAMPLERATE * 1.0 / max(devc->cur_samplerate, HW_MIN_SAMPLERATE)) :
(uint32_t)ceil(DSLOGIC_MAX_LOGIC_SAMPLERATE * 1.0 / devc->cur_samplerate);
devc->unit_pitch = ceil(HW_MIN_SAMPLERATE * 1.0 / devc->cur_samplerate);
tmp_u32 = (sdi->mode == DSO) ? (uint32_t)ceil(channel_modes[devc->ch_mode].max_samplerate * 1.0 / devc->cur_samplerate / ch_num) :
(sdi->mode == ANALOG) ? (uint32_t)ceil(channel_modes[devc->ch_mode].hw_max_samplerate * 1.0 / max(devc->cur_samplerate, channel_modes[devc->ch_mode].hw_min_samplerate)) :
(uint32_t)ceil(channel_modes[devc->ch_mode].hw_max_samplerate * 1.0 / devc->cur_samplerate);
devc->unit_pitch = ceil(channel_modes[devc->ch_mode].hw_min_samplerate * 1.0 / devc->cur_samplerate);
setting.div_l = tmp_u32 & 0x0000ffff;
setting.div_h = tmp_u32 >> 16;
// capture counter
// analog: 16bits, but sample with half mode(0-7 valid only)
tmp_u64 = (sdi->mode == DSO) ? (devc->limit_samples / (g_slist_length(sdi->channels) / ch_num)) :
(sdi->mode == ANALOG) ? (devc->limit_samples * g_slist_length(sdi->channels) * 4) :
(devc->limit_samples);
tmp_u64 = (sdi->mode == DSO) ? (devc->actual_samples / (channel_modes[devc->ch_mode].num / ch_num)) :
(devc->limit_samples);
tmp_u64 >>= 4; // hardware minimum unit 64
setting.cnt_l = tmp_u64 & 0x0000ffff;
setting.cnt_h = tmp_u64 >> 16;
@@ -831,7 +1059,7 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
const struct sr_channel *ch,
const struct sr_channel_group *cg)
{
struct DSL_context *devc;
struct DSL_context *devc = sdi->priv;
struct sr_usb_dev_inst *usb;
char str[128];
@@ -852,37 +1080,31 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
case SR_CONF_LIMIT_SAMPLES:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_uint64(devc->limit_samples);
break;
case SR_CONF_SAMPLERATE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
case SR_CONF_RLE_SUPPORT:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->rle_support);
break;
case SR_CONF_CLOCK_TYPE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->clock_type);
break;
case SR_CONF_CLOCK_EDGE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->clock_edge);
break;
case SR_CONF_INSTANT:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->instant);
break;
case SR_CONF_PROBE_VDIV:
@@ -903,9 +1125,18 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
case SR_CONF_TIMEBASE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_uint64(devc->timebase);
break;
case SR_CONF_MAX_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(min(MAX_TIMEBASE,
SR_SEC(1) *
devc->profile->dev_caps.dso_depth /
channel_modes[devc->ch_mode].num /
channel_modes[devc->ch_mode].min_samplerate /
DS_CONF_DSO_HDIVS));
break;
case SR_CONF_PROBE_COUPLING:
if (!ch)
return SR_ERR;
@@ -916,28 +1147,19 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
return SR_ERR;
*data = g_variant_new_boolean(ch->enabled);
break;
case SR_CONF_DATALOCK:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->data_lock);
break;
case SR_CONF_TRIGGER_SLOPE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_byte(devc->trigger_slope);
break;
case SR_CONF_TRIGGER_SOURCE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_byte(devc->trigger_source&0x0f);
break;
case SR_CONF_TRIGGER_CHANNEL:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_byte(devc->trigger_source>>4);
break;
case SR_CONF_TRIGGER_VALUE:
@@ -948,7 +1170,6 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
case SR_CONF_HORIZ_TRIGGERPOS:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
if (sdi->mode == DSO) {
*data = g_variant_new_byte(devc->trigger_hrate);
} else {
@@ -958,19 +1179,21 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
case SR_CONF_TRIGGER_HOLDOFF:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_uint64(devc->trigger_holdoff);
break;
case SR_CONF_TRIGGER_MARGIN:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_byte(devc->trigger_margin);
break;
case SR_CONF_HAVE_ZERO:
if (!sdi)
return SR_ERR;
*data = g_variant_new_boolean(devc->profile->dev_caps.feature_caps & CAPS_FEATURE_ZERO);
break;
case SR_CONF_ZERO:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
if (sdi->mode == DSO)
*data = g_variant_new_boolean(devc->zero);
else
@@ -979,14 +1202,83 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
case SR_CONF_ROLL:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->roll);
break;
case SR_CONF_UNIT_BITS:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_byte(devc->unit_bits);
*data = g_variant_new_byte(channel_modes[devc->ch_mode].unit_bits);
break;
case SR_CONF_PROBE_MAP_UNIT:
if (!sdi || !ch)
return SR_ERR;
*data = g_variant_new_string(ch->map_unit);
break;
case SR_CONF_PROBE_MAP_MIN:
if (!sdi || !ch)
return SR_ERR;
*data = g_variant_new_double(ch->map_min);
break;
case SR_CONF_PROBE_MAP_MAX:
if (!sdi || !ch)
return SR_ERR;
*data = g_variant_new_double(ch->map_max);
break;
default:
return SR_ERR_NA;
}
return SR_OK;
}
SR_PRIV int dsl_config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
struct DSL_context *devc;
GVariant *gvar;
GVariantBuilder gvb;
int i;
(void)cg;
devc = sdi->priv;
switch (key) {
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
// gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
// ARRAY_SIZE(samplerates), sizeof(uint64_t));
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplerates + devc->samplerates_min_index,
(devc->samplerates_max_index - devc->samplerates_min_index + 1) * sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_PROBE_CONFIGS:
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
probeOptions, ARRAY_SIZE(probeOptions)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_PROBE_SESSIONS:
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
probeSessions, ARRAY_SIZE(probeSessions)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_PROBE_VDIV:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
for (i = 0; devc->profile->dev_caps.vdivs[i]; i++);
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
devc->profile->dev_caps.vdivs, i*sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "vdivs", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_PROBE_COUPLING:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_from_data(G_VARIANT_TYPE("ay"),
probeCoupling, ARRAY_SIZE(probeCoupling)*sizeof(uint8_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "coupling", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_PROBE_MAP_UNIT:
*data = g_variant_new_strv(probeMapUnits, ARRAY_SIZE(probeMapUnits));
break;
default:
return SR_ERR_NA;
@@ -1113,7 +1405,7 @@ SR_PRIV int dsl_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_dat
if (!devc->abort) {
devc->abort = TRUE;
dsl_wr_reg(sdi, EEWP_ADDR, bmFORCE_RDY);
dsl_wr_reg(sdi, CTR0_ADDR, bmFORCE_RDY);
} else if (devc->status == DSL_FINISH) {
/* Stop GPIF acquisition */
wr_cmd.header.dest = DSL_CTL_STOP;
@@ -1139,8 +1431,8 @@ SR_PRIV int dsl_dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *
devc = sdi->priv;
usb = sdi->conn;
if (prg && (devc->status == DSL_START)) {
rd_cmd.header.dest = DSL_CTL_DSO_MEASURE;
rd_cmd.header.offset = (FPGA_I2CADDR << 8) + begin;
rd_cmd.header.dest = DSL_CTL_I2C_STATUS;
rd_cmd.header.offset = begin;
rd_cmd.header.size = end - begin + 1;
rd_cmd.data = (unsigned char*)status;
ret = command_ctl_rd(usb->devhdl, rd_cmd);
@@ -1212,7 +1504,7 @@ static void finish_acquisition(struct DSL_context *devc)
{
struct sr_datafeed_packet packet;
sr_err("%s: send SR_DF_END packet", __func__);
sr_info("%s: send SR_DF_END packet", __func__);
/* Terminate session. */
packet.type = SR_DF_END;
packet.status = SR_PKT_OK;
@@ -1273,15 +1565,9 @@ static void receive_transfer(struct libusb_transfer *transfer)
uint8_t *cur_buf = transfer->buffer;
struct DSL_context *devc = transfer->user_data;
struct sr_dev_inst *sdi = devc->cb_data;
const int sample_width = (devc->sample_wide) ? 2 : 1;
if (devc->status == DSL_START)
devc->status = DSL_DATA;
if (devc->data_lock) {
resubmit_transfer(transfer);
devc->trf_completed = 1;
return;
}
if (devc->abort)
devc->status = DSL_STOP;
@@ -1313,7 +1599,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
logic.data = cur_buf;
} else if (sdi->mode == DSO) {
if (!devc->instant) {
const uint32_t mstatus_offset = devc->limit_samples / (g_slist_length(sdi->channels)/dsl_en_ch_num(sdi));
const uint32_t mstatus_offset = devc->actual_samples / (channel_modes[devc->ch_mode].num/dsl_en_ch_num(sdi));
devc->mstatus.pkt_id = *((const uint16_t*)cur_buf + mstatus_offset);
devc->mstatus.ch0_max = *((const uint8_t*)cur_buf + mstatus_offset*2 + 1*2);
devc->mstatus.ch0_min = *((const uint8_t*)cur_buf + mstatus_offset*2 + 3);
@@ -1334,19 +1620,18 @@ static void receive_transfer(struct libusb_transfer *transfer)
devc->mstatus.vlen = instant_buffer_size;
}
const uint32_t divider = devc->zero ? 0x1 : (uint32_t)ceil(DSCOPE_MAX_SAMPLERATE * 1.0 / devc->cur_samplerate / dsl_en_ch_num(sdi));
const uint32_t divider = devc->zero ? 0x1 : (uint32_t)ceil(channel_modes[devc->ch_mode].max_samplerate * 1.0 / devc->cur_samplerate / dsl_en_ch_num(sdi));
if ((devc->mstatus.pkt_id == DSO_PKTID &&
devc->mstatus.sample_divider == divider &&
devc->mstatus.vlen != 0 &&
devc->mstatus.vlen <= (transfer->actual_length - 512) / sample_width) ||
devc->mstatus.vlen <= (uint32_t)(transfer->actual_length - 512) / 2) ||
devc->instant) {
devc->roll = (devc->mstatus.stream_mode != 0);
devc->mstatus_valid = devc->instant ? FALSE : TRUE;
packet.type = SR_DF_DSO;
packet.payload = &dso;
dso.probes = sdi->channels;
//dso.num_samples = (transfer->actual_length - 512) / sample_width;
cur_sample_count = 2 * devc->mstatus.vlen / dsl_en_ch_num(sdi) ;
cur_sample_count = min(2 * devc->mstatus.vlen / dsl_en_ch_num(sdi), devc->limit_samples);
dso.num_samples = cur_sample_count;
dso.mq = SR_MQ_VOLTAGE;
dso.unit = SR_UNIT_VOLT;
@@ -1363,9 +1648,9 @@ static void receive_transfer(struct libusb_transfer *transfer)
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
analog.probes = sdi->channels;
cur_sample_count = transfer->actual_length / (((devc->unit_bits + 7) / 8) * g_slist_length(analog.probes));
cur_sample_count = transfer->actual_length / (((channel_modes[devc->ch_mode].unit_bits + 7) / 8) * g_slist_length(analog.probes));
analog.num_samples = cur_sample_count;
analog.unit_bits = devc->unit_bits;
analog.unit_bits = channel_modes[devc->ch_mode].unit_bits;;
analog.unit_pitch = devc->unit_pitch;
analog.mq = SR_MQ_VOLTAGE;
analog.unit = SR_UNIT_VOLT;
@@ -1475,9 +1760,10 @@ SR_PRIV int dsl_start_transfers(const struct sr_dev_inst *sdi)
test_init = 1;
if (devc->instant)
dso_buffer_size = instant_buffer_size * g_slist_length(sdi->channels);
dso_buffer_size = min(instant_buffer_size * channel_modes[devc->ch_mode].num,
devc->profile->dev_caps.hw_depth / channel_modes[devc->ch_mode].unit_bits);
else
dso_buffer_size = devc->limit_samples * dsl_en_ch_num(sdi) + 512;
dso_buffer_size = devc->actual_samples * dsl_en_ch_num(sdi) + 512;
num_transfers = (devc->stream) ? get_number_of_transfers(devc) : 1;
size = (sdi->mode == DSO) ? dso_buffer_size :

View File

@@ -42,63 +42,45 @@
/* Message logging helpers with subsystem-specific prefix string. */
#define LOG_PREFIX "DSL Hardware: "
#define ds_log(l, s, args...) ds_log(l, LOG_PREFIX s, ## args)
#define ds_spew(s, args...) ds_spew(LOG_PREFIX s, ## args)
#define ds_dbg(s, args...) ds_dbg(LOG_PREFIX s, ## args)
#define ds_info(s, args...) ds_info(LOG_PREFIX s, ## args)
#define ds_warn(s, args...) ds_warn(LOG_PREFIX s, ## args)
#define ds_err(s, args...) ds_err(LOG_PREFIX s, ## args)
#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
#define USB_INTERFACE 0
#define USB_CONFIGURATION 1
#define NUM_TRIGGER_STAGES 16
#define TRIGGER_TYPE "01"
#define MAX_RENUM_DELAY_MS 3000
#define NUM_SIMUL_TRANSFERS 64
#define MAX_EMPTY_TRANSFERS (NUM_SIMUL_TRANSFERS * 2)
#define DSL_REQUIRED_VERSION_MAJOR 2
#define DSL_REQUIRED_VERSION_MINOR 0
#define MAX_8BIT_SAMPLE_RATE DS_MHZ(24)
#define MAX_16BIT_SAMPLE_RATE DS_MHZ(12)
/* hardware Capabilities */
#define CAPS_MODE_LOGIC (1 << 0)
#define CAPS_MODE_ANALOG (1 << 1)
#define CAPS_MODE_DSO (1 << 2)
/* 6 delay states of up to 256 clock ticks */
#define MAX_SAMPLE_DELAY (6 * 256)
#define CAPS_FEATURE_NONE 0
// voltage threshold
#define CAPS_FEATURE_VTH (1 << 0)
// with external buffer
#define CAPS_FEATURE_BUF (1 << 1)
// pre offset control
#define CAPS_FEATURE_PREOFF (1 << 2)
// small startup eemprom
#define CAPS_FEATURE_SEEP (1 << 3)
// zero calibration ability
#define CAPS_FEATURE_ZERO (1 << 4)
/* end */
#define DEV_CAPS_16BIT_POS 0
#define DEV_CAPS_16BIT (1 << DEV_CAPS_16BIT_POS)
#define MAX_ANALOG_PROBES_NUM 9
#define MAX_DSO_PROBES_NUM 2
#define DEFAULT_SAMPLERATE SR_MHZ(1)
#define DEFAULT_SAMPLELIMIT SR_MB(1)
#define VPOS_MINISTEP 0.083
#define VPOS_STEP 26.0
#define DSLOGIC_ATOMIC_BITS 6
#define DSLOGIC_ATOMIC_SAMPLES (1 << DSLOGIC_ATOMIC_BITS)
#define DSLOGIC_ATOMIC_SIZE (1 << (DSLOGIC_ATOMIC_BITS - 3))
#define DSLOGIC_ATOMIC_MASK (0xFFFF << DSLOGIC_ATOMIC_BITS)
#define DSLOGIC_MAX_DSO_DEPTH SR_MB(2)
//#define DSLOGIC_MAX_DSO_DEPTH SR_KB(2)
#define DSLOGIC_MAX_DSO_SAMPLERATE SR_MHZ(200)
#define DSLOGIC_INSTANT_DEPTH SR_MB(32)
#define DSLOGIC_MAX_LOGIC_DEPTH SR_MB(16)
#define DSLOGIC_MAX_LOGIC_SAMPLERATE SR_MHZ(100)
#define DSCOPE_MAX_DEPTH SR_MB(2)
//#define DSCOPE_MAX_DEPTH SR_KB(512)
#define DSCOPE_MAX_SAMPLERATE SR_MHZ(200)
#define DSCOPE_INSTANT_DEPTH SR_MB(32)
#define DSCOPE_VLD_CH_NUM 2
#define DSCOPE_MAX_DAQ_SAMPLERATE SR_MHZ(100)
#define HW_MIN_SAMPLERATE SR_KHZ(10)
/*
* for basic configuration
*/
@@ -118,28 +100,18 @@
#define EXT_TEST_BIT 14
#define INT_TEST_BIT 15
#define bmZERO 0x00
#define bmEEWP 0x01
#define bmFORCE_RDY 0x02
#define bmFORCE_STOP 0x04
#define bmSCOPE_SET 0x08
#define bmSCOPE_CLR 0x08
#define DSO_EN1_BIT 6
#define DSO_EN0_BIT 5
#define DSO_EN_COMB_BIT 4
#define DSO_DC1_BIT 3
#define DSO_ATT1_BIT 2
#define DSO_DC0_BIT 1
#define DSO_ATT0_BIT 0
#define bmNONE 0
#define bmEEWP (1 << 0)
#define bmFORCE_RDY (1 << 1)
#define bmFORCE_STOP (1 << 2)
#define bmSCOPE_SET (1 << 3)
#define bmSCOPE_CLR (1 << 4)
/*
* for DSLogic device
*
* packet content check
*/
#define MAX_LOGIC_PROBES 16
#define DSLOGIC_BASIC_MEM_DEPTH SR_KB(256)
#define DSLOGIC_MEM_DEPTH SR_MB(256)
#define TRIG_CHECKID 0x55555555
#define DSO_PKTID 0xa500
/*
* for DSCope device
@@ -151,52 +123,32 @@
* y = voff(fine) default bias
* the final offset: x+DSCOPE_CONSTANT_BIAS->vpos(coarse); y->voff(fine)
*/
#define DSCOPE_DEFAULT_TRANS (129<<8)+167
#define DSCOPE_DEFAULT_VOFF (32<<10)+558
#define DSCOPE_CONSTANT_BIAS 160
#define DSCOPE_TRANS_CMULTI 10
#define DSCOPE_TRANS_FMULTI 100.0
#define DSCOPE_DEFAULT_VGAIN0 0x162400
#define DSCOPE_DEFAULT_VGAIN1 0x14C000
#define DSCOPE_DEFAULT_VGAIN2 0x12E800
#define DSCOPE_DEFAULT_VGAIN3 0x118000
#define DSCOPE_DEFAULT_VGAIN4 0x102400
#define DSCOPE_DEFAULT_VGAIN5 0x2E800
#define DSCOPE_DEFAULT_VGAIN6 0x18000
#define DSCOPE_DEFAULT_VGAIN7 0x02400
/*
* for DSCope20 device
* trans: the whole windows offset map to the offset pwm(1024 total)
* voff: offset pwm constant bias to balance circuit offset
*/
#define DSCOPE20_DEFAULT_TRANS 920
#define DSCOPE20_DEFAULT_VOFF 45
#define DSCOPE20_DEFAULT_VGAIN0 0x1DA800
#define DSCOPE20_DEFAULT_VGAIN1 0x1A7200
#define DSCOPE20_DEFAULT_VGAIN2 0x164200
#define DSCOPE20_DEFAULT_VGAIN3 0x131800
#define DSCOPE20_DEFAULT_VGAIN4 0xBD000
#define DSCOPE20_DEFAULT_VGAIN5 0x7AD00
#define DSCOPE20_DEFAULT_VGAIN6 0x48800
#define DSCOPE20_DEFAULT_VGAIN7 0x12000
#define DSCOPEC20_DEFAULT_VGAIN0 0x1C5C00
#define DSCOPEC20_DEFAULT_VGAIN1 0x19EB00
#define DSCOPEC20_DEFAULT_VGAIN2 0x16AE00
#define DSCOPEC20_DEFAULT_VGAIN3 0x143D00
#define DSCOPEC20_DEFAULT_VGAIN4 0xAFC00
#define DSCOPEC20_DEFAULT_VGAIN5 0x7C000
#define DSCOPEC20_DEFAULT_VGAIN6 0x54E00
#define DSCOPEC20_DEFAULT_VGAIN7 0x2DD00
#define CALI_VGAIN_RANGE 100
#define CALI_VOFF_RANGE (1024-DSCOPE20_DEFAULT_TRANS)
#define DSO_AUTOTRIG_THRESHOLD 16
#define TRIG_CHECKID 0x55555555
#define DSO_PKTID 0xa500
struct DSL_caps {
uint64_t mode_caps;
uint64_t feature_caps;
uint64_t channels;
uint64_t hw_depth;
uint64_t dso_depth;
uint8_t intest_channel;
const uint64_t *vdivs;
uint8_t vga_id;
uint16_t default_channelmode;
uint64_t default_samplerate;
uint64_t default_samplelimit;
uint16_t default_pwmtrans;
uint16_t default_pwmmargin;
};
struct DSL_profile {
uint16_t vid;
@@ -211,82 +163,328 @@ struct DSL_profile {
const char *fpga_bit33;
const char *fpga_bit50;
uint32_t dev_caps;
struct DSL_caps dev_caps;
};
static const uint64_t vdivs10to2000[] = {
SR_mV(10),
SR_mV(20),
SR_mV(50),
SR_mV(100),
SR_mV(200),
SR_mV(500),
SR_V(1),
SR_V(2),
0,
};
struct DSL_vga {
uint8_t id;
uint64_t key;
uint64_t vgain;
uint16_t voff;
uint16_t voff_comp;
};
static const struct DSL_vga vga_defaults[] = {
{1, 10, 0x162400, (32<<10)+558, (32<<10)+558},
{1, 20, 0x14C000, (32<<10)+558, (32<<10)+558},
{1, 50, 0x12E800, (32<<10)+558, (32<<10)+558},
{1, 100, 0x118000, (32<<10)+558, (32<<10)+558},
{1, 200, 0x102400, (32<<10)+558, (32<<10)+558},
{1, 500, 0x2E800, (32<<10)+558, (32<<10)+558},
{1, 1000, 0x18000, (32<<10)+558, (32<<10)+558},
{1, 2000, 0x02400, (32<<10)+558, (32<<10)+558},
{2, 10, 0x1DA800, 45, 1024-920-45},
{2, 20, 0x1A7200, 45, 1024-920-45},
{2, 50, 0x164200, 45, 1024-920-45},
{2, 100, 0x131800, 45, 1024-920-45},
{2, 200, 0xBD000, 45, 1024-920-45},
{2, 500, 0x7AD00, 45, 1024-920-45},
{2, 1000, 0x48800, 45, 1024-920-45},
{2, 2000, 0x12000, 45, 1024-920-45},
{3, 10, 0x1C5C00, 45, 1024-920-45},
{3, 20, 0x19EB00, 45, 1024-920-45},
{3, 50, 0x16AE00, 45, 1024-920-45},
{3, 100, 0x143D00, 45, 1024-920-45},
{3, 200, 0xB1000, 45, 1024-920-45},
{3, 500, 0x7F000, 45, 1024-920-45},
{3, 1000, 0x57200, 45, 1024-920-45},
{3, 2000, 0x2DD00, 45, 1024-920-45},
{0, 0, 0, 0, 0}
};
enum CHANNEL_ID {
DSL_STREAM20x16 = 0,
DSL_STREAM25x12,
DSL_STREAM50x6,
DSL_STREAM100x3,
DSL_BUFFER100x16,
DSL_BUFFER200x8,
DSL_BUFFER400x4,
DSL_ANALOG10x2,
DSL_DSO200x2,
};
struct DSL_channels {
enum CHANNEL_ID id;
enum OPERATION_MODE mode;
enum CHANNEL_TYPE type;
gboolean stream;
uint16_t num;
uint8_t unit_bits;
uint64_t min_samplerate;
uint64_t max_samplerate;
uint64_t hw_min_samplerate;
uint64_t hw_max_samplerate;
const char *descr;
};
static const struct DSL_channels channel_modes[] = {
// LA Stream
{DSL_STREAM20x16, LOGIC, SR_CHANNEL_LOGIC, TRUE, 16, 1, SR_KHZ(10), SR_MHZ(20),
SR_KHZ(10), SR_MHZ(100), "Use 16 Channels (Max 20MHz)"},
{DSL_STREAM25x12, LOGIC, SR_CHANNEL_LOGIC, TRUE, 12, 1, SR_KHZ(10), SR_MHZ(25),
SR_KHZ(10), SR_MHZ(100), "Use 12 Channels (Max 25MHz)"},
{DSL_STREAM50x6, LOGIC, SR_CHANNEL_LOGIC, TRUE, 6, 1, SR_KHZ(10), SR_MHZ(50),
SR_KHZ(10), SR_MHZ(100), "Use 6 Channels (Max 50MHz)"},
{DSL_STREAM100x3, LOGIC, SR_CHANNEL_LOGIC, TRUE, 3, 1, SR_KHZ(10), SR_MHZ(100),
SR_KHZ(10), SR_MHZ(100), "Use 3 Channels (Max 100MHz)"},
// LA Buffer
{DSL_BUFFER100x16, LOGIC, SR_CHANNEL_LOGIC, FALSE, 16, 1, SR_KHZ(10), SR_MHZ(100),
SR_KHZ(10), SR_MHZ(100), "Use Channels 0~15 (Max 100MHz)"},
{DSL_BUFFER200x8, LOGIC, SR_CHANNEL_LOGIC, FALSE, 8, 1, SR_KHZ(10), SR_MHZ(200),
SR_KHZ(10), SR_MHZ(100), "Use Channels 0~7 (Max 200MHz)"},
{DSL_BUFFER400x4, LOGIC, SR_CHANNEL_LOGIC, FALSE, 4, 1, SR_KHZ(10), SR_MHZ(400),
SR_KHZ(10), SR_MHZ(100), "Use Channels 0~3 (Max 400MHz)"},
// DAQ
{DSL_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, TRUE, 2, 8, SR_HZ(10), SR_MHZ(10),
SR_KHZ(10), SR_MHZ(100), "Use Channels 0~1 (Max 10MHz)"},
// OSC
{DSL_DSO200x2, DSO, SR_CHANNEL_DSO, FALSE, 2, 8, SR_KHZ(10), SR_MHZ(200),
SR_KHZ(10), SR_MHZ(100), "Use Channels 0~1 (Max 200MHz)"}
};
static const struct DSL_profile supported_DSLogic[] = {
/*
* DSLogic
*/
{0x2A0E, 0x0001, NULL, "DSLogic", NULL,
{0x2A0E, 0x0001, "DreamSourceLab", "DSLogic", NULL,
"DSLogic.fw",
"DSLogic33.bin",
"DSLogic50.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_LOGIC | CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_SEEP | CAPS_FEATURE_BUF,
(1 << DSL_STREAM20x16) | (1 << DSL_STREAM25x12) | (1 << DSL_STREAM50x6) | (1 << DSL_STREAM100x3) |
(1 << DSL_BUFFER100x16) | (1 << DSL_BUFFER200x8) | (1 << DSL_BUFFER400x4) |
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_MB(256),
SR_Mn(2),
DSL_BUFFER100x16,
vdivs10to2000,
0,
DSL_STREAM20x16,
SR_MHZ(1),
SR_Mn(1),
0,
0}
},
{0x2A0E, 0x0003, NULL, "DSLogic Pro", NULL,
{0x2A0E, 0x0003, "DreamSourceLab", "DSLogic Pro", NULL,
"DSLogicPro.fw",
"DSLogicPro.bin",
"DSLogicPro.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_LOGIC,
CAPS_FEATURE_SEEP | CAPS_FEATURE_VTH | CAPS_FEATURE_BUF,
(1 << DSL_STREAM20x16) | (1 << DSL_STREAM25x12) | (1 << DSL_STREAM50x6) | (1 << DSL_STREAM100x3) |
(1 << DSL_BUFFER100x16) | (1 << DSL_BUFFER200x8) | (1 << DSL_BUFFER400x4),
SR_MB(256),
0,
DSL_BUFFER100x16,
0,
0,
DSL_STREAM20x16,
SR_MHZ(1),
SR_Mn(1),
0,
0}
},
{0x2A0E, 0x0005, NULL, "DSMso", NULL,
"DSMso.fw",
"DSMso.bin",
"DSMso.bin",
DEV_CAPS_16BIT},
{0x2A0E, 0x0020, NULL, "DSLogic PLus", NULL,
{0x2A0E, 0x0020, "DreamSourceLab", "DSLogic PLus", NULL,
"DSLogicPlus.fw",
"DSLogicPlus.bin",
"DSLogicPlus.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_LOGIC,
CAPS_FEATURE_VTH | CAPS_FEATURE_BUF,
(1 << DSL_STREAM20x16) | (1 << DSL_STREAM25x12) | (1 << DSL_STREAM50x6) | (1 << DSL_STREAM100x3) |
(1 << DSL_BUFFER100x16) | (1 << DSL_BUFFER200x8) | (1 << DSL_BUFFER400x4),
SR_MB(256),
0,
DSL_BUFFER100x16,
0,
0,
DSL_STREAM20x16,
SR_MHZ(1),
SR_Mn(1),
0,
0}
},
{0x2A0E, 0x0021, NULL, "DSLogic Basic", NULL,
{0x2A0E, 0x0021, "DreamSourceLab", "DSLogic Basic", NULL,
"DSLogicBasic.fw",
"DSLogicBasic.bin",
"DSLogicBasic.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_LOGIC,
CAPS_FEATURE_VTH,
(1 << DSL_STREAM20x16) | (1 << DSL_STREAM25x12) | (1 << DSL_STREAM50x6) | (1 << DSL_STREAM100x3) |
(1 << DSL_BUFFER100x16) | (1 << DSL_BUFFER200x8) | (1 << DSL_BUFFER400x4),
SR_KB(256),
0,
DSL_STREAM20x16,
0,
0,
DSL_STREAM20x16,
SR_MHZ(1),
SR_Mn(1),
0,
0}
},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
{ 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
};
static const struct DSL_profile supported_DSCope[] = {
/*
* DSCope
*/
{0x2A0E, 0x0002, NULL, "DSCope", NULL,
{0x2A0E, 0x0002, "DreamSourceLab", "DSCope", NULL,
"DSCope.fw",
"DSCope.bin",
"DSCope.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_ZERO | CAPS_FEATURE_PREOFF | CAPS_FEATURE_SEEP | CAPS_FEATURE_BUF,
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_MB(256),
SR_Mn(2),
0,
vdivs10to2000,
1,
DSL_DSO200x2,
SR_MHZ(100),
SR_Mn(1),
(129<<8)+167,
1024-920}
},
{0x2A0E, 0x0004, NULL, "DSCope20", NULL,
{0x2A0E, 0x0004, "DreamSourceLab", "DSCope20", NULL,
"DSCope20.fw",
"DSCope20.bin",
"DSCope20.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_ZERO | CAPS_FEATURE_SEEP | CAPS_FEATURE_BUF,
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_MB(256),
SR_Mn(2),
0,
vdivs10to2000,
2,
DSL_DSO200x2,
SR_MHZ(100),
SR_Mn(1),
920,
1024-920}
},
{0x2A0E, 0x0022, NULL, "DSCope B20", NULL,
{0x2A0E, 0x0022, "DreamSourceLab", "DSCope B20", NULL,
"DSCopeB20.fw",
"DSCope20.bin",
"DSCope20.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_ZERO | CAPS_FEATURE_BUF,
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_MB(256),
SR_Mn(2),
0,
vdivs10to2000,
2,
DSL_DSO200x2,
SR_MHZ(100),
SR_Mn(1),
920,
1024-920}
},
{0x2A0E, 0x0023, NULL, "DSCope C20", NULL,
{0x2A0E, 0x0023, "DreamSourceLab", "DSCope C20", NULL,
"DSCopeC20.fw",
"DSCopeC20.bin",
"DSCopeC20.bin",
DEV_CAPS_16BIT},
{CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_ZERO | CAPS_FEATURE_BUF,
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_MB(256),
SR_Mn(2),
0,
vdivs10to2000,
3,
DSL_DSO200x2,
SR_MHZ(100),
SR_Mn(1),
920,
1024-920}
},
{0x2A0E, 0x0024, NULL, "DSCope C20P", NULL,
{0x2A0E, 0x0024, "DreamSourceLab", "DSCope C20P", NULL,
"DSCopeC20P.fw",
"DSCopeC20.bin",
"DSCopeC20.bin",
DEV_CAPS_16BIT},
"DSCopeC20P.bin",
"DSCopeC20P.bin",
{CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_ZERO | CAPS_FEATURE_BUF,
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_MB(256),
SR_Mn(2),
0,
vdivs10to2000,
3,
DSL_DSO200x2,
SR_MHZ(100),
SR_Mn(1),
920,
1024-920}
},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
{0x2A0E, 0x0025, "DreamSourceLab", "DSCope C20", NULL,
"DSCopeC20B.fw",
"DSCopeC20B.bin",
"DSCopeC20B.bin",
{CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_ZERO,
(1 << DSL_ANALOG10x2) |
(1 << DSL_DSO200x2),
SR_KB(256),
SR_Kn(20),
0,
vdivs10to2000,
3,
DSL_DSO200x2,
SR_MHZ(100),
SR_Kn(10),
920,
1024-920}
},
{ 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
};
static const gboolean default_ms_en[] = {
@@ -329,7 +527,6 @@ struct DSL_context {
uint64_t actual_bytes;
/* Operational settings */
gboolean sample_wide;
gboolean clock_type;
gboolean clock_edge;
gboolean rle_mode;
@@ -339,9 +536,9 @@ struct DSL_context {
gboolean stream;
uint8_t test_mode;
uint16_t buf_options;
uint16_t ch_mode;
uint16_t samplerates_size;
uint16_t samplecounts_size;
enum CHANNEL_ID ch_mode;
uint16_t samplerates_min_index;
uint16_t samplerates_max_index;
uint16_t th_level;
double vth;
uint16_t filter;
@@ -365,7 +562,6 @@ struct DSL_context {
int zero_comb;
gboolean roll;
gboolean data_lock;
uint8_t unit_bits;
uint16_t unit_pitch;
uint64_t num_samples;
@@ -425,21 +621,59 @@ struct DSL_setting {
uint32_t end_sync;
};
struct DSL_vga {
uint64_t key;
uint64_t vgain0;
uint64_t vgain1;
uint16_t voff0;
uint16_t voff1;
static const uint64_t samplerates[] = {
SR_HZ(10),
SR_HZ(20),
SR_HZ(50),
SR_HZ(100),
SR_HZ(200),
SR_HZ(500),
SR_KHZ(1),
SR_KHZ(2),
SR_KHZ(5),
SR_KHZ(10),
SR_KHZ(20),
SR_KHZ(40),
SR_KHZ(50),
SR_KHZ(100),
SR_KHZ(200),
SR_KHZ(400),
SR_KHZ(500),
SR_MHZ(1),
SR_MHZ(2),
SR_MHZ(4),
SR_MHZ(5),
SR_MHZ(10),
SR_MHZ(20),
SR_MHZ(25),
SR_MHZ(40),
SR_MHZ(50),
SR_MHZ(100),
SR_MHZ(200),
SR_MHZ(400),
SR_MHZ(500),
SR_MHZ(800),
SR_GHZ(1),
SR_GHZ(2),
SR_GHZ(5),
SR_GHZ(10),
};
SR_PRIV int dsl_adjust_probes(struct sr_dev_inst *sdi, int num_probes);
SR_PRIV int dsl_setup_probes(struct sr_dev_inst *sdi, int num_probes);
SR_PRIV const GSList *dsl_mode_list(const struct sr_dev_inst *sdi);
SR_PRIV void dsl_adjust_samplerate(struct DSL_context *devc);
SR_PRIV int dsl_en_ch_num(const struct sr_dev_inst *sdi);
SR_PRIV gboolean dsl_check_conf_profile(libusb_device *dev);
SR_PRIV int dsl_configure_probes(const struct sr_dev_inst *sdi);
SR_PRIV uint64_t dsl_channel_depth(const struct sr_dev_inst *sdi);
SR_PRIV int dsl_wr_reg(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t value);
SR_PRIV int dsl_rd_reg(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t *value);
SR_PRIV int dsl_wr_ext(const struct sr_dev_inst *sdi, uint8_t addr, uint8_t value);
SR_PRIV int dsl_rd_ext(const struct sr_dev_inst *sdi, unsigned char *ctx, uint16_t addr, uint8_t len);
SR_PRIV int dsl_wr_dso(const struct sr_dev_inst *sdi, uint64_t cmd);
SR_PRIV int dsl_wr_nvm(const struct sr_dev_inst *sdi, unsigned char *ctx, uint16_t addr, uint8_t len);
SR_PRIV int dsl_rd_nvm(const struct sr_dev_inst *sdi, unsigned char *ctx, uint16_t addr, uint8_t len);
@@ -450,6 +684,8 @@ SR_PRIV int dsl_fpga_config(struct libusb_device_handle *hdl, const char *filena
SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel *ch,
const struct sr_channel_group *cg);
SR_PRIV int dsl_config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg);
SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboolean *fpga_done);
SR_PRIV int dsl_dev_close(struct sr_dev_inst *sdi);

View File

@@ -25,16 +25,6 @@
#include "command.h"
static struct sr_dev_mode mode_list[] = {
{"LA", LOGIC},
{"DAQ", ANALOG},
{"OSC", DSO},
};
static struct sr_dev_mode pro_mode_list[] = {
{"LA", LOGIC},
};
enum {
/** Buffer mode */
OP_BUFFER = 0,
@@ -60,32 +50,6 @@ static const char *bufoptions[] = {
"Upload captured data",
};
static const char *stream_ch_modes[] = {
"Use 16 Channels (Max 20MHz)",
"Use 12 Channels (Max 25MHz)",
"Use 6 Channels (Max 50MHz)",
"Use 3 Channels (Max 100MHz)",
};
static const uint16_t stream_ch_num[] = {
16,
12,
6,
3,
};
static const char *buffer_ch_modes[] = {
"Use Channels 0~15 (Max 100MHz)",
"Use Channels 0~7 (Max 200MHz)",
"Use Channels 0~3 (Max 400MHz)",
};
static const uint16_t buffer_ch_num[] = {
MAX_LOGIC_PROBES,
MAX_LOGIC_PROBES / 2,
MAX_LOGIC_PROBES / 4,
};
static const char *thresholds[] = {
"1.8/2.5/3.3V Level",
"5.0V Level",
@@ -104,20 +68,6 @@ static const char *maxHeights[] = {
"5X",
};
static const int32_t hwopts[] = {
SR_CONF_CONN,
};
static const int32_t hwcaps[] = {
SR_CONF_LOGIC_ANALYZER,
SR_CONF_TRIGGER_TYPE,
SR_CONF_SAMPLERATE,
/* These are really implemented in the driver, not the hardware. */
SR_CONF_LIMIT_SAMPLES,
SR_CONF_CONTINUOUS,
};
static const int32_t hwoptions[] = {
SR_CONF_OPERATION_MODE,
SR_CONF_BUFFER_OPTIONS,
@@ -179,171 +129,30 @@ static const int32_t sessions_pro[] = {
SR_CONF_TRIGGER_MARGIN,
};
static const char *probe_names[] = {
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14", "15",
NULL,
};
static const uint64_t samplerates[] = {
SR_KHZ(10),
SR_KHZ(20),
SR_KHZ(50),
SR_KHZ(100),
SR_KHZ(200),
SR_KHZ(500),
SR_MHZ(1),
SR_MHZ(2),
SR_MHZ(5),
SR_MHZ(10),
SR_MHZ(20),
SR_MHZ(25),
SR_MHZ(50),
SR_MHZ(100),
SR_MHZ(200),
SR_MHZ(400),
};
//static const uint64_t samplecounts[] = {
// SR_KB(1),
// SR_KB(2),
// SR_KB(5),
// SR_KB(10),
// SR_KB(20),
// SR_KB(50),
// SR_KB(100),
// SR_KB(200),
// SR_KB(500),
// SR_MB(1),
// SR_MB(2),
// SR_MB(5),
// SR_MB(10),
// SR_MB(16),
//};
static const uint64_t samplecounts[] = {
SR_KB(1),
SR_KB(2),
SR_KB(4),
SR_KB(8),
SR_KB(16),
SR_KB(32),
SR_KB(64),
SR_KB(128),
SR_KB(256),
SR_KB(512),
SR_MB(1),
SR_MB(2),
SR_MB(4),
SR_MB(8),
SR_MB(16),
SR_MB(32),
SR_MB(64),
SR_MB(128),
SR_MB(256),
SR_MB(512),
SR_GB(1),
SR_GB(2),
SR_GB(4),
SR_GB(8),
SR_GB(16),
};
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 int counts_size(const struct sr_dev_inst *sdi)
{
struct DSL_context *devc = sdi->priv;
if (strcmp(sdi->model, "DSLogic Basic") == 0)
if (sdi->mode == ANALOG)
return 5;
else if (!devc || devc->stream)
return ARRAY_SIZE(samplecounts);
else
return 15;
else
if (sdi->mode == ANALOG)
return 15;
else
return ARRAY_SIZE(samplecounts);
}
static void probe_init(struct sr_dev_inst *sdi)
{
int i;
GSList *l;
for (l = sdi->channels; l; l = l->next) {
struct sr_channel *probe = (struct sr_channel *)l->data;
if (sdi->mode == DSO) {
probe->vdiv = 1000;
probe->vfactor = 1;
probe->vpos = 0;
probe->coupling = SR_DC_COUPLING;
probe->trig_value = 0x80;
probe->ms_show = TRUE;
for (i = DSO_MS_BEGIN; i < DSO_MS_END; i++)
probe->ms_en[i] = default_ms_en[i];
}
}
}
static int setup_probes(struct sr_dev_inst *sdi, int num_probes)
{
uint16_t j;
struct sr_channel *probe;
for (j = 0; j < num_probes; j++) {
if (!(probe = sr_channel_new(j, (sdi->mode == LOGIC) ? SR_CHANNEL_LOGIC : ((sdi->mode == DSO) ? SR_CHANNEL_DSO : SR_CHANNEL_ANALOG),
TRUE, probe_names[j])))
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, probe);
}
probe_init(sdi);
return SR_OK;
}
static int adjust_probes(struct sr_dev_inst *sdi, int num_probes)
{
uint16_t j;
struct sr_channel *probe;
assert(num_probes > 0);
j = g_slist_length(sdi->channels);
while(j < num_probes) {
if (!(probe = sr_channel_new(j, (sdi->mode == LOGIC) ? SR_CHANNEL_LOGIC : ((sdi->mode == DSO) ? SR_CHANNEL_DSO : SR_CHANNEL_ANALOG),
TRUE, probe_names[j])))
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, probe);
j++;
}
while(j > num_probes) {
sdi->channels = g_slist_delete_link(sdi->channels, g_slist_last(sdi->channels));
j--;
}
return SR_OK;
}
static struct DSL_context *DSLogic_dev_new(const struct sr_dev_inst *sdi)
static struct DSL_context *DSLogic_dev_new(const struct DSL_profile *prof)
{
struct DSL_context *devc;
unsigned int i;
if (!(devc = g_try_malloc(sizeof(struct DSL_context)))) {
sr_err("Device context malloc failed.");
return NULL;
}
for (i = 0; i < ARRAY_SIZE(channel_modes); i++)
assert(channel_modes[i].id == i);
devc->channel = NULL;
devc->profile = NULL;
devc->profile = prof;
devc->fw_updated = 0;
devc->cur_samplerate = DEFAULT_SAMPLERATE;
devc->limit_samples = DEFAULT_SAMPLELIMIT;
devc->sample_wide = TRUE;
devc->cur_samplerate = devc->profile->dev_caps.default_samplerate;
devc->limit_samples = devc->profile->dev_caps.default_samplelimit;
devc->clock_type = FALSE;
devc->clock_edge = FALSE;
devc->rle_mode = FALSE;
@@ -352,9 +161,7 @@ static struct DSL_context *DSLogic_dev_new(const struct sr_dev_inst *sdi)
devc->test_mode = SR_TEST_NONE;
devc->stream = (devc->op_mode == OP_STREAM);
devc->buf_options = SR_BUF_UPLOAD;
devc->ch_mode = 0;
devc->samplerates_size = 11;
devc->samplecounts_size = counts_size(sdi);
devc->ch_mode = devc->profile->dev_caps.default_channelmode;
devc->th_level = SR_TH_3V3;
devc->vth = 1.0;
devc->filter = SR_FILTER_NONE;
@@ -369,10 +176,11 @@ static struct DSL_context *DSLogic_dev_new(const struct sr_dev_inst *sdi)
devc->mstatus_valid = FALSE;
devc->data_lock = FALSE;
devc->max_height = 0;
devc->unit_bits = 8;
devc->trigger_margin = 8;
devc->trigger_channel = 0;
dsl_adjust_samplerate(devc);
return devc;
}
@@ -397,7 +205,7 @@ static GSList *scan(GSList *options)
GSList *l, *devices, *conn_devices;
struct libusb_device_descriptor des;
libusb_device **devlist;
int devcnt, num_logic_probes, ret, i, j;
int devcnt, ret, i, j;
const char *conn;
drvc = di->priv;
@@ -453,23 +261,25 @@ static GSList *scan(GSList *options)
continue;
devcnt = g_slist_length(drvc->instances);
sdi = sr_dev_inst_new(LOGIC, devcnt, SR_ST_INITIALIZING,
devc = DSLogic_dev_new(prof);
if (!devc)
return NULL;
sdi = sr_dev_inst_new(channel_modes[devc->ch_mode].mode, devcnt, SR_ST_INITIALIZING,
prof->vendor, prof->model, prof->model_version);
if (!sdi)
if (!sdi) {
g_free(devc);
return NULL;
}
sdi->priv = devc;
sdi->driver = di;
/* Fill in probelist according to this device's profile. */
num_logic_probes = prof->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
if (setup_probes(sdi, num_logic_probes) != SR_OK)
return NULL;
devc = DSLogic_dev_new(sdi);
devc->profile = prof;
sdi->priv = devc;
drvc->instances = g_slist_append(drvc->instances, sdi);
//devices = g_slist_append(devices, sdi);
/* Fill in probelist according to this device's profile. */
if (dsl_setup_probes(sdi, channel_modes[devc->ch_mode].num) != SR_OK)
return NULL;
if (dsl_check_conf_profile(devlist[i])) {
/* Already has the firmware, so fix the new address. */
sr_dbg("Found an DSLogic device.");
@@ -511,21 +321,9 @@ static GSList *dev_list(void)
return ((struct drv_context *)(di->priv))->instances;
}
static GSList *dev_mode_list(const struct sr_dev_inst *sdi)
static const GSList *dev_mode_list(const struct sr_dev_inst *sdi)
{
GSList *l = NULL;
unsigned int i;
if (strcmp(sdi->model, "DSLogic") == 0) {
for(i = 0; i < ARRAY_SIZE(mode_list); i++) {
l = g_slist_append(l, &mode_list[i]);
}
} else {
for(i = 0; i < ARRAY_SIZE(pro_mode_list); i++) {
l = g_slist_append(l, &pro_mode_list[i]);
}
}
return l;
return dsl_mode_list(sdi);
}
static uint64_t dso_cmd_gen(const struct sr_dev_inst *sdi, struct sr_channel* ch, int id)
@@ -534,7 +332,7 @@ static uint64_t dso_cmd_gen(const struct sr_dev_inst *sdi, struct sr_channel* ch
uint64_t cmd = 0;
int channel_cnt = 0;
GSList *l;
struct sr_channel *en_probe;
struct sr_channel *en_probe = ch;
devc = sdi->priv;
@@ -583,20 +381,16 @@ static uint64_t dso_cmd_gen(const struct sr_dev_inst *sdi, struct sr_channel* ch
}
// --Channel
if(channel_cnt == 1)
cmd += 0xC00000;
else if(ch->index == 0)
cmd += 0x400000;
else if(ch->index == 1)
cmd += 0x800000;
else
cmd += 0x000000;
// if(ch->index == 0)
// cmd += 0x400000;
// else if(ch->index == 1)
// cmd += 0x800000;
// else
// cmd += 0x000000;
if (sdi->mode != LOGIC) {
if(channel_cnt == 1)
cmd += 0xC00000;
else if(ch->index == 0)
cmd += 0x400000;
else if(ch->index == 1)
cmd += 0x800000;
else
cmd += 0x000000;
}
// --Header
cmd += 0x55000000;
@@ -607,7 +401,7 @@ static uint64_t dso_cmd_gen(const struct sr_dev_inst *sdi, struct sr_channel* ch
channel_cnt += probe->enabled;
}
cmd += 0x18;
uint32_t divider = (uint32_t)ceil(DSLOGIC_MAX_DSO_SAMPLERATE * 1.0 / devc->cur_samplerate / channel_cnt);
uint32_t divider = (uint32_t)ceil(channel_modes[devc->ch_mode].max_samplerate * 1.0 / devc->cur_samplerate / channel_cnt);
cmd += divider << 8;
break;
case SR_CONF_HORIZ_TRIGGERPOS:
@@ -708,7 +502,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel *ch,
const struct sr_channel_group *cg)
{
struct DSL_context *devc;
struct DSL_context *devc = sdi->priv;
int ret;
ret = dsl_config_get(id, data, sdi, ch, cg);
@@ -717,41 +511,35 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_OPERATION_MODE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_string(opmodes[devc->op_mode]);
break;
case SR_CONF_FILTER:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_string(filters[devc->filter]);
break;
case SR_CONF_RLE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->rle_mode);
break;
case SR_CONF_TEST:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->test_mode != SR_TEST_NONE);
break;
case SR_CONF_ACTUAL_SAMPLES:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_uint64(devc->actual_samples);
break;
case SR_CONF_WAIT_UPLOAD:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
if (devc->buf_options == SR_BUF_UPLOAD &&
devc->status == DSL_START) {
devc->status = DSL_ABORT;
dsl_wr_reg(sdi, EEWP_ADDR, bmFORCE_STOP);
dsl_wr_reg(sdi, CTR0_ADDR, bmFORCE_STOP);
*data = g_variant_new_boolean(TRUE);
} else {
*data = g_variant_new_boolean(FALSE);
@@ -760,81 +548,57 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_BUFFER_OPTIONS:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_string(bufoptions[devc->buf_options]);
break;
case SR_CONF_CHANNEL_MODE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
if (devc->stream)
*data = g_variant_new_string(stream_ch_modes[devc->ch_mode]);
else
*data = g_variant_new_string(buffer_ch_modes[devc->ch_mode]);
*data = g_variant_new_string(channel_modes[devc->ch_mode].descr);
break;
case SR_CONF_MAX_HEIGHT:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_string(maxHeights[devc->max_height]);
break;
case SR_CONF_MAX_HEIGHT_VALUE:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_byte(devc->max_height);
break;
case SR_CONF_THRESHOLD:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_string(thresholds[devc->th_level]);
break;
case SR_CONF_VTH:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_double(devc->vth);
break;
case SR_CONF_ZERO:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
if (sdi->mode == DSO)
*data = g_variant_new_boolean(devc->zero);
else
*data = g_variant_new_boolean(FALSE);
break;
case SR_CONF_STREAM:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_boolean(devc->stream);
break;
case SR_CONF_MAX_DSO_SAMPLERATE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(DSLOGIC_MAX_DSO_SAMPLERATE);
*data = g_variant_new_uint64(channel_modes[devc->ch_mode].max_samplerate);
break;
case SR_CONF_MAX_DSO_SAMPLELIMITS:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(DSLOGIC_MAX_DSO_DEPTH);
*data = g_variant_new_uint64(devc->profile->dev_caps.dso_depth);
break;
case SR_CONF_HW_DEPTH:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
*data = g_variant_new_uint64(dsl_channel_depth(sdi));
break;
case SR_CONF_VLD_CH_NUM:
if (!sdi)
return SR_ERR;
devc = sdi->priv;
if (devc->stream)
*data = g_variant_new_int16(stream_ch_num[devc->ch_mode]);
else
*data = g_variant_new_int16(buffer_ch_num[devc->ch_mode]);
*data = g_variant_new_int16(channel_modes[devc->ch_mode].num);
break;
default:
return SR_ERR_NA;
@@ -850,17 +614,16 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
{
struct DSL_context *devc;
const char *stropt;
int ret, num_probes;
int ret, num_probes = 0;
struct sr_usb_dev_inst *usb;
unsigned int i;
struct drv_context *drvc;
(void)cg;
if (sdi->status != SR_ST_ACTIVE)
if (sdi->status != SR_ST_ACTIVE) {
return SR_ERR;
}
drvc = di->priv;
devc = sdi->priv;
usb = sdi->conn;
@@ -874,13 +637,9 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
devc->clock_edge = g_variant_get_boolean(data);
} else if (id == SR_CONF_LIMIT_SAMPLES) {
devc->limit_samples = g_variant_get_uint64(data);
} else if (id == SR_CONF_DATALOCK) {
while(libusb_try_lock_events(drvc->sr_ctx->libusb_ctx));
devc->data_lock = g_variant_get_boolean(data);
libusb_unlock_events(drvc->sr_ctx->libusb_ctx);
} else if (id == SR_CONF_PROBE_VDIV) {
ch->vdiv = g_variant_get_uint64(data);
if (sdi->mode == DSO) {
if (sdi->mode != LOGIC) {
ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_PROBE_VDIV));
}
if (ret == SR_OK)
@@ -899,7 +658,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
ch->coupling = g_variant_get_byte(data);
if (ch->coupling == SR_GND_COUPLING)
ch->coupling = SR_DC_COUPLING;
if (sdi->mode == DSO) {
if (sdi->mode != LOGIC) {
ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, ch, SR_CONF_PROBE_COUPLING));
}
if (ret == SR_OK)
@@ -973,11 +732,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
} else if (id == SR_CONF_SAMPLERATE) {
if (devc->test_mode == SR_TEST_NONE) {
devc->cur_samplerate = g_variant_get_uint64(data);
if(sdi->mode == DSO) {
devc->sample_wide = (devc->cur_samplerate <= DSLOGIC_MAX_DSO_SAMPLERATE);
if(sdi->mode != LOGIC) {
ret = dsl_wr_dso(sdi, dso_cmd_gen(sdi, 0, SR_CONF_SAMPLERATE));
} else {
devc->sample_wide = (devc->cur_samplerate <= DSLOGIC_MAX_LOGIC_SAMPLERATE);
}
}
} else if (id == SR_CONF_FILTER) {
@@ -998,38 +754,67 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
devc->instant = g_variant_get_boolean(data);
if (dsl_en_ch_num(sdi) != 0) {
if (devc->instant)
devc->limit_samples = DSLOGIC_INSTANT_DEPTH / dsl_en_ch_num(sdi);
devc->limit_samples = devc->profile->dev_caps.hw_depth / dsl_en_ch_num(sdi);
else
devc->limit_samples = DSLOGIC_MAX_DSO_DEPTH / dsl_en_ch_num(sdi);
devc->limit_samples = devc->profile->dev_caps.dso_depth / dsl_en_ch_num(sdi);
}
}
} else if (id == SR_CONF_DEVICE_MODE) {
sdi->mode = g_variant_get_int16(data);
if (sdi->mode == LOGIC) {
dsl_wr_reg(sdi, EEWP_ADDR, bmSCOPE_CLR);
num_probes = devc->profile->dev_caps & DEV_CAPS_16BIT ? 16 : 8;
dsl_wr_reg(sdi, CTR0_ADDR, bmSCOPE_CLR);
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (channel_modes[i].mode == LOGIC &&
devc->profile->dev_caps.channels & (1 << i)) {
devc->ch_mode = channel_modes[i].id;
num_probes = channel_modes[i].num;
devc->stream = channel_modes[i].stream;
dsl_adjust_samplerate(devc);
break;
}
}
} else if (sdi->mode == DSO) {
dsl_wr_reg(sdi, EEWP_ADDR, bmSCOPE_SET);
num_probes = devc->profile->dev_caps & DEV_CAPS_16BIT ? MAX_DSO_PROBES_NUM : 1;
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)
sr_dbg("%s: DSO configuration sync failed", __func__);
devc->cur_samplerate = DSLOGIC_MAX_DSO_SAMPLERATE / num_probes;
devc->limit_samples = DSLOGIC_MAX_DSO_DEPTH / num_probes;
devc->samplerates_size = 15;
} else {
dsl_wr_reg(sdi, EEWP_ADDR, bmSCOPE_CLR);
num_probes = devc->profile->dev_caps & DEV_CAPS_16BIT ? MAX_ANALOG_PROBES_NUM : 1;
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (channel_modes[i].mode == DSO &&
devc->profile->dev_caps.channels & (1 << i)) {
devc->ch_mode = channel_modes[i].id;
num_probes = channel_modes[i].num;
devc->stream = channel_modes[i].stream;
devc->cur_samplerate = channel_modes[i].max_samplerate / num_probes;
dsl_adjust_samplerate(devc);
break;
}
}
devc->limit_samples = devc->profile->dev_caps.dso_depth / num_probes;
} 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)
sr_dbg("%s: DAQ configuration sync failed", __func__);
devc->op_mode = OP_STREAM;
devc->test_mode = SR_TEST_NONE;
devc->stream = TRUE;
devc->samplerates_size = 10;
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (channel_modes[i].mode == ANALOG &&
devc->profile->dev_caps.channels & (1 << i)) {
devc->ch_mode = channel_modes[i].id;
num_probes = channel_modes[i].num;
devc->stream = channel_modes[i].stream;
dsl_adjust_samplerate(devc);
break;
}
}
} else {
ret = SR_ERR;
}
devc->samplecounts_size = counts_size(sdi);
assert(num_probes != 0);
sr_dev_probes_free(sdi);
setup_probes(sdi, num_probes);
dsl_setup_probes(sdi, num_probes);
sr_dbg("%s: setting mode to %d", __func__, sdi->mode);
if (sdi->mode == DSO) {
if (sdi->mode != LOGIC) {
dso_init(sdi);
}
} else if (id == SR_CONF_OPERATION_MODE) {
@@ -1039,70 +824,43 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
devc->op_mode = OP_BUFFER;
devc->test_mode = SR_TEST_NONE;
devc->stream = FALSE;
devc->ch_mode = 0;
devc->samplerates_size = 14;
adjust_probes(sdi, MAX_LOGIC_PROBES);
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (channel_modes[i].mode == LOGIC &&
channel_modes[i].stream == devc->stream &&
devc->profile->dev_caps.channels & (1 << i)) {
devc->ch_mode = channel_modes[i].id;
break;
}
}
} else if (!strcmp(stropt, opmodes[OP_STREAM]) && (devc->op_mode != OP_STREAM)) {
devc->op_mode = OP_STREAM;
devc->test_mode = SR_TEST_NONE;
devc->stream = TRUE;
devc->ch_mode = 0;
devc->samplerates_size = 11;
adjust_probes(sdi, MAX_LOGIC_PROBES);
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (channel_modes[i].mode == LOGIC &&
channel_modes[i].stream == devc->stream &&
devc->profile->dev_caps.channels & (1 << i)) {
devc->ch_mode = channel_modes[i].id;
break;
}
}
} else if (!strcmp(stropt, opmodes[OP_INTEST]) && (devc->op_mode != OP_INTEST)) {
devc->op_mode = OP_INTEST;
devc->test_mode = SR_TEST_INTERNAL;
if (strcmp(sdi->model, "DSLogic Basic") == 0) {
devc->stream = TRUE;
devc->samplerates_size = 10;
} else {
devc->stream = FALSE;
devc->samplerates_size = 14;
}
devc->ch_mode = 0;
adjust_probes(sdi, MAX_LOGIC_PROBES);
devc->limit_samples = DSLOGIC_MAX_LOGIC_DEPTH;
devc->cur_samplerate = DSLOGIC_MAX_LOGIC_SAMPLERATE;
devc->sample_wide = TRUE;
} else if (!strcmp(stropt, opmodes[OP_EXTEST]) && (devc->op_mode != OP_EXTEST)) {
devc->op_mode = OP_EXTEST;
devc->test_mode = SR_TEST_EXTERNAL;
if (strcmp(sdi->model, "DSLogic Basic") == 0) {
devc->stream = TRUE;
devc->samplerates_size = 11;
} else {
devc->stream = FALSE;
devc->samplerates_size = 14;
}
devc->ch_mode = 0;
adjust_probes(sdi, MAX_LOGIC_PROBES);
devc->limit_samples = DSLOGIC_MAX_LOGIC_DEPTH;
devc->cur_samplerate = DSLOGIC_MAX_LOGIC_SAMPLERATE;
devc->sample_wide = TRUE;
} else if (!strcmp(stropt, opmodes[OP_LPTEST]) && (devc->op_mode != OP_LPTEST)) {
devc->op_mode = OP_LPTEST;
devc->test_mode = SR_TEST_LOOPBACK;
devc->stream = FALSE;
devc->ch_mode = 0;
devc->samplerates_size = 14;
adjust_probes(sdi, MAX_LOGIC_PROBES);
devc->limit_samples = DSLOGIC_MAX_LOGIC_DEPTH;
devc->cur_samplerate = DSLOGIC_MAX_LOGIC_SAMPLERATE;
devc->sample_wide = TRUE;
devc->ch_mode = devc->profile->dev_caps.intest_channel;
devc->stream = !(devc->profile->dev_caps.feature_caps & CAPS_FEATURE_BUF);
} else {
ret = SR_ERR;
}
if (devc->cur_samplerate > samplerates[devc->samplerates_size-1]) {
devc->cur_samplerate = samplerates[devc->samplerates_size-1];
devc->sample_wide = (devc->cur_samplerate <= DSLOGIC_MAX_DSO_SAMPLERATE);
dsl_adjust_probes(sdi, channel_modes[devc->ch_mode].num);
dsl_adjust_samplerate(devc);
if (devc->op_mode == OP_INTEST) {
devc->cur_samplerate = devc->stream ? channel_modes[devc->ch_mode].max_samplerate / 2 :
channel_modes[devc->ch_mode].max_samplerate;
devc->limit_samples = devc->stream ? devc->cur_samplerate * 3 :
devc->profile->dev_caps.hw_depth / dsl_en_ch_num(sdi);
}
} else if (sdi->mode == ANALOG) {
devc->op_mode = OP_STREAM;
devc->test_mode = SR_TEST_NONE;
devc->stream = TRUE;
devc->samplerates_size = 10;
}
devc->samplecounts_size = counts_size(sdi);
sr_dbg("%s: setting pattern to %d",
__func__, devc->op_mode);
} else if (id == SR_CONF_BUFFER_OPTIONS) {
@@ -1116,27 +874,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
} else if (id == SR_CONF_CHANNEL_MODE) {
stropt = g_variant_get_string(data, NULL);
if (sdi->mode == LOGIC) {
if (devc->stream) {
for (i = 0; i < ARRAY_SIZE(stream_ch_modes); i++)
if (!strcmp(stropt, stream_ch_modes[i])) {
devc->ch_mode = i;
devc->samplerates_size = 11 + i;
adjust_probes(sdi, MAX_LOGIC_PROBES);
break;
}
} else {
for (i = 0; i < ARRAY_SIZE(buffer_ch_modes); i++)
if (!strcmp(stropt, buffer_ch_modes[i])) {
devc->ch_mode = i;
devc->samplerates_size = 14 + i;
adjust_probes(sdi, buffer_ch_num[i]);
break;
}
}
if (devc->cur_samplerate > samplerates[devc->samplerates_size-1]) {
devc->cur_samplerate = samplerates[devc->samplerates_size-1];
devc->sample_wide = (devc->cur_samplerate <= DSLOGIC_MAX_DSO_SAMPLERATE);
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (!strcmp(stropt, channel_modes[i].descr)) {
devc->ch_mode = channel_modes[i].id;
break;
}
}
dsl_adjust_probes(sdi, channel_modes[devc->ch_mode].num);
dsl_adjust_samplerate(devc);
}
sr_dbg("%s: setting channel mode to %d",
__func__, devc->ch_mode);
@@ -1223,8 +968,25 @@ 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) {
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));
}
if (ret == SR_OK)
sr_dbg("%s: setting DSO Trigger Source to %d",
__func__, devc->trigger_source);
else
sr_dbg("%s: setting DSO Trigger Source to %d failed",
__func__, devc->trigger_source);
} else if (id == SR_CONF_STREAM) {
devc->stream = g_variant_get_boolean(data);
} else if (id == SR_CONF_PROBE_MAP_UNIT) {
ch->map_unit = g_variant_get_string(data, NULL);
} else if (id == SR_CONF_PROBE_MAP_MIN) {
ch->map_min = g_variant_get_double(data);
} else if (id == SR_CONF_PROBE_MAP_MAX) {
ch->map_max = g_variant_get_double(data);
} else {
ret = SR_ERR_NA;
}
@@ -1236,63 +998,33 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
struct DSL_context *devc;
GVariant *gvar;
GVariantBuilder gvb;
GVariantBuilder gvb;
unsigned int i;
//(void)sdi;
(void)cg;
devc = sdi->priv;
if (dsl_config_list(key, data, sdi, cg) == SR_OK) {
return SR_OK;
}
switch (key) {
case SR_CONF_SCAN_OPTIONS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwopts, ARRAY_SIZE(hwopts)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_DEVICE_OPTIONS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwcaps, ARRAY_SIZE(hwcaps)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_DEVICE_CONFIGS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
if (strcmp(sdi->model, "DSLogic") == 0)
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwoptions, ARRAY_SIZE(hwoptions)*sizeof(int32_t), TRUE, NULL, NULL);
else
if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_VTH)
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwoptions_pro, ARRAY_SIZE(hwoptions_pro)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_DEVICE_SESSIONS:
if (strcmp(sdi->model, "DSLogic") == 0)
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
sessions, ARRAY_SIZE(sessions)*sizeof(int32_t), TRUE, NULL, NULL);
else
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwoptions, ARRAY_SIZE(hwoptions)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_DEVICE_SESSIONS:
if (devc->profile->dev_caps.feature_caps & CAPS_FEATURE_VTH)
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
sessions_pro, ARRAY_SIZE(sessions_pro)*sizeof(int32_t), TRUE, NULL, NULL);
else
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
sessions, ARRAY_SIZE(sessions)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
// gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
// ARRAY_SIZE(samplerates), sizeof(uint64_t));
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplerates, devc->samplerates_size*sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_LIMIT_SAMPLES:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplecounts, devc->samplecounts_size*sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "samplecounts", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_TRIGGER_TYPE:
*data = g_variant_new_string(TRIGGER_TYPE);
break;
case SR_CONF_OPERATION_MODE:
*data = g_variant_new_strv(opmodes, opmodes_show_count);
break;
@@ -1300,12 +1032,16 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
*data = g_variant_new_strv(bufoptions, ARRAY_SIZE(bufoptions));
break;
case SR_CONF_CHANNEL_MODE:
if (devc->stream)
*data = g_variant_new_strv(stream_ch_modes, ARRAY_SIZE(stream_ch_modes));
else if (devc->test_mode != SR_TEST_NONE)
*data = g_variant_new_strv(buffer_ch_modes, 1);
else
*data = g_variant_new_strv(buffer_ch_modes, ARRAY_SIZE(buffer_ch_modes));
g_variant_builder_init(&gvb, G_VARIANT_TYPE("as"));
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if (channel_modes[i].stream == devc->stream &&
devc->profile->dev_caps.channels & (1 << i)) {
g_variant_builder_add(&gvb, "s", channel_modes[i].descr);
if (devc->test_mode != SR_TEST_NONE)
break;
}
}
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_THRESHOLD:
*data = g_variant_new_strv(thresholds, ARRAY_SIZE(thresholds));
@@ -1341,7 +1077,8 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi)
{
int ret = dsl_dev_close(sdi);
int ret;
ret = dsl_dev_close(sdi);
return ret;
}
@@ -1364,7 +1101,7 @@ static int cleanup(void)
static void remove_sources(struct DSL_context *devc)
{
int i;
sr_err("%s: remove fds from polling", __func__);
sr_info("%s: remove fds from polling", __func__);
/* Remove fds from polling. */
for (i = 0; devc->usbfd[i] != -1; i++)
sr_source_remove(devc->usbfd[i]);
@@ -1440,7 +1177,10 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
devc->status = DSL_INIT;
devc->num_transfers = 0;
devc->submitted_transfers = 0;
devc->actual_samples = devc->limit_samples;
if (sdi->mode != LOGIC)
devc->actual_samples = (devc->limit_samples + 1023) & ~1023;
else
devc->actual_samples = devc->limit_samples;
devc->actual_bytes = devc->actual_samples / DSLOGIC_ATOMIC_SAMPLES * dsl_en_ch_num(sdi) * DSLOGIC_ATOMIC_SIZE;
devc->abort = FALSE;
devc->mstatus_valid = FALSE;

View File

@@ -20,122 +20,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
/* Message logging helpers with subsystem-specific prefix string. */
#define LOG_PREFIX "demo: "
#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
/* TODO: Number of probes should be configurable. */
#define NUM_PROBES 16
#define DEMONAME "Demo device"
#include "demo.h"
/* The size of chunks to send through the session bus. */
/* TODO: Should be configurable. */
#define BUFSIZE 512*1024
#define DSO_BUFSIZE 10*1024
#define PERIOD 4000
#define PI 3.14159265
#define CONST_LEN 50
#define DEMO_MAX_LOGIC_DEPTH SR_MB(100)
#define DEMO_MAX_LOGIC_SAMPLERATE SR_MHZ(400)
#define DEMO_MAX_DSO_DEPTH SR_KB(20)
#define DEMO_MAX_DSO_SAMPLERATE SR_MHZ(200)
#define DEMO_MAX_DSO_PROBES_NUM 2
/* Supported patterns which we can generate */
enum {
PATTERN_SINE = 0,
PATTERN_SQUARE = 1,
PATTERN_TRIANGLE = 2,
PATTERN_SAWTOOTH = 3,
PATTERN_RANDOM = 4,
};
static const char *pattern_strings[] = {
"Sine",
"Square",
"Triangle",
"Sawtooth",
"Random",
};
static const char *maxHeights[] = {
"1X",
"2X",
"3X",
"4X",
"5X",
};
static struct sr_dev_mode mode_list[] = {
{"LA", LOGIC},
{"DAQ", ANALOG},
{"OSC", DSO},
};
/* Private, per-device-instance driver context. */
struct dev_context {
struct sr_dev_inst *sdi;
int pipe_fds[2];
GIOChannel *channel;
uint64_t cur_samplerate;
uint64_t limit_samples;
uint64_t limit_samples_show;
uint64_t limit_msec;
uint8_t sample_generator;
uint64_t samples_counter;
void *cb_data;
int64_t starttime;
int stop;
uint64_t timebase;
gboolean instant;
gboolean data_lock;
uint8_t max_height;
uint8_t unit_bits;
uint64_t samples_not_sent;
uint16_t *buf;
uint64_t pre_index;
struct sr_status mstatus;
int trigger_stage;
uint16_t trigger_mask;
uint16_t trigger_value;
uint16_t trigger_edge;
uint8_t trigger_slope;
uint8_t trigger_source;
};
static const int hwcaps[] = {
SR_CONF_LOGIC_ANALYZER,
SR_CONF_DEMO_DEV,
SR_CONF_SAMPLERATE,
SR_CONF_PATTERN_MODE,
SR_CONF_LIMIT_SAMPLES,
SR_CONF_LIMIT_MSEC,
SR_CONF_CONTINUOUS,
};
static const int hwoptions[] = {
SR_CONF_PATTERN_MODE,
SR_CONF_MAX_HEIGHT,
@@ -168,175 +59,6 @@ static const uint8_t probeCoupling[] = {
SR_AC_COUPLING,
};
static const uint64_t probeVdivs[] = {
SR_mV(10),
SR_mV(20),
SR_mV(50),
SR_mV(100),
SR_mV(200),
SR_mV(500),
SR_V(1),
SR_V(2),
};
static const char *probeMapUnits[] = {
"V",
"A",
"°C",
"°F",
"g",
"m",
"m/s",
};
static const int const_dc = 1.95 / 10 * 255;
static const int sinx[] = {
0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 18, 20, 21, 23, 24, 26, 27, 28,
30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, 47,
48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 48, 48,
47, 47, 46, 46, 45, 44, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30,
29, 28, 26, 25, 24, 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 2, 1,
-1, -2, -4, -6, -7, -9, -10, -12, -13, -15, -16, -18, -19, -21, -22, -24, -25, -26, -28, -29,
-30, -31, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -44, -45, -46, -46, -47, -47,
-48, -48, -49, -49, -49, -50, -50, -50, -50, -50, -50, -50, -50, -50, -49, -49, -49, -49, -48, -48,
-47, -47, -46, -45, -45, -44, -43, -42, -41, -41, -40, -39, -38, -37, -35, -34, -33, -32, -31, -30,
-28, -27, -26, -24, -23, -21, -20, -18, -17, -16, -14, -12, -11, -9, -8, -6, -5, -3, -2, 0,
};
static const int sqrx[] = {
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
};
static const int trix[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41,
40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21,
20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19,
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39,
-40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41,
-40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21,
-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
};
static const int sawx[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19,
20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29,
30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39,
40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 50,
-50, -49, -48, -48, -47, -47, -46, -46, -45, -45, -44, -44, -43, -43, -42, -42, -41, -41, -40, -40,
-39, -39, -38, -38, -37, -37, -36, -36, -35, -35, -34, -34, -33, -33, -32, -32, -31, -31, -30, -30,
-29, -29, -28, -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22, -22, -21, -21, -20, -20,
-19, -19, -18, -18, -17, -17, -16, -16, -15, -15, -14, -14, -13, -13, -12, -12, -11, -11, -10, -10,
-9, -9, -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0,
};
static const int ranx[] = {
-4, 47, -49, -1, -3, 6, -29, 26, 1, 14, -39, -38, 36, 17, 26, -37, -2, 27, -20, -15,
-49, -46, 36, 16, 29, 23, -30, -3, 28, -2, -6, 46, 43, 50, -42, 30, 48, -50, -38, -30,
7, -36, -20, -24, -10, -34, -24, 3, -48, 46, -11, 22, 19, 28, 39, -49, -31, 34, 2, -29,
9, 35, 8, 10, 38, 30, 17, 48, -3, -6, -28, 46, -19, 18, -43, -9, -31, -32, -41, 16,
-10, 46, -4, 4, -32, -43, -45, -39, -33, 28, 24, -17, -43, 42, -7, 36, -44, -5, 9, 39,
17, -40, 12, 16, -42, -1, 2, -9, 50, -8, 27, 27, 14, 8, -18, 12, -8, 26, -8, 12,
-35, 49, 35, 2, -26, -24, -31, 33, 15, -47, 34, 46, -1, -12, 14, 32, -25, -31, -35, -18,
-48, -21, -5, 1, -27, -14, 12, 49, -11, 33, 31, 35, -36, 19, 20, 44, 29, -48, 14, -43,
1, 30, -12, 44, 20, 49, 29, -43, 42, 30, -34, 24, 20, -40, 33, -12, 13, -45, 45, -24,
-41, 36, -8, 46, 47, -34, 28, -39, 7, -32, 38, -27, 28, -3, -8, 43, -37, -24, 6, 3,
};
static const uint64_t samplerates[] = {
SR_HZ(100),
SR_HZ(200),
SR_HZ(500),
SR_KHZ(1),
SR_KHZ(2),
SR_KHZ(5),
SR_KHZ(10),
SR_KHZ(20),
SR_KHZ(50),
SR_KHZ(100),
SR_KHZ(200),
SR_KHZ(500),
SR_MHZ(1),
SR_MHZ(2),
SR_MHZ(5),
SR_MHZ(10),
SR_MHZ(20),
SR_MHZ(50),
SR_MHZ(100),
SR_MHZ(200),
};
//static const uint64_t samplecounts[] = {
// SR_KB(1),
// SR_KB(2),
// SR_KB(4),
// SR_KB(8),
// SR_KB(16),
// SR_KB(32),
// SR_KB(64),
// SR_KB(128),
// SR_KB(256),
// SR_KB(512),
// SR_MB(1),
// SR_MB(2),
// SR_MB(4),
// SR_MB(8),
// SR_MB(16),
// SR_MB(32),
// SR_MB(64),
// SR_MB(128),
//};
static const uint64_t samplecounts[] = {
SR_KB(1),
SR_KB(2),
SR_KB(5),
SR_KB(10),
SR_KB(20),
SR_KB(50),
SR_KB(100),
SR_KB(200),
SR_KB(500),
SR_MB(1),
SR_MB(2),
SR_MB(5),
SR_MB(10),
SR_MB(20),
SR_MB(50),
SR_MB(100),
};
/* We name the probes 0-7 on our demo driver. */
static const char *probe_names[NUM_PROBES + 1] = {
"0", "1", "2", "3",
"4", "5", "6", "7",
"8", "9", "10", "11",
"12", "13", "14", "15",
NULL,
};
static const gboolean default_ms_en[] = {
FALSE, /* DSO_MS_BEGIN */
TRUE, /* DSO_MS_FREQ */
FALSE, /* DSO_MS_PERD */
TRUE, /* DSO_MS_VMAX */
TRUE, /* DSO_MS_VMIN */
FALSE, /* DSO_MS_VRMS */
FALSE, /* DSO_MS_VMEA */
FALSE, /* DSO_MS_VP2P */
};
/* Private, per-device-instance driver context. */
/* TODO: struct context as with the other drivers. */
@@ -361,6 +83,27 @@ static int hw_init(struct sr_context *sr_ctx)
return std_hw_init(sr_ctx, di, LOG_PREFIX);
}
static void adjust_samplerate(struct demo_context *devc)
{
devc->samplerates_max_index = ARRAY_SIZE(samplerates) - 1;
while (samplerates[devc->samplerates_max_index] >
channel_modes[devc->ch_mode].max_samplerate)
devc->samplerates_max_index--;
devc->samplerates_min_index = 0;
while (samplerates[devc->samplerates_min_index] <
channel_modes[devc->ch_mode].min_samplerate)
devc->samplerates_min_index++;
assert(devc->samplerates_max_index >= devc->samplerates_min_index);
if (devc->cur_samplerate > samplerates[devc->samplerates_max_index])
devc->cur_samplerate = samplerates[devc->samplerates_max_index];
if (devc->cur_samplerate < samplerates[devc->samplerates_min_index])
devc->cur_samplerate = samplerates[devc->samplerates_min_index];
}
static void probe_init(struct sr_dev_inst *sdi)
{
int i;
@@ -385,10 +128,10 @@ static int setup_probes(struct sr_dev_inst *sdi, int num_probes)
{
uint16_t j;
struct sr_channel *probe;
struct demo_context *devc = sdi->priv;
for (j = 0; j < num_probes; j++) {
if (!(probe = sr_channel_new(j, (sdi->mode == LOGIC) ? SR_CHANNEL_LOGIC :
((sdi->mode == DSO) ? SR_CHANNEL_DSO : SR_CHANNEL_ANALOG),
if (!(probe = sr_channel_new(j, channel_modes[devc->ch_mode].type,
TRUE, probe_names[j])))
return SR_ERR;
sdi->channels = g_slist_append(sdi->channels, probe);
@@ -400,68 +143,45 @@ static int setup_probes(struct sr_dev_inst *sdi, int num_probes)
static GSList *hw_scan(GSList *options)
{
struct sr_dev_inst *sdi;
struct sr_channel *probe;
struct drv_context *drvc;
struct dev_context *devc;
struct demo_context *devc;
GSList *devices;
uint16_t i;
(void)options;
drvc = di->priv;
devices = NULL;
sdi = sr_dev_inst_new(LOGIC, 0, SR_ST_INITIALIZING, DEMONAME, NULL, NULL);
if (!(devc = g_try_malloc(sizeof(struct demo_context)))) {
sr_err("Device context malloc failed.");
return NULL;
}
devc->profile = &supported_Demo[0];
devc->ch_mode = devc->profile->dev_caps.default_channelmode;
devc->cur_samplerate = channel_modes[devc->ch_mode].default_samplerate;
devc->limit_samples = channel_modes[devc->ch_mode].default_samplelimit;
devc->limit_samples_show = devc->limit_samples;
devc->limit_msec = 0;
devc->sample_generator = devc->profile->dev_caps.default_pattern;
devc->timebase = devc->profile->dev_caps.default_timebase;
devc->max_height = 0;
adjust_samplerate(devc);
sdi = sr_dev_inst_new(channel_modes[devc->ch_mode].mode, 0, SR_ST_INITIALIZING,
devc->profile->vendor,
devc->profile->model,
devc->profile->model_version);
if (!sdi) {
g_free(devc);
sr_err("Device instance creation failed.");
return NULL;
}
sdi->priv = devc;
sdi->driver = di;
devices = g_slist_append(devices, sdi);
drvc->instances = g_slist_append(drvc->instances, sdi);
if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
sr_err("Device context malloc failed.");
return NULL;
}
devc->sdi = sdi;
devc->cur_samplerate = SR_MHZ(1);
devc->limit_samples = SR_MB(1);
devc->limit_samples_show = devc->limit_samples;
devc->limit_msec = 0;
devc->sample_generator = PATTERN_SINE;
devc->timebase = 500;
devc->data_lock = FALSE;
devc->max_height = 0;
devc->unit_bits = 8;
sdi->priv = devc;
if (sdi->mode == LOGIC) {
for (i = 0; probe_names[i]; i++) {
if (!(probe = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
probe_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, probe);
}
} else if (sdi->mode == DSO) {
for (i = 0; i < DS_MAX_DSO_PROBES_NUM; i++) {
if (!(probe = sr_channel_new(i, SR_CHANNEL_DSO, TRUE,
probe_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, probe);
}
} else if (sdi->mode == ANALOG) {
for (i = 0; i < DS_MAX_ANALOG_PROBES_NUM; i++) {
if (!(probe = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE,
probe_names[i])))
return NULL;
sdi->channels = g_slist_append(sdi->channels, probe);
}
}
setup_probes(sdi, channel_modes[devc->ch_mode].num);
return devices;
}
@@ -471,14 +191,16 @@ static GSList *hw_dev_list(void)
return ((struct drv_context *)(di->priv))->instances;
}
static GSList *hw_dev_mode_list(const struct sr_dev_inst *sdi)
static const GSList *hw_dev_mode_list(const struct sr_dev_inst *sdi)
{
(void)sdi;
struct demo_context *devc;
GSList *l = NULL;
unsigned int i;
for(i = 0; i < ARRAY_SIZE(mode_list); i++) {
l = g_slist_append(l, &mode_list[i]);
devc = sdi->priv;
for (i = 0; i < ARRAY_SIZE(mode_list); i++) {
if (devc->profile->dev_caps.mode_caps & (1 << i))
l = g_slist_append(l, &mode_list[i]);
}
return l;
@@ -487,7 +209,7 @@ static GSList *hw_dev_mode_list(const struct sr_dev_inst *sdi)
static int hw_dev_open(struct sr_dev_inst *sdi)
{
//(void)sdi;
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
sdi->status = SR_ST_ACTIVE;
@@ -509,7 +231,7 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
static int hw_dev_close(struct sr_dev_inst *sdi)
{
//(void)sdi;
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
if (sdi->status == SR_ST_ACTIVE && devc->channel) {
g_io_channel_shutdown(devc->channel, FALSE, NULL);
@@ -566,7 +288,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
{
(void) cg;
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
switch (id) {
case SR_CONF_SAMPLERATE:
@@ -608,6 +330,11 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_TIMEBASE:
*data = g_variant_new_uint64(devc->timebase);
break;
case SR_CONF_MAX_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(MAX_TIMEBASE);
break;
case SR_CONF_PROBE_COUPLING:
*data = g_variant_new_byte(ch->coupling);
break;
@@ -617,20 +344,17 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
case SR_CONF_PROBE_EN:
*data = g_variant_new_boolean(ch->enabled);
break;
case SR_CONF_DATALOCK:
*data = g_variant_new_boolean(devc->data_lock);
break;
case SR_CONF_MAX_DSO_SAMPLERATE:
*data = g_variant_new_uint64(DEMO_MAX_DSO_SAMPLERATE);
*data = g_variant_new_uint64(channel_modes[devc->ch_mode].max_samplerate);
break;
case SR_CONF_MAX_DSO_SAMPLELIMITS:
*data = g_variant_new_uint64(DEMO_MAX_DSO_DEPTH);
*data = g_variant_new_uint64(devc->profile->dev_caps.dso_depth);
break;
case SR_CONF_HW_DEPTH:
*data = g_variant_new_uint64(DEMO_MAX_LOGIC_DEPTH);
*data = g_variant_new_uint64(devc->profile->dev_caps.hw_depth / channel_modes[devc->ch_mode].unit_bits);
break;
case SR_CONF_UNIT_BITS:
*data = g_variant_new_byte(devc->unit_bits);
*data = g_variant_new_byte(channel_modes[devc->ch_mode].unit_bits);
break;
case SR_CONF_PROBE_MAP_UNIT:
if (!sdi || !ch)
@@ -648,7 +372,12 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
*data = g_variant_new_double(ch->map_max);
break;
case SR_CONF_VLD_CH_NUM:
*data = g_variant_new_int16(NUM_PROBES);
*data = g_variant_new_int16(channel_modes[devc->ch_mode].num);
break;
case SR_CONF_HAVE_ZERO:
if (!sdi)
return SR_ERR;
*data = g_variant_new_boolean(devc->profile->dev_caps.feature_caps & CAPS_FEATURE_ZERO);
break;
default:
return SR_ERR_NA;
@@ -668,7 +397,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
(void) cg;
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
@@ -701,26 +430,21 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
} else if (id == SR_CONF_DEVICE_MODE) {
sdi->mode = g_variant_get_int16(data);
ret = SR_OK;
if (sdi->mode == LOGIC) {
num_probes = ARRAY_SIZE(probe_names) - 1;
devc->cur_samplerate = SR_MHZ(1);
devc->limit_samples = SR_MB(1);
devc->limit_samples_show = devc->limit_samples;
} else if (sdi->mode == DSO) {
num_probes = DEMO_MAX_DSO_PROBES_NUM;
devc->cur_samplerate = DEMO_MAX_DSO_SAMPLERATE / DEMO_MAX_DSO_PROBES_NUM;
devc->limit_samples = DEMO_MAX_DSO_DEPTH / DEMO_MAX_DSO_PROBES_NUM;
devc->limit_samples_show = devc->limit_samples;
} else if (sdi->mode == ANALOG) {
num_probes = DS_MAX_ANALOG_PROBES_NUM;
devc->cur_samplerate = SR_KHZ(1);
devc->limit_samples = SR_KB(2);
devc->limit_samples_show = devc->limit_samples;
} else {
num_probes = 0;
for (i = 0; i < ARRAY_SIZE(channel_modes); i++) {
if ((int)channel_modes[i].mode == sdi->mode &&
devc->profile->dev_caps.channels & (1 << i)) {
devc->ch_mode = channel_modes[i].id;
break;
}
}
num_probes = channel_modes[devc->ch_mode].num;
devc->cur_samplerate = channel_modes[devc->ch_mode].default_samplerate;
devc->limit_samples = channel_modes[devc->ch_mode].default_samplelimit;
devc->limit_samples_show = devc->limit_samples;
devc->timebase = devc->profile->dev_caps.default_timebase;
sr_dev_probes_free(sdi);
setup_probes(sdi, num_probes);
adjust_samplerate(devc);
sr_dbg("%s: setting mode to %d", __func__, sdi->mode);
}else if (id == SR_CONF_PATTERN_MODE) {
stropt = g_variant_get_string(data, NULL);
@@ -765,16 +489,11 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
} else if (id == SR_CONF_PROBE_EN) {
ch->enabled = g_variant_get_boolean(data);
if (en_ch_num(sdi) != 0) {
devc->limit_samples_show = DEMO_MAX_DSO_DEPTH / en_ch_num(sdi);
devc->limit_samples_show = devc->profile->dev_caps.dso_depth / en_ch_num(sdi);
}
sr_dbg("%s: setting ENABLE of channel %d to %d", __func__,
ch->index, ch->enabled);
ret = SR_OK;
} else if (id == SR_CONF_DATALOCK) {
devc->data_lock = g_variant_get_boolean(data);
sr_dbg("%s: setting data lock to %d", __func__,
devc->data_lock);
ret = SR_OK;
} else if (id == SR_CONF_PROBE_VDIV) {
tmp_u64 = g_variant_get_uint64(data);
ch->vpos = (tmp_u64 * 1.0 / ch->vdiv) * ch->vpos;
@@ -819,10 +538,13 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
ret = SR_OK;
} else if (id == SR_CONF_PROBE_MAP_UNIT) {
ch->map_unit = g_variant_get_string(data, NULL);
ret = SR_OK;
} else if (id == SR_CONF_PROBE_MAP_MIN) {
ch->map_min = g_variant_get_double(data);
ret = SR_OK;
} else if (id == SR_CONF_PROBE_MAP_MAX) {
ch->map_max = g_variant_get_double(data);
ret = SR_OK;
} else {
ret = SR_ERR_NA;
}
@@ -833,21 +555,17 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
struct demo_context *devc;
GVariant *gvar;
GVariantBuilder gvb;
int i;
(void)sdi;
(void)cg;
devc = sdi->priv;
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwcaps, ARRAY_SIZE(hwcaps)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_DEVICE_CONFIGS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwoptions, ARRAY_SIZE(hwoptions)*sizeof(int32_t), TRUE, NULL, NULL);
@@ -858,27 +576,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
break;
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
// gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
// ARRAY_SIZE(samplerates), sizeof(uint64_t));
if (sdi->mode == ANALOG)
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplerates, 16*sizeof(uint64_t), TRUE, NULL, NULL);
else if (sdi->mode == LOGIC)
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplerates, 19*sizeof(uint64_t), TRUE, NULL, NULL);
else
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplerates, ARRAY_SIZE(samplerates)*sizeof(uint64_t), TRUE, NULL, NULL);
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplerates + devc->samplerates_min_index,
(devc->samplerates_max_index - devc->samplerates_min_index + 1) * sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_LIMIT_SAMPLES:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
samplecounts, ARRAY_SIZE(samplecounts)*sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "samplecounts", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_PATTERN_MODE:
*data = g_variant_new_strv(pattern_strings, ARRAY_SIZE(pattern_strings));
break;
@@ -896,8 +599,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
break;
case SR_CONF_PROBE_VDIV:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
for (i = 0; devc->profile->dev_caps.vdivs[i]; i++);
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
probeVdivs, ARRAY_SIZE(probeVdivs)*sizeof(uint64_t), TRUE, NULL, NULL);
devc->profile->dev_caps.vdivs, i*sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "vdivs", gvar);
*data = g_variant_builder_end(&gvb);
break;
@@ -920,18 +624,19 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
static void samples_generator(uint16_t *buf, uint64_t size,
const struct sr_dev_inst *sdi,
struct dev_context *devc)
struct demo_context *devc)
{
uint64_t i, pre0_i, pre1_i;
GSList *l;
struct sr_channel *probe;
int offset;
unsigned int start_rand;
const uint64_t span = DEMO_MAX_DSO_SAMPLERATE / devc->cur_samplerate;
double span = 1;
const uint64_t len = ARRAY_SIZE(sinx) - 1;
const int *pre_buf;
uint16_t tmp_u16 = 0;
unsigned int ch_num = en_ch_num(sdi) ? en_ch_num(sdi) : 1;
uint64_t index = 0;
switch (devc->sample_generator) {
case PATTERN_SINE: /* Sine */
@@ -954,10 +659,10 @@ static void samples_generator(uint16_t *buf, uint64_t size,
break;
}
if (devc->samples_counter == devc->limit_samples &&
if (sdi->mode == DSO && devc->samples_counter == devc->limit_samples &&
size != devc->limit_samples) {
// for (i = 0; i < devc->limit_samples; i++)
// *(buf + i) = *(buf + ((i + size)%devc->limit_samples));
for (i = 0; i < devc->limit_samples; i++)
*(buf + i) = *(buf + ((i + size)%devc->limit_samples));
} else if (sdi->mode == LOGIC) {
for (i = 0; i < size; i++) {
//index = (i/10/g_slist_length(sdi->channels)+start_rand)%len;
@@ -974,17 +679,25 @@ static void samples_generator(uint16_t *buf, uint64_t size,
*(buf + i) = *(buf + i - 1);
}
}
} else if (sdi->mode == ANALOG) {
for (i = 0; i < size; i++) {
*(buf + i) = 0x8080;
if (i % (int)ceil(size / 7.0))
*(buf + i) = 0x7E7E + (rand() & 0x0300) + (rand() & 0x003);
else if (rand() > INT_MAX / 4)
*(buf + i) = 0x7878 + (rand() & 0x0F00) + (rand() & 0x00F);
else if (rand() < INT_MAX / 8)
*(buf + i) = 0x6060 + (rand() & 0x3F00) + (rand() & 0x03F);
}
// } else if (sdi->mode == ANALOG) {
// for (i = 0; i < size; i++) {
// *(buf + i) = 0x8080;
// if (i % (int)ceil(size / 7.0))
// *(buf + i) = 0x7E7E + (rand() & 0x0300) + (rand() & 0x003);
// else if (rand() > INT_MAX / 4)
// *(buf + i) = 0x7878 + (rand() & 0x0F00) + (rand() & 0x00F);
// else if (rand() < INT_MAX / 8)
// *(buf + i) = 0x6060 + (rand() & 0x3F00) + (rand() & 0x03F);
// }
} else {
if (sdi->mode == DSO) {
index = devc->pre_index;
span = channel_modes[devc->ch_mode].max_samplerate / devc->cur_samplerate;
} else if (sdi->mode == ANALOG) {
span = len * 20.0 / devc->limit_samples;
index = 0;
}
if (devc->pre_index == 0) {
devc->mstatus.ch0_max = 0;
devc->mstatus.ch0_min = 255;
@@ -995,19 +708,27 @@ static void samples_generator(uint16_t *buf, uint64_t size,
devc->mstatus.ch1_period = 0;
devc->mstatus.ch1_pcnt = 1;
}
memset(buf+devc->pre_index, 0, size*sizeof(uint16_t));
if (sdi->mode == DSO)
memset(buf+devc->pre_index, 0, size*sizeof(uint16_t));
else if (sdi->mode == ANALOG)
memset(buf, 0, size*sizeof(uint16_t));
for (l = sdi->channels; l; l = l->next) {
start_rand = devc->pre_index == 0 ? rand()%len : 0;
if (sdi->mode == DSO)
start_rand = (devc->pre_index == 0) ? rand()%len : 0;
else
start_rand = devc->pre_index * span;
probe = (struct sr_channel *)l->data;
offset = ceil((0.5 - (probe->vpos/probe->vdiv/10.0)) * 255);
//offset = 128;
pre0_i = devc->pre_index;
pre1_i = devc->pre_index;
for (i = devc->pre_index; i < devc->pre_index + size; i++) {
for (i = index; i < index + size; i++) {
if (probe->coupling == SR_DC_COUPLING) {
*(buf + i) += (uint8_t)(offset + (1000.0/probe->vdiv) * (pre_buf[(i*span+start_rand)%len] - const_dc)) << (probe->index * 8);
*(buf + i) += (uint8_t)(offset + (1000.0/probe->vdiv) * (pre_buf[(uint64_t)(i*span+start_rand)%len] - const_dc)) << (probe->index * 8);
} else if (probe->coupling == SR_AC_COUPLING) {
*(buf + i) += (uint8_t)(offset + (1000.0/probe->vdiv) * pre_buf[(i*span+start_rand)%len]) << (probe->index * 8);
*(buf + i) += (uint8_t)(offset + (1000.0/probe->vdiv) * pre_buf[(uint64_t)(i*span+start_rand)%len]) << (probe->index * 8);
} else {
*(buf + i) += offset << (probe->index * 8);
}
@@ -1016,18 +737,18 @@ static void samples_generator(uint16_t *buf, uint64_t size,
devc->mstatus.ch0_max = MAX(devc->mstatus.ch0_max, (*(buf + i) & 0x00ff));
devc->mstatus.ch0_min = MIN(devc->mstatus.ch0_min, (*(buf + i) & 0x00ff));
if (i > devc->pre_index &&
pre_buf[(i*span+start_rand)%len] < 0 &&
pre_buf[((i-1)*span+start_rand)%len] > 0) {
devc->mstatus.ch0_period = 2*(i - pre0_i)*pow(10, 8)/DEMO_MAX_DSO_SAMPLERATE;
pre_buf[(uint64_t)(i*span+start_rand)%len] < 0 &&
pre_buf[(uint64_t)((i-1)*span+start_rand)%len] > 0) {
devc->mstatus.ch0_period = 2*(i - pre0_i)*pow(10, 8)/channel_modes[devc->ch_mode].max_samplerate;
pre0_i = i;
}
} else {
devc->mstatus.ch1_max = MAX(devc->mstatus.ch1_max, ((*(buf + i) & 0xff00) >> 8));
devc->mstatus.ch1_min = MIN(devc->mstatus.ch1_min, ((*(buf + i) & 0xff00) >> 8));
if (i > devc->pre_index &&
pre_buf[(i*span+start_rand)%len] < 0 &&
pre_buf[((i-1)*span+start_rand)%len] > 0) {
devc->mstatus.ch1_period = 2*(i - pre1_i)*pow(10, 8)/DEMO_MAX_DSO_SAMPLERATE;
pre_buf[(uint64_t)(i*span+start_rand)%len] < 0 &&
pre_buf[(uint64_t)((i-1)*span+start_rand)%len] > 0) {
devc->mstatus.ch1_period = 2*(i - pre1_i)*pow(10, 8)/channel_modes[devc->ch_mode].max_samplerate;
pre1_i = i;
}
}
@@ -1050,7 +771,7 @@ static void samples_generator(uint16_t *buf, uint64_t size,
/* Callback handling data */
static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
{
struct dev_context *devc = sdi->priv;
struct demo_context *devc = sdi->priv;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
struct sr_datafeed_dso dso;
@@ -1145,7 +866,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
if (sdi->mode == LOGIC) {
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
logic.length = sending_now * (NUM_PROBES >> 3);
logic.length = sending_now * (channel_modes[devc->ch_mode].num >> 3);
logic.format = LA_CROSS_DATA;
logic.data = devc->buf;
} else if (sdi->mode == DSO) {
@@ -1167,7 +888,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
packet.payload = &analog;
analog.probes = sdi->channels;
analog.num_samples = sending_now;
analog.unit_bits = 8;
analog.unit_bits = channel_modes[devc->ch_mode].unit_bits;;
analog.mq = SR_MQ_VOLTAGE;
analog.unit = SR_UNIT_VOLT;
analog.mqflags = SR_MQFLAG_AC;
@@ -1178,6 +899,8 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
devc->pre_index += sending_now;
if (devc->pre_index >= devc->limit_samples)
devc->pre_index = 0;
} else if (sdi->mode == ANALOG) {
devc->pre_index =(devc->pre_index + sending_now) % devc->limit_samples;
}
sr_session_send(sdi, &packet);
@@ -1203,7 +926,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
static int hw_dev_acquisition_start(struct sr_dev_inst *sdi,
void *cb_data)
{
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
(void)cb_data;
@@ -1223,17 +946,18 @@ static int hw_dev_acquisition_start(struct sr_dev_inst *sdi,
/*
* trigger setting
*/
if (!trigger->trigger_en || sdi->mode != LOGIC) {
devc->trigger_stage = 0;
} else {
devc->trigger_mask = ds_trigger_get_mask0(TriggerStages);
devc->trigger_value = ds_trigger_get_value0(TriggerStages);
devc->trigger_edge = ds_trigger_get_edge0(TriggerStages);
if (devc->trigger_edge != 0)
devc->trigger_stage = 2;
else
devc->trigger_stage = 1;
}
// if (!trigger->trigger_en || sdi->mode != LOGIC) {
// devc->trigger_stage = 0;
// } else {
// devc->trigger_mask = ds_trigger_get_mask0(TriggerStages);
// devc->trigger_value = ds_trigger_get_value0(TriggerStages);
// devc->trigger_edge = ds_trigger_get_edge0(TriggerStages);
// if (devc->trigger_edge != 0)
// devc->trigger_stage = 2;
// else
// devc->trigger_stage = 1;
// }
devc->trigger_stage = 0;
/*
* Setting two channels connected by a pipe is a remnant from when the
@@ -1265,7 +989,7 @@ static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data)
{
(void)cb_data;
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
struct sr_datafeed_packet packet;
if (devc->stop)
return SR_OK;
@@ -1292,7 +1016,7 @@ static int hw_dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *st
(void)begin;
(void)end;
if (sdi) {
struct dev_context *const devc = sdi->priv;
struct demo_context *const devc = sdi->priv;
*status = devc->mstatus;
return SR_OK;
} else {

View File

@@ -0,0 +1,360 @@
/*
* This file is part of the libsigrok project.
*
* Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
* Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBDSL_HARDWARE_DEMO_H
#define LIBDSL_HARDWARE_DEMO_H
#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include <assert.h>
#include <sys/stat.h>
#include <inttypes.h>
#include <unistd.h>
#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#endif
#undef min
#define min(a,b) ((a)<(b)?(a):(b))
#undef max
#define max(a,b) ((a)>(b)?(a):(b))
/* Message logging helpers with subsystem-specific prefix string. */
#define LOG_PREFIX "demo: "
#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
/* hardware Capabilities */
#define CAPS_MODE_LOGIC (1 << 0)
#define CAPS_MODE_ANALOG (1 << 1)
#define CAPS_MODE_DSO (1 << 2)
#define CAPS_FEATURE_NONE 0
// zero calibration ability
#define CAPS_FEATURE_ZERO (1 << 4)
/* end */
static struct sr_dev_mode mode_list[] = {
{"LA", LOGIC},
{"DAQ", ANALOG},
{"OSC", DSO},
};
/* Supported patterns which we can generate */
enum DEMO_PATTERN {
PATTERN_SINE = 0,
PATTERN_SQUARE = 1,
PATTERN_TRIANGLE = 2,
PATTERN_SAWTOOTH = 3,
PATTERN_RANDOM = 4,
};
static const char *pattern_strings[] = {
"Sine",
"Square",
"Triangle",
"Sawtooth",
"Random",
};
struct DEMO_caps {
uint64_t mode_caps;
uint64_t feature_caps;
uint64_t channels;
uint64_t hw_depth;
uint64_t dso_depth;
uint8_t intest_channel;
const uint64_t *vdivs;
uint8_t vga_id;
uint16_t default_channelmode;
enum DEMO_PATTERN default_pattern;
uint64_t default_timebase;
};
struct DEMO_profile {
const char *vendor;
const char *model;
const char *model_version;
struct DEMO_caps dev_caps;
};
static const uint64_t vdivs10to2000[] = {
SR_mV(10),
SR_mV(20),
SR_mV(50),
SR_mV(100),
SR_mV(200),
SR_mV(500),
SR_V(1),
SR_V(2),
0,
};
enum CHANNEL_ID {
DEMO_LOGIC100x16 = 0,
DEMO_ANALOG10x2,
DEMO_DSO200x2,
};
struct DEMO_channels {
enum CHANNEL_ID id;
enum OPERATION_MODE mode;
enum CHANNEL_TYPE type;
uint16_t num;
uint8_t unit_bits;
uint64_t default_samplerate;
uint64_t default_samplelimit;
uint64_t min_samplerate;
uint64_t max_samplerate;
const char *descr;
};
static const struct DEMO_channels channel_modes[] = {
// LA Stream
{DEMO_LOGIC100x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1),
SR_KHZ(10), SR_MHZ(100), "Use 16 Channels (Max 20MHz)"},
// DAQ
{DEMO_ANALOG10x2, ANALOG, SR_CHANNEL_ANALOG, 2, 8, SR_MHZ(1), SR_Mn(1),
SR_HZ(10), SR_MHZ(10), "Use Channels 0~1 (Max 10MHz)"},
// OSC
{DEMO_DSO200x2, DSO, SR_CHANNEL_DSO, 2, 8, SR_MHZ(100), SR_Kn(10),
SR_HZ(100), SR_MHZ(200), "Use Channels 0~1 (Max 200MHz)"}
};
static const struct DEMO_profile supported_Demo[] = {
/*
* Demo
*/
{"DreamSourceLab", "Demo Device", NULL,
{CAPS_MODE_LOGIC | CAPS_MODE_ANALOG | CAPS_MODE_DSO,
CAPS_FEATURE_NONE,
(1 << DEMO_LOGIC100x16) |
(1 << DEMO_ANALOG10x2) |
(1 << DEMO_DSO200x2),
SR_Mn(100),
SR_Kn(20),
0,
vdivs10to2000,
0,
DEMO_LOGIC100x16,
PATTERN_SINE,
SR_NS(500)}
},
{ 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
};
struct demo_context {
const struct DEMO_profile *profile;
int pipe_fds[2];
GIOChannel *channel;
uint64_t cur_samplerate;
uint64_t limit_samples;
uint64_t limit_samples_show;
uint64_t limit_msec;
uint8_t sample_generator;
uint64_t samples_counter;
void *cb_data;
int64_t starttime;
int stop;
uint64_t timebase;
enum CHANNEL_ID ch_mode;
uint16_t samplerates_min_index;
uint16_t samplerates_max_index;
gboolean instant;
uint8_t max_height;
uint64_t samples_not_sent;
uint16_t *buf;
uint64_t pre_index;
struct sr_status mstatus;
int trigger_stage;
uint16_t trigger_mask;
uint16_t trigger_value;
uint16_t trigger_edge;
uint8_t trigger_slope;
uint8_t trigger_source;
};
static const uint64_t samplerates[] = {
SR_HZ(10),
SR_HZ(20),
SR_HZ(50),
SR_HZ(100),
SR_HZ(200),
SR_HZ(500),
SR_KHZ(1),
SR_KHZ(2),
SR_KHZ(5),
SR_KHZ(10),
SR_KHZ(20),
SR_KHZ(40),
SR_KHZ(50),
SR_KHZ(100),
SR_KHZ(200),
SR_KHZ(400),
SR_KHZ(500),
SR_MHZ(1),
SR_MHZ(2),
SR_MHZ(4),
SR_MHZ(5),
SR_MHZ(10),
SR_MHZ(20),
SR_MHZ(25),
SR_MHZ(40),
SR_MHZ(50),
SR_MHZ(100),
SR_MHZ(200),
SR_MHZ(400),
SR_MHZ(500),
SR_MHZ(800),
SR_GHZ(1),
SR_GHZ(2),
SR_GHZ(5),
SR_GHZ(10),
};
static const char *probeMapUnits[] = {
"V",
"A",
"°C",
"°F",
"g",
"m",
"m/s",
};
/* We name the probes 0-7 on our demo driver. */
static const char *probe_names[] = {
"0", "1", "2", "3",
"4", "5", "6", "7",
"8", "9", "10", "11",
"12", "13", "14", "15",
NULL,
};
static const gboolean default_ms_en[] = {
FALSE, /* DSO_MS_BEGIN */
TRUE, /* DSO_MS_FREQ */
FALSE, /* DSO_MS_PERD */
TRUE, /* DSO_MS_VMAX */
TRUE, /* DSO_MS_VMIN */
FALSE, /* DSO_MS_VRMS */
FALSE, /* DSO_MS_VMEA */
FALSE, /* DSO_MS_VP2P */
};
static const char *maxHeights[] = {
"1X",
"2X",
"3X",
"4X",
"5X",
};
static const int const_dc = 1.95 / 10 * 255;
static const int sinx[] = {
0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 18, 20, 21, 23, 24, 26, 27, 28,
30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, 47,
48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 49, 49, 49, 48, 48,
47, 47, 46, 46, 45, 44, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30,
29, 28, 26, 25, 24, 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 2, 1,
-1, -2, -4, -6, -7, -9, -10, -12, -13, -15, -16, -18, -19, -21, -22, -24, -25, -26, -28, -29,
-30, -31, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -44, -45, -46, -46, -47, -47,
-48, -48, -49, -49, -49, -50, -50, -50, -50, -50, -50, -50, -50, -50, -49, -49, -49, -49, -48, -48,
-47, -47, -46, -45, -45, -44, -43, -42, -41, -41, -40, -39, -38, -37, -35, -34, -33, -32, -31, -30,
-28, -27, -26, -24, -23, -21, -20, -18, -17, -16, -14, -12, -11, -9, -8, -6, -5, -3, -2, 0,
};
static const int sqrx[] = {
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
};
static const int trix[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41,
40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21,
20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19,
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39,
-40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41,
-40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21,
-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
};
static const int sawx[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19,
20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29,
30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39,
40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 50,
-50, -49, -48, -48, -47, -47, -46, -46, -45, -45, -44, -44, -43, -43, -42, -42, -41, -41, -40, -40,
-39, -39, -38, -38, -37, -37, -36, -36, -35, -35, -34, -34, -33, -33, -32, -32, -31, -31, -30, -30,
-29, -29, -28, -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22, -22, -21, -21, -20, -20,
-19, -19, -18, -18, -17, -17, -16, -16, -15, -15, -14, -14, -13, -13, -12, -12, -11, -11, -10, -10,
-9, -9, -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0,
};
static const int ranx[] = {
-4, 47, -49, -1, -3, 6, -29, 26, 1, 14, -39, -38, 36, 17, 26, -37, -2, 27, -20, -15,
-49, -46, 36, 16, 29, 23, -30, -3, 28, -2, -6, 46, 43, 50, -42, 30, 48, -50, -38, -30,
7, -36, -20, -24, -10, -34, -24, 3, -48, 46, -11, 22, 19, 28, 39, -49, -31, 34, 2, -29,
9, 35, 8, 10, 38, 30, 17, 48, -3, -6, -28, 46, -19, 18, -43, -9, -31, -32, -41, 16,
-10, 46, -4, 4, -32, -43, -45, -39, -33, 28, 24, -17, -43, 42, -7, 36, -44, -5, 9, 39,
17, -40, 12, 16, -42, -1, 2, -9, 50, -8, 27, 27, 14, 8, -18, 12, -8, 26, -8, 12,
-35, 49, 35, 2, -26, -24, -31, 33, 15, -47, 34, 46, -1, -12, 14, 32, -25, -31, -35, -18,
-48, -21, -5, 1, -27, -14, 12, 49, -11, 33, 31, 35, -36, 19, 20, 44, 29, -48, 14, -43,
1, 30, -12, 44, 20, 49, 29, -43, 42, 30, -34, 24, 20, -40, 33, -12, 13, -45, 45, -24,
-41, 36, -8, 46, 47, -34, 28, -39, 7, -32, 38, -27, 28, -3, -8, 43, -37, -24, 6, 3,
};
#endif

View File

@@ -68,8 +68,6 @@ static struct sr_config_info sr_config_info_data[] = {
"Pre-trigger capture ratio", "Pre-trigger capture ratio", NULL},
{SR_CONF_PATTERN_MODE, SR_T_CHAR, "pattern",
"Pattern mode", "Pattern mode", NULL},
{SR_CONF_TRIGGER_TYPE, SR_T_CHAR, "triggertype",
"Trigger types", "Trigger types", NULL},
{SR_CONF_RLE, SR_T_BOOL, "rle",
"Run Length Encoding", "Run Length Encoding", NULL},
{SR_CONF_WAIT_UPLOAD, SR_T_BOOL, "buf_upload",

View File

@@ -124,6 +124,10 @@ enum {
#define DS_CONF_DSO_VDIVS 10
#define DS_MAX_TRIG_PERCENT 90
/*
* Oscilloscope
*/
#define MAX_TIMEBASE SR_SEC(10)
extern char DS_RES_PATH[256];
@@ -353,10 +357,6 @@ struct sr_datafeed_logic {
void *data;
};
struct sr_datafeed_trigger {
};
struct sr_datafeed_dso {
/** The probes for which data is included in this packet. */
GSList *probes;
@@ -593,7 +593,7 @@ struct sr_output_module {
};
enum {
enum CHANNEL_TYPE {
SR_CHANNEL_LOGIC = 10000,
SR_CHANNEL_DSO,
SR_CHANNEL_ANALOG,
@@ -602,7 +602,7 @@ enum {
SR_CHANNEL_FFT,
};
enum {
enum OPERATION_MODE {
LOGIC = 0,
DSO = 1,
ANALOG = 2,
@@ -628,6 +628,7 @@ struct sr_channel {
const char *map_unit;
double map_min;
double map_max;
struct DSL_vga *vga_ptr;
};
/** Structure for groups of channels that have common properties. */
@@ -681,7 +682,7 @@ struct sr_status {
uint64_t ch1_period;
uint32_t ch1_pcnt;
int vlen;
uint32_t vlen;
gboolean stream_mode;
uint32_t sample_divider;
gboolean sample_divider_tog;
@@ -796,6 +797,7 @@ enum {
SR_CONF_BUFFERSIZE,
/** Time base. */
SR_CONF_MAX_TIMEBASE,
SR_CONF_TIMEBASE,
/** Filter. */
@@ -811,11 +813,10 @@ enum {
SR_CONF_VLD_CH_NUM,
/** Zero */
SR_CONF_HAVE_ZERO,
SR_CONF_ZERO,
SR_CONF_ZERO_SET,
SR_CONF_ZERO_LOAD,
SR_CONF_COMB_SET,
SR_CONF_ZERO,
SR_CONF_ZERO_OVER,
SR_CONF_VOCM,
SR_CONF_CALI,
@@ -835,21 +836,6 @@ enum {
SR_CONF_TEST,
SR_CONF_EEPROM,
/** Data lock */
SR_CONF_DATALOCK,
/** Trigger types. */
SR_CONF_TRIGGER_TYPE,
/** The device supports setting its sample interval, in ms. */
SR_CONF_SAMPLE_INTERVAL,
@@ -929,12 +915,8 @@ enum {
/*--- Special stuff -------------------------------------------------*/
/** Scan options supported by the driver. */
SR_CONF_SCAN_OPTIONS = 40000,
/** Device options for a particular device. */
SR_CONF_DEVICE_OPTIONS,
SR_CONF_DEVICE_CONFIGS,
/** Sessions */
SR_CONF_DEVICE_SESSIONS,
@@ -1112,7 +1094,7 @@ struct sr_dev_driver {
int (*cleanup) (void);
GSList *(*scan) (GSList *options);
GSList *(*dev_list) (void);
GSList *(*dev_mode_list) (const struct sr_dev_inst *sdi);
const GSList *(*dev_mode_list) (const struct sr_dev_inst *sdi);
int (*dev_clear) (void);
int (*config_get) (int id, GVariant **data,

View File

@@ -38,8 +38,8 @@
*/
/* Currently selected libsigrok loglevel. Default: SR_LOG_WARN. */
//static int sr_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
static int sr_loglevel = SR_LOG_SPEW;
static int sr_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
//static int sr_loglevel = SR_LOG_SPEW;
/* Function prototype. */
static int sr_logv(void *cb_data, int loglevel, const char *format,

View File

@@ -51,9 +51,8 @@ SR_API int sr_dev_probe_enable(const struct sr_dev_inst *sdi, int probenum,
gboolean state);
SR_API int sr_dev_trigger_set(const struct sr_dev_inst *sdi, uint16_t probenum,
const char *trigger);
SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key);
SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver);
SR_API GSList *sr_dev_mode_list(const struct sr_dev_inst *sdi);
SR_API const GSList *sr_dev_mode_list(const struct sr_dev_inst *sdi);
SR_API int sr_dev_clear(const struct sr_dev_driver *driver);
SR_API int sr_dev_open(struct sr_dev_inst *sdi);
SR_API int sr_dev_close(struct sr_dev_inst *sdi);
@@ -135,8 +134,6 @@ SR_API char *sr_samplecount_string(uint64_t samplecount);
SR_API char *sr_period_string(uint64_t frequency);
SR_API char *sr_time_string(uint64_t time);
SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q);
SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
const char *triggerstring);
SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size);
SR_API uint64_t sr_parse_timestring(const char *timestring);
SR_API gboolean sr_parse_boolstring(const char *boolstring);

View File

@@ -416,8 +416,8 @@ SR_API int sr_session_run(void)
}
} else {
/* Real sources, use g_poll() main loop. */
while (session->num_sources)
sr_session_iteration(TRUE);
while (session->num_sources)
sr_session_iteration(TRUE);
}
g_mutex_lock(&session->stop_mutex);

View File

@@ -53,6 +53,16 @@ static const char *maxHeights[] = {
"4X",
"5X",
};
static const uint64_t vdivs[] = {
SR_mV(10),
SR_mV(20),
SR_mV(50),
SR_mV(100),
SR_mV(200),
SR_mV(500),
SR_V(1),
SR_V(2),
};
struct session_vdev {
int version;
@@ -80,9 +90,6 @@ struct session_vdev {
};
static GSList *dev_insts = NULL;
static const int hwcaps[] = {
SR_CONF_CAPTUREFILE,
};
static const int hwoptions[] = {
SR_CONF_MAX_HEIGHT,
@@ -97,8 +104,8 @@ static const int32_t probeOptions[] = {
static const char *probeMapUnits[] = {
"V",
"A",
"°C",
"°F",
"",
"",
"g",
"m",
"m/s",
@@ -376,6 +383,11 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
} else
return SR_ERR;
break;
case SR_CONF_MAX_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(MAX_TIMEBASE);
break;
case SR_CONF_UNIT_BITS:
if (sdi) {
vdev = sdi->priv;
@@ -628,13 +640,7 @@ static int config_list(int key, GVariant **data,
(void)sdi;
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
hwcaps, ARRAY_SIZE(hwcaps)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_DEVICE_CONFIGS:
case SR_CONF_DEVICE_OPTIONS:
// *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
// hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
@@ -664,6 +670,13 @@ static int config_list(int key, GVariant **data,
*data = g_variant_new_from_data(G_VARIANT_TYPE("ai"),
probeOptions, ARRAY_SIZE(probeOptions)*sizeof(int32_t), TRUE, NULL, NULL);
break;
case SR_CONF_PROBE_VDIV:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_from_data(G_VARIANT_TYPE("at"),
vdivs, ARRAY_SIZE(vdivs)*sizeof(uint64_t), TRUE, NULL, NULL);
g_variant_builder_add(&gvb, "{sv}", "vdivs", gvar);
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_PROBE_MAP_UNIT:
*data = g_variant_new_strv(probeMapUnits, ARRAY_SIZE(probeMapUnits));
break;

View File

@@ -299,99 +299,6 @@ SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q)
return o;
}
/**
* Parse a trigger specification string.
*
* @param sdi The device instance for which the trigger specification is
* intended. Must not be NULL. Also, sdi->driver and
* sdi->driver->info_get must not be NULL.
* @param triggerstring The string containing the trigger specification for
* one or more probes of this device. Entries for multiple probes are
* comma-separated. Triggers are specified in the form key=value,
* where the key is a probe number (or probe name) and the value is
* the requested trigger type. Valid trigger types currently
* include 'r' (rising edge), 'f' (falling edge), 'c' (any pin value
* change), '0' (low value), or '1' (high value).
* Example: "1=r,sck=f,miso=0,7=c"
*
* @return Pointer to a list of trigger types (strings), or NULL upon errors.
* The pointer list (if non-NULL) has as many entries as the
* respective device has probes (all physically available probes,
* not just enabled ones). Entries of the list which don't have
* a trigger value set in 'triggerstring' are NULL, the other entries
* contain the respective trigger type which is requested for the
* respective probe (e.g. "r", "c", and so on).
*/
SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
const char *triggerstring)
{
GSList *l;
GVariant *gvar;
struct sr_channel *probe;
int max_probes, probenum, i;
char **tokens, **triggerlist, *trigger, *tc;
const char *trigger_types;
gboolean error;
max_probes = g_slist_length(sdi->channels);
error = FALSE;
if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) {
sr_err("%s: triggerlist malloc failed", __func__);
return NULL;
}
if (sdi->driver->config_list(SR_CONF_TRIGGER_TYPE, &gvar, sdi, NULL) != SR_OK) {
sr_err("%s: Device doesn't support any triggers.", __func__);
return NULL;
}
trigger_types = g_variant_get_string(gvar, NULL);
tokens = g_strsplit(triggerstring, ",", max_probes);
for (i = 0; tokens[i]; i++) {
probenum = -1;
for (l = sdi->channels; l; l = l->next) {
probe = (struct sr_channel *)l->data;
if (probe->enabled
&& !strncmp(probe->name, tokens[i],
strlen(probe->name))) {
probenum = probe->index;
break;
}
}
if (probenum < 0 || probenum >= max_probes) {
sr_err("Invalid probe.");
error = TRUE;
break;
}
if ((trigger = strchr(tokens[i], '='))) {
for (tc = ++trigger; *tc; tc++) {
if (strchr(trigger_types, *tc) == NULL) {
sr_err("Unsupported trigger "
"type '%c'.", *tc);
error = TRUE;
break;
}
}
if (!error)
triggerlist[probenum] = g_strdup(trigger);
}
}
g_strfreev(tokens);
g_variant_unref(gvar);
if (error) {
for (i = 0; i < max_probes; i++)
g_free(triggerlist[i]);
g_free(triggerlist);
triggerlist = NULL;
}
return triggerlist;
}
/**
* Convert a "natural" string representation of a size value to uint64_t.
*

View File

@@ -250,7 +250,7 @@ class Decoder(srd.Decoder):
if not (self.have_miso or self.have_mosi):
raise ChannelError('Either MISO or MOSI (or both) pins required.')
if (self.mode == 0 or self.mode == 3):
self.exp_oldclk = 0
self.exp_oldclk = 0
self.exp_clk = 1
else:
self.exp_oldclk = 1
@@ -272,7 +272,7 @@ class Decoder(srd.Decoder):
#if not self.no_cs_notification and not self.have_cs:
# self.put(0, 0, self.out_python, ['CS-CHANGE', None, None])
# self.no_cs_notification = True
if (self.oldcs, cs) == (self.asserted_oldcs, self.asserted_cs):
#self.ss_transfer = self.samplenum
#self.misobytes = []
@@ -288,6 +288,6 @@ class Decoder(srd.Decoder):
elif not self.have_cs or cs == self.asserted_cs:
if (self.oldclk, clk) == (self.exp_oldclk, self.exp_clk):
#Sample on rising/falling clock edge
self.handle_bit(miso, mosi, clk, cs)
self.handle_bit(miso, mosi, clk, cs)
self.oldclk, self.oldcs = clk, cs

View File

@@ -281,7 +281,7 @@ class Decoder(srd.Decoder):
(signal,) = pins
if self.options['invert'] == 'yes':
signal = not signal
signal = not signal
# State machine.
if self.state == 'FIND START':

View File

@@ -179,7 +179,7 @@ class Decoder(srd.Decoder):
self.bits[1][2] = self.samplenum
if self.bitcount == 7:
self.bitwidth = self.bits[1][2] - self.bits[2][2]
self.bits[0][2] += self.bitwidth
self.bits[0][2] += self.bitwidth
# Return if we haven't collected all 8 + 1 bits, yet.
if self.bitcount < 7:
@@ -233,7 +233,7 @@ class Decoder(srd.Decoder):
self.bits[1][2] = self.samplenum
if self.bitcount == 7:
self.bitwidth = self.bits[1][2] - self.bits[2][2]
self.bits[0][2] += self.bitwidth
self.bits[0][2] += self.bitwidth
# Return if we haven't collected all 8 + 1 bits, yet.
if self.bitcount < 7:

View File

@@ -252,7 +252,7 @@ class Decoder(srd.Decoder):
if not (self.have_miso or self.have_mosi):
raise ChannelError('Either MISO or MOSI (or both) pins required.')
if (self.mode == 0 or self.mode == 3):
self.exp_oldclk = 0
self.exp_oldclk = 0
self.exp_clk = 1
else:
self.exp_oldclk = 1
@@ -273,7 +273,7 @@ class Decoder(srd.Decoder):
if not self.no_cs_notification and not self.have_cs:
self.put(0, 0, self.out_python, ['CS-CHANGE', None, None])
self.no_cs_notification = True
if (self.oldcs, cs) == (self.asserted_oldcs, self.asserted_cs):
self.ss_transfer = self.samplenum
self.misobytes = []
@@ -289,6 +289,6 @@ class Decoder(srd.Decoder):
elif not self.have_cs or cs == self.asserted_cs:
if (self.oldclk, clk) == (self.exp_oldclk, self.exp_clk):
#Sample on rising/falling clock edge
self.handle_bit(miso, mosi, clk, cs)
self.handle_bit(miso, mosi, clk, cs)
self.oldclk, self.oldcs = clk, cs

View File

@@ -281,7 +281,7 @@ class Decoder(srd.Decoder):
(signal,) = pins
if self.options['invert'] == 'yes':
signal = not signal
signal = not signal
# State machine.
if self.state == 'FIND START':

View File

@@ -47,7 +47,7 @@ class Decoder(srd.Decoder):
self.syncbuf = []
self.prevsample = 0
self.stream = 0
self.ss_stream = None
self.stream_ss = None
self.bytenum = 0
def start(self):
@@ -57,10 +57,10 @@ class Decoder(srd.Decoder):
def stream_changed(self, ss, stream):
if self.stream != stream:
if self.stream != 0:
self.put(self.ss_stream, ss, self.out_ann,
self.put(self.stream_ss, ss, self.out_ann,
[0, ['Stream %d' % self.stream, 'S%d' % self.stream]])
self.stream = stream
self.ss_stream = ss
self.stream_ss = ss
def emit_byte(self, ss, es, byte):
if self.stream == self.options['stream']:

View File

@@ -1,20 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2016 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##

View File

@@ -1,20 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2016 Bert Vermeulen <bert@biot.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
from .mod import *

View File

@@ -1,192 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2016 Bert Vermeulen <bert@biot.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
# This module contains definitions for use by pluggable network adapters,
# such as SFP, XFP etc.
MODULE_ID = {
0x01: 'GBIC',
0x02: 'Integrated module/connector',
0x03: 'SFP',
0x04: '300-pin XBI',
0x05: 'XENPAK',
0x06: 'XFP',
0x07: 'XFF',
0x08: 'XFP-E',
0x09: 'XPAK',
0x0a: 'X2',
}
ALARM_THRESHOLDS = {
0: 'Temp high alarm',
2: 'Temp low alarm',
4: 'Temp high warning',
6: 'Temp low warning',
16: 'Bias high alarm',
18: 'Bias low alarm',
20: 'Bias high warning',
22: 'Bias low warning',
24: 'TX power high alarm',
26: 'TX power low alarm',
28: 'TX power high warning',
30: 'TX power low warning',
32: 'RX power high alarm',
34: 'RX power low alarm',
36: 'RX power high warning',
38: 'RX power low warning',
40: 'AUX 1 high alarm',
42: 'AUX 1 low alarm',
44: 'AUX 1 high warning',
46: 'AUX 1 low warning',
48: 'AUX 2 high alarm',
50: 'AUX 2 low alarm',
52: 'AUX 2 high warning',
54: 'AUX 2 low warning',
}
AD_READOUTS = {
0: 'Module temperature',
4: 'TX bias current',
6: 'Measured TX output power',
8: 'Measured RX input power',
10: 'AUX 1 measurement',
12: 'AUX 2 measurement',
}
GCS_BITS = [
'TX disable',
'Soft TX disable',
'MOD_NR',
'P_Down',
'Soft P_Down',
'Interrupt',
'RX_LOS',
'Data_Not_Ready',
'TX_NR',
'TX_Fault',
'TX_CDR not locked',
'RX_NR',
'RX_CDR not locked',
]
CONNECTOR = {
0x01: 'SC',
0x02: 'Fibre Channel style 1 copper',
0x03: 'Fibre Channel style 2 copper',
0x04: 'BNC/TNC',
0x05: 'Fibre Channel coax',
0x06: 'FiberJack',
0x07: 'LC',
0x08: 'MT-RJ',
0x09: 'MU',
0x0a: 'SG',
0x0b: 'Optical pigtail',
0x20: 'HSSDC II',
0x21: 'Copper pigtail',
}
TRANSCEIVER = [
# 10GB Ethernet
['10GBASE-SR', '10GBASE-LR', '10GBASE-ER', '10GBASE-LRM', '10GBASE-SW',
'10GBASE-LW', '10GBASE-EW'],
# 10GB Fibre Channel
['1200-MX-SN-I', '1200-SM-LL-L', 'Extended Reach 1550 nm',
'Intermediate reach 1300 nm FP'],
# 10GB Copper
[],
# 10GB low speed
['1000BASE-SX / 1xFC MMF', '1000BASE-LX / 1xFC SMF', '2xFC MMF',
'2xFC SMF', 'OC48-SR', 'OC48-IR', 'OC48-LR'],
# 10GB SONET/SDH interconnect
['I-64.1r', 'I-64.1', 'I-64.2r', 'I-64.2', 'I-64.3', 'I-64.5'],
# 10GB SONET/SDH short haul
['S-64.1', 'S-64.2a', 'S-64.2b', 'S-64.3a', 'S-64.3b', 'S-64.5a', 'S-64.5b'],
# 10GB SONET/SDH long haul
['L-64.1', 'L-64.2a', 'L-64.2b', 'L-64.2c', 'L-64.3', 'G.959.1 P1L1-2D2'],
# 10GB SONET/SDH very long haul
['V-64.2a', 'V-64.2b', 'V-64.3'],
]
SERIAL_ENCODING = [
'64B/66B',
'8B/10B',
'SONET scrambled',
'NRZ',
'RZ',
]
XMIT_TECH = [
'850 nm VCSEL',
'1310 nm VCSEL',
'1550 nm VCSEL',
'1310 nm FP',
'1310 nm DFB',
'1550 nm DFB',
'1310 nm EML'
'1550 nm EML'
'copper',
]
CDR = [
'9.95Gb/s',
'10.3Gb/s',
'10.5Gb/s',
'10.7Gb/s',
'11.1Gb/s',
'(unknown)',
'lineside loopback mode',
'XFI loopback mode',
]
DEVICE_TECH = [
['no wavelength control', 'sctive wavelength control'],
['uncooled transmitter device', 'cooled transmitter'],
['PIN detector', 'APD detector'],
['transmitter not tunable', 'transmitter tunable'],
]
ENHANCED_OPTS = [
'VPS',
'soft TX_DISABLE',
'soft P_Down',
'VPS LV regulator mode',
'VPS bypassed regulator mode',
'active FEC control',
'wavelength tunability',
'CMU',
]
AUX_TYPES = [
'not implemented',
'APD bias voltage',
'(unknown)',
'TEC current',
'laser temperature',
'laser wavelength',
'5V supply voltage',
'3.3V supply voltage',
'1.8V supply voltage',
'-5.2V supply voltage',
'5V supply current',
'(unknown)',
'(unknown)',
'3.3V supply current',
'1.8V supply current',
'-5.2V supply current',
]

View File

@@ -1,21 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
from .mod import *

View File

@@ -1,186 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
# Normal commands (CMD)
# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't
# seem to be mentioned in the spec, but aren't marked as reserved either.
cmd_names = {
0: 'GO_IDLE_STATE',
1: 'SEND_OP_COND', # Reserved in SD mode
2: 'ALL_SEND_CID',
3: 'SEND_RELATIVE_ADDR',
4: 'SET_DSR',
5: 'IO_SEND_OP_COND', # SDIO-only
6: 'SWITCH_FUNC', # New since spec 1.10
7: 'SELECT/DESELECT_CARD',
8: 'SEND_IF_COND',
9: 'SEND_CSD',
10: 'SEND_CID',
11: 'VOLTAGE_SWITCH',
12: 'STOP_TRANSMISSION',
13: 'SEND_STATUS',
# 14: Reserved
15: 'GO_INACTIVE_STATE',
16: 'SET_BLOCKLEN',
17: 'READ_SINGLE_BLOCK',
18: 'READ_MULTIPLE_BLOCK',
19: 'SEND_TUNING_BLOCK',
20: 'SPEED_CLASS_CONTROL',
# 21-22: Reserved
23: 'SET_BLOCK_COUNT',
24: 'WRITE_BLOCK',
25: 'WRITE_MULTIPLE_BLOCK',
26: 'Reserved for manufacturer',
27: 'PROGRAM_CSD',
28: 'SET_WRITE_PROT',
29: 'CLR_WRITE_PROT',
30: 'SEND_WRITE_PROT',
# 31: Reserved
32: 'ERASE_WR_BLK_START', # SPI mode: ERASE_WR_BLK_START_ADDR
33: 'ERASE_WR_BLK_END', # SPI mode: ERASE_WR_BLK_END_ADDR
34: 'Reserved for CMD6', # New since spec 1.10
35: 'Reserved for CMD6', # New since spec 1.10
36: 'Reserved for CMD6', # New since spec 1.10
37: 'Reserved for CMD6', # New since spec 1.10
38: 'ERASE',
# 39: Reserved
40: 'Reserved for security specification',
# 41: Reserved
42: 'LOCK_UNLOCK',
# 43-49: Reserved
50: 'Reserved for CMD6', # New since spec 1.10
# 51: Reserved
52: 'IO_RW_DIRECT', # SDIO-only
53: 'IO_RW_EXTENDED', # SDIO-only
54: 'Unknown',
55: 'APP_CMD',
56: 'GEN_CMD',
57: 'Reserved for CMD6', # New since spec 1.10
58: 'READ_OCR', # Reserved in SD mode
59: 'CRC_ON_OFF', # Reserved in SD mode
60: 'Reserved for manufacturer',
61: 'Reserved for manufacturer',
62: 'Reserved for manufacturer',
63: 'Reserved for manufacturer',
}
# Application-specific commands (ACMD)
# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't
# seem to be mentioned in the spec, but aren't marked as reserved either.
acmd_names = {
# 1-5: Reserved
6: 'SET_BUS_WIDTH',
# 7-12: Reserved
13: 'SD_STATUS',
14: 'Reserved for Security Application',
15: 'Reserved for Security Application',
16: 'Reserved for Security Application',
# 17: Reserved
18: 'Reserved for SD security applications',
# 19-21: Reserved
22: 'SEND_NUM_WR_BLOCKS',
23: 'SET_WR_BLK_ERASE_COUNT',
# 24: Reserved
25: 'Reserved for SD security applications',
26: 'Reserved for SD security applications',
27: 'Reserved for security specification',
28: 'Reserved for security specification',
# 29: Reserved
30: 'Reserved for security specification',
31: 'Reserved for security specification',
32: 'Reserved for security specification',
33: 'Reserved for security specification',
34: 'Reserved for security specification',
35: 'Reserved for security specification',
# 36-37: Reserved
38: 'Reserved for SD security applications',
# 39-40: Reserved
41: 'SD_SEND_OP_COND',
42: 'SET_CLR_CARD_DETECT',
43: 'Reserved for SD security applications',
44: 'Reserved for SD security applications',
45: 'Reserved for SD security applications',
46: 'Reserved for SD security applications',
47: 'Reserved for SD security applications',
48: 'Reserved for SD security applications',
49: 'Reserved for SD security applications',
50: 'Unknown',
51: 'SEND_SCR',
52: 'Reserved for security specification',
53: 'Reserved for security specification',
54: 'Reserved for security specification',
55: 'Non-existant', # Doesn't exist (equivalent to CMD55)
56: 'Reserved for security specification',
57: 'Reserved for security specification',
58: 'Reserved for security specification',
59: 'Reserved for security specification',
60: 'Unknown',
61: 'Unknown',
62: 'Unknown',
63: 'Unknown',
}
accepted_voltages = {
0b0001: '2.7-3.6V',
0b0010: 'reserved for low voltage range',
0b0100: 'reserved',
0b1000: 'reserved',
# All other values: "not defined".
}
card_status = {
0: 'Reserved for manufacturer test mode',
1: 'Reserved for manufacturer test mode',
2: 'Reserved for application specific commands',
3: 'AKE_SEQ_ERROR',
4: 'Reserved for SDIO card',
5: 'APP_CMD',
6: 'Unknown',
7: 'Unknown',
8: 'READY_FOR_DATA',
9: 'CURRENT_STATE', # CURRENT_STATE is a 4-bit value (decimal: 0..15).
10: 'CURRENT_STATE',
11: 'CURRENT_STATE',
12: 'CURRENT_STATE',
13: 'ERASE_RESET',
14: 'CARD_ECC_DISABLED',
15: 'WP_ERASE_SKIP',
16: 'CSD_OVERWRITE',
17: 'Reserved for DEFERRED_RESPONSE', # See eSD addendum
18: 'Reserved',
19: 'ERROR',
20: 'CC_ERROR',
21: 'CARD_ECC_FAILED',
22: 'ILLEGAL_COMMAND',
23: 'COM_CRC_ERROR',
24: 'LOCK_UNLOCK_FAILED',
25: 'CARD_IS_LOCKED',
26: 'WP_VIOLATION',
27: 'ERASE_PARAM',
28: 'ERASE_SEQ_ERROR',
29: 'BLOCK_LEN_ERROR',
30: 'ADDRESS_ERROR',
31: 'OUT_OF_RANGE',
}
sd_status = {
# 311:0: Reserved for manufacturer
# 391:312: Reserved
}

View File

@@ -1,21 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
from .mod import *

View File

@@ -1,23 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-2014 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)

View File

@@ -20,7 +20,10 @@
import sigrokdecode as srd
import calendar
from common.srdhelper import bcd2int
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
class SamplerateError(Exception):
pass
@@ -65,7 +68,7 @@ class Decoder(srd.Decoder):
('warnings', 'Warnings', (19,)),
)
def __init__(self):
def __init__(self, **kwargs):
self.samplerate = None
self.state = 'WAIT FOR RISING EDGE'
self.oldpins = None

View File

@@ -14,8 +14,7 @@
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
'''

View File

@@ -14,8 +14,7 @@
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd

View File

@@ -21,7 +21,6 @@
import re
import sigrokdecode as srd
from common.srdhelper import bcd2int
days_of_week = (
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
@@ -52,6 +51,10 @@ def regs_and_bits():
l += [('bit-' + re.sub('\/| ', '-', b).lower(), b + ' bit') for b in bits]
return tuple(l)
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
class Decoder(srd.Decoder):
api_version = 2
id = 'ds1307'
@@ -75,7 +78,7 @@ class Decoder(srd.Decoder):
('warnings', 'Warnings', (28,)),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'IDLE'
self.hours = -1
self.minutes = -1

View File

@@ -73,12 +73,12 @@ class Decoder(srd.Decoder):
('binary', 'Binary'),
)
def __init__(self):
def __init__(self, **kwargs):
self.reset()
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
self.out_binary = self.register(srd.OUTPUT_BINARY)
self.out_bin = self.register(srd.OUTPUT_BINARY)
self.chip = chips[self.options['chip']]
self.addr_counter = self.options['addr_counter']
@@ -86,7 +86,7 @@ class Decoder(srd.Decoder):
self.put(self.ss_block, self.es_block, self.out_ann, data)
def putbin(self, data):
self.put(self.ss_block, self.es_block, self.out_binary, data)
self.put(self.ss_block, self.es_block, self.out_bin, data)
def putbits(self, bit1, bit2, bits, data):
self.put(bits[bit1][1], bits[bit2][2], self.out_ann, data)
@@ -165,7 +165,7 @@ class Decoder(srd.Decoder):
self.putb([cls, ['%s (%s): %s' % (s, self.addr_and_len(), \
self.hexbytes(self.chip['addr_bytes'])),
'%s (%s)' % (s, self.addr_and_len()), s, a, s[0]]])
self.putbin([0, bytes(self.bytebuf[self.chip['addr_bytes']:])])
self.putbin((0, bytes(self.bytebuf[self.chip['addr_bytes']:])))
def addr_and_len(self):
if self.chip['addr_bytes'] == 1:
@@ -215,7 +215,7 @@ class Decoder(srd.Decoder):
[8, ['Data', 'D']])
self.putb([11, ['Current address read: %02X' % self.bytebuf[0],
'Current address read', 'Cur addr read', 'CAR', 'C']])
self.putbin([0, bytes([self.bytebuf[0]])])
self.putbin((0, bytes([self.bytebuf[0]])))
self.addr_counter += 1
elif self.is_random_access_read:
# Random access read: word address, one data byte.

View File

@@ -74,12 +74,12 @@ class Decoder(srd.Decoder):
self.oldpl = 0
self.oldsamplenum = 0
self.last_bit_pos = 0
self.ss_first = 0
self.first_ss = 0
self.first_one = 0
self.state = 'HEADER'
self.data = 0
self.data_bits = 0
self.ss_data = 0
self.data_ss = 0
self.data_parity = 0
self.payload_cnt = 0
self.data_col_parity = [0, 0, 0, 0, 0, 0]
@@ -105,14 +105,14 @@ class Decoder(srd.Decoder):
if self.first_one > 0:
self.first_one += 1
if self.first_one == 9:
self.put(self.ss_first, es, self.out_ann,
self.put(self.first_ss, es, self.out_ann,
[1, ['Header', 'Head', 'He', 'H']])
self.first_one = 0
self.state = 'PAYLOAD'
return
if self.first_one == 0:
self.first_one = 1
self.ss_first = ss
self.first_ss = ss
if bit == 0:
self.first_one = 0
@@ -121,14 +121,14 @@ class Decoder(srd.Decoder):
if self.state == 'PAYLOAD':
self.payload_cnt += 1
if self.data_bits == 0:
self.ss_data = ss
self.data_ss = ss
self.data = 0
self.data_parity = 0
self.data_bits += 1
if self.data_bits == 5:
s = 'Version/customer' if self.payload_cnt <= 10 else 'Data'
c = 2 if self.payload_cnt <= 10 else 3
self.put(self.ss_data, ss, self.out_ann,
self.put(self.data_ss, ss, self.out_ann,
[c, [s + ': %X' % self.data, '%X' % self.data]])
s = 'OK' if self.data_parity == bit else 'ERROR'
c = 4 if s == 'OK' else 5
@@ -150,7 +150,7 @@ class Decoder(srd.Decoder):
if self.state == 'TRAILER':
self.payload_cnt += 1
if self.data_bits == 0:
self.ss_data = ss
self.data_ss = ss
self.data = 0
self.data_parity = 0
self.data_bits += 1
@@ -172,7 +172,7 @@ class Decoder(srd.Decoder):
# Emit an annotation for valid-looking tags.
all_col_parity_ok = (self.data_col_parity[1:5] == self.col_parity[1:5])
if all_col_parity_ok and self.all_row_parity_ok:
self.put(self.ss_first, es, self.out_ann,
self.put(self.first_ss, es, self.out_ann,
[9, ['Tag: %010X' % self.tag, 'Tag', 'T']])
self.tag = 0

View File

@@ -14,8 +14,7 @@
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
'''

View File

@@ -14,8 +14,7 @@
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd

View File

@@ -283,7 +283,18 @@ class Decoder(srd.Decoder):
ptype, data1, data2 = data
if ptype == 'CS-CHANGE':
if ptype == 'TRANSFER':
if self.cmd:
# Check if we got the minimum number of data bytes
# after the command byte.
if len(self.mb) < self.min:
self.warn((ss, ss), 'missing data bytes')
elif self.mb:
self.finish_command((self.mb_s, self.mb_e))
self.next()
self.cs_was_released = True
elif ptype == 'CS-CHANGE':
if data1 is None:
if data2 is None:
self.requirements_met = False
@@ -303,8 +314,8 @@ class Decoder(srd.Decoder):
self.finish_command((self.mb_s, self.mb_e))
self.next()
self.cs_was_released = True
elif ptype == 'DATA' and self.cs_was_released:
self.cs_was_released = True
elif ptype == 'DATA':
mosi, miso = data1, data2
pos = (ss, es)

View File

@@ -182,7 +182,7 @@ class Decoder(srd.Decoder):
self.cnt_overdrive_presence = int(samplerate * x) - 1
x = float(self.options['cnt_overdrive_reset']) / 1000000.0
self.cnt_overdrive_reset = int(samplerate * x) - 1
# Organize values into lists.
self.cnt_bit = [self.cnt_normal_bit, self.cnt_overdrive_bit]
self.cnt_presence = [self.cnt_normal_presence, self.cnt_overdrive_presence]
@@ -286,3 +286,4 @@ class Decoder(srd.Decoder):
# Wait for next slot.
self.state = 'WAIT FOR FALLING EDGE'

View File

@@ -49,7 +49,7 @@ class Decoder(srd.Decoder):
def __init__(self):
self.samplerate = None
self.oldpin = None
self.ss_packet = None
self.packet_ss = None
self.ss = None
self.es = None
self.bits = []
@@ -66,10 +66,10 @@ class Decoder(srd.Decoder):
if len(self.bits) == 24:
grb = reduce(lambda a, b: (a << 1) | b, self.bits)
rgb = (grb & 0xff0000) >> 8 | (grb & 0x00ff00) << 8 | (grb & 0x0000ff)
self.put(self.ss_packet, samplenum, self.out_ann,
self.put(self.packet_ss, samplenum, self.out_ann,
[2, ['#%06x' % rgb]])
self.bits = []
self.ss_packet = None
self.packet_ss = None
def decode(self, ss, es, data):
if not self.samplerate:
@@ -99,7 +99,7 @@ class Decoder(srd.Decoder):
self.inreset = True
self.bits = []
self.ss_packet = None
self.packet_ss = None
self.ss = None
if not self.oldpin and pin:
@@ -116,8 +116,8 @@ class Decoder(srd.Decoder):
self.bits.append(bit_)
self.handle_bits(samplenum)
if self.ss_packet is None:
self.ss_packet = samplenum
if self.packet_ss is None:
self.packet_ss = samplenum
self.ss = samplenum

View File

@@ -19,7 +19,10 @@
##
import sigrokdecode as srd
from common.srdhelper import bcd2int
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
def reg_list():
l = []
@@ -52,7 +55,7 @@ class Decoder(srd.Decoder):
('date-time', 'Date/time', (9, 10)),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'IDLE'
self.hours = -1
self.minutes = -1

View File

@@ -1,5 +1,5 @@
##
## This file is part of the libsigrokdecode project.
## This file is part of the sigrok project.
##
## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
##

View File

@@ -1,5 +1,5 @@
##
## This file is part of the libsigrokdecode project.
## This file is part of the sigrok project.
##
## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
##
@@ -19,7 +19,7 @@
##
import sigrokdecode as srd
from common.sdcard import (cmd_names, acmd_names, accepted_voltages, card_status, sd_status)
from .lists import *
class Decoder(srd.Decoder):
api_version = 2
@@ -61,7 +61,7 @@ class Decoder(srd.Decoder):
('cmd', 'Commands', tuple(range(128))),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'GET COMMAND TOKEN'
self.token = []
self.oldpins = None
@@ -167,7 +167,7 @@ class Decoder(srd.Decoder):
# Handle command.
s = 'ACMD' if self.is_acmd else 'CMD'
self.cmd_str = '%s%d (%s)' % (s, self.cmd, self.cmd_name(self.cmd))
if self.cmd in (0, 2, 3, 4, 6, 7, 8, 9, 10, 13, 41, 51, 55):
if self.cmd in (0, 2, 3, 6, 7, 8, 9, 10, 13, 41, 51, 55):
self.state = 'HANDLE CMD%d' % self.cmd
else:
self.state = 'HANDLE CMD999'

View File

@@ -19,7 +19,57 @@
##
import sigrokdecode as srd
from common.sdcard import (cmd_names, acmd_names)
# Normal commands (CMD)
cmd_names = {
0: 'GO_IDLE_STATE',
1: 'SEND_OP_COND',
6: 'SWITCH_FUNC',
8: 'SEND_IF_COND',
9: 'SEND_CSD',
10: 'SEND_CID',
12: 'STOP_TRANSMISSION',
13: 'SEND_STATUS',
16: 'SET_BLOCKLEN',
17: 'READ_SINGLE_BLOCK',
18: 'READ_MULTIPLE_BLOCK',
24: 'WRITE_BLOCK',
25: 'WRITE_MULTIPLE_BLOCK',
27: 'PROGRAM_CSD',
28: 'SET_WRITE_PROT',
29: 'CLR_WRITE_PROT',
30: 'SEND_WRITE_PROT',
32: 'ERASE_WR_BLK_START_ADDR',
33: 'ERASE_WR_BLK_END_ADDR',
38: 'ERASE',
42: 'LOCK_UNLOCK',
55: 'APP_CMD',
56: 'GEN_CMD',
58: 'READ_OCR',
59: 'CRC_ON_OFF',
# CMD60-63: Reserved for manufacturer
}
# Application-specific commands (ACMD)
acmd_names = {
13: 'SD_STATUS',
18: 'Reserved for SD security applications',
22: 'SEND_NUM_WR_BLOCKS',
23: 'SET_WR_BLK_ERASE_COUNT',
25: 'Reserved for SD security applications',
26: 'Reserved for SD security applications',
38: 'Reserved for SD security applications',
41: 'SD_SEND_OP_COND',
42: 'SET_CLR_CARD_DETECT',
43: 'Reserved for SD security applications',
44: 'Reserved for SD security applications',
45: 'Reserved for SD security applications',
46: 'Reserved for SD security applications',
47: 'Reserved for SD security applications',
48: 'Reserved for SD security applications',
49: 'Reserved for SD security applications',
51: 'SEND_SCR',
}
class Decoder(srd.Decoder):
api_version = 2
@@ -46,7 +96,7 @@ class Decoder(srd.Decoder):
('cmd-reply', 'Commands/replies', tuple(range(134))),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'IDLE'
self.ss, self.es = 0, 0
self.ss_bit, self.es_bit = 0, 0
@@ -72,12 +122,7 @@ class Decoder(srd.Decoder):
def cmd_name(self, cmd):
c = acmd_names if self.is_acmd else cmd_names
s = c.get(cmd, 'Unknown')
# SD mode names for CMD32/33: ERASE_WR_BLK_{START,END}.
# SPI mode names for CMD32/33: ERASE_WR_BLK_{START,END}_ADDR.
if cmd in (32, 33):
s += '_ADDR'
return s
return c.get(cmd, 'Unknown')
def handle_command_token(self, mosi, miso):
# Command tokens (6 bytes) are sent (MSB-first) by the host.

View File

@@ -17,8 +17,7 @@
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
'''

View File

@@ -17,8 +17,7 @@
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd

Some files were not shown because too many files have changed in this diff Show More