Files
templates/tools/dsview/zynq-ethernet/ethernet.patch
T

1544 lines
58 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 575eb85..6102914 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,6 +94,7 @@ include_directories(
#= glib-2.0
#-------------------------------------------------------------------------------
pkg_search_module(GLIB glib-2.0)
+pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
if(NOT GLIB_FOUND)
message(FATAL_ERROR "Please install glib!")
@@ -477,6 +478,8 @@ set(libsigrok4DSL_SOURCES
libsigrok4DSL/output/gnuplot.c
libsigrok4DSL/output/srzip.c
libsigrok4DSL/output/vcd.c
+ libsigrok4DSL/hardware/zynq/zynq.c
+ libsigrok4DSL/hardware/zynq/zynq_record.c
libsigrok4DSL/hardware/DSL/dslogic.c
libsigrok4DSL/hardware/common/usb.c
libsigrok4DSL/hardware/common/ezusb.c
@@ -619,6 +622,7 @@ add_compile_options(-O3)
set(DSVIEW_LINK_LIBS
-lz
-lglib-2.0
+ PkgConfig::GIO
${CMAKE_THREAD_LIBS_INIT}
${QT_LIBRARIES}
${LIBUSB_1_LIBRARIES}
diff --git a/DSView/main.cpp b/DSView/main.cpp
index 58d2d15..869a6c1 100644
--- a/DSView/main.cpp
+++ b/DSView/main.cpp
@@ -38,6 +38,7 @@
#include <QDateTime>
#include <string>
#include <ds_types.h>
+#include <libsigrok.h>
#ifdef _WIN32
#include <windows.h>
@@ -224,7 +225,8 @@ bool bHighScale = true;
AppControl *control = AppControl::Instance();
AppConfig &app = AppConfig::Instance();
app.LoadAll(); //load app config
- if (embedParent) {
+ const bool localZynq = qEnvironmentVariableIsSet("DSVIEW_LOCAL_ZYNQ");
+ if (embedParent || localZynq) {
app.frameOptions.style = "dark";
app.appOptions.fontSize = 10;
QString captureDir = QString::fromUtf8(qgetenv("DSVIEW_CAPTURE_DIR"));
@@ -264,6 +266,15 @@ bool bHighScale = true;
dsv_err("init error!");
return 1;
}
+ if (localZynq) {
+ ds_device_handle analyzer = 0;
+ if (ds_add_zynq_device("127.0.0.1", &analyzer) != SR_OK) {
+ dsv_err("Local Zynq capture service did not answer.");
+ control->UnInit();
+ dsv_log_uninit();
+ return 1;
+ }
+ }
if (open_file != NULL){
control->_open_file_name = open_file;
@@ -287,8 +298,12 @@ bool bHighScale = true;
} else
#endif
{
- w.ShowFormInit();
- w.ShowHelpDocAsync();
+ if (localZynq)
+ w.showMaximized();
+ else {
+ w.ShowFormInit();
+ w.ShowHelpDocAsync();
+ }
}
ret = a.exec(); //Run the application
diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp
index b2226cd..59d5a0c 100644
--- a/DSView/pv/data/logicsnapshot.cpp
+++ b/DSView/pv/data/logicsnapshot.cpp
@@ -64,11 +64,18 @@ LogicSnapshot::LogicSnapshot() :
LogicSnapshot::~LogicSnapshot()
{
+ if (_disk)
+ ds_zynq_disk_close(_disk);
}
void LogicSnapshot::free_data()
{
Snapshot::free_data();
+ if (_disk) {
+ ds_zynq_disk_close(_disk);
+ _disk = nullptr;
+ _disk_cache.clear();
+ }
for(auto& iter : _ch_data) {
for(auto& iter_rn : iter) {
@@ -117,6 +124,92 @@ void LogicSnapshot::clear()
_free_count = 0;
}
+bool LogicSnapshot::load_zynq_recording(const QString &file, bool dense_channels)
+{
+ struct ds_zynq_record_info info;
+ auto path = file.toUtf8();
+ auto *disk = ds_zynq_disk_open(path.constData(), &info);
+ if (!disk)
+ return false;
+ std::lock_guard<std::mutex> lock(_mutex);
+ free_data();
+ init_all();
+ _disk = disk;
+ _is_loop = false;
+ _ch_index.clear();
+ _samplerate = double(info.clock) / info.divider;
+ _total_sample_count = _sample_count = _ring_sample_count = info.samples;
+ const auto *tiles = ds_zynq_disk_tiles(disk);
+ const uint64_t tile_count = (info.samples + DS_ZYNQ_TILE_SAMPLES - 1) / DS_ZYNQ_TILE_SAMPLES;
+ const uint64_t leaves = (info.samples + LeafBlockSamples - 1) / LeafBlockSamples;
+ for (unsigned channel = 0; channel < 8; channel++) {
+ const unsigned mask = 1u << channel;
+ if (!(info.mask & mask))
+ continue;
+ _disk_channels[_ch_index.size()] = channel;
+ _ch_index.push_back(dense_channels ? _ch_index.size() : channel);
+ _ch_data.emplace_back((leaves + RootScale - 1) / RootScale);
+ auto &roots = _ch_data.back();
+ for (uint64_t leaf = 0; leaf < leaves; leaf++) {
+ const uint64_t first_tile = leaf * (LeafBlockSamples / DS_ZYNQ_TILE_SAMPLES);
+ const uint64_t stop_tile = min(tile_count, first_tile + LeafBlockSamples / DS_ZYNQ_TILE_SAMPLES);
+ const bool first = tiles[first_tile].first & mask;
+ bool last = first;
+ bool changes = false;
+ for (uint64_t tile = first_tile; tile < stop_tile; tile++) {
+ changes |= (tiles[tile].changes & mask) || (bool(tiles[tile].first & mask) != last);
+ last = tiles[tile].last & mask;
+ }
+ auto &root = roots[leaf / RootScale];
+ const uint64_t bit = 1ULL << (leaf % RootScale);
+ if (first) root.first |= bit;
+ if (last) root.last |= bit;
+ if (changes) root.tog |= bit;
+ }
+ }
+ _channel_num = _ch_index.size();
+ return true;
+}
+
+std::shared_ptr<uint8_t> LogicSnapshot::disk_leaf(unsigned order, uint64_t root, unsigned pos)
+{
+ if (!(_ch_data[order][root].tog & (1ULL << pos)))
+ return {};
+ const uint64_t leaf = root * RootScale + pos;
+ const uint64_t key = leaf * CHANNEL_MAX_COUNT + order;
+ for (auto i = _disk_cache.begin(); i != _disk_cache.end(); ++i) {
+ if (i->first == key) {
+ _disk_cache.splice(_disk_cache.begin(), _disk_cache, i);
+ return _disk_cache.front().second;
+ }
+ }
+ std::shared_ptr<uint8_t> buffer(static_cast<uint8_t *>(calloc(1, LeafBlockSpace)), free);
+ if (!buffer || ds_zynq_disk_leaf(_disk, leaf, order, buffer.get(), LeafBlockSamples / 8) != SR_OK) {
+ dsv_err("Could not read an RJ2 recording block.");
+ return {};
+ }
+ // Reuse DSView's edge index. The root summary comes from the recording.
+ auto &node = _ch_data[order][root];
+ const auto first = node.first, last = node.last, tog = node.tog;
+ node.lbp[pos] = buffer.get();
+ _last_calc_count[order] = 0;
+ calc_mipmap(order, root, pos, LeafBlockSamples, false);
+ node.lbp[pos] = nullptr;
+ node.first = first;
+ node.last = last;
+ node.tog = tog;
+ _disk_cache.emplace_front(key, buffer);
+ if (_disk_cache.size() > 24)
+ _disk_cache.pop_back();
+ return buffer;
+}
+
+uint8_t *LogicSnapshot::leaf_buffer(unsigned order, uint64_t root, unsigned pos)
+{
+ return _disk ? disk_leaf(order, root, pos).get() :
+ static_cast<uint8_t *>(_ch_data[order][root].lbp[pos]);
+}
+
void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total_sample_count, GSList *channels, bool able_free)
{
bool channel_changed = false;
@@ -139,7 +232,7 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total
}
}
- if (total_sample_count != _total_sample_count
+ if (_disk || total_sample_count != _total_sample_count
|| channel_num != _channel_num
|| channel_changed
|| _is_loop) {
@@ -464,7 +557,9 @@ void LogicSnapshot::capture_ended()
{
std::lock_guard<std::mutex> lock(_mutex);
- Snapshot::capture_ended();
+ Snapshot::capture_ended();
+ if (_disk)
+ return;
_sample_count = _ring_sample_count;
_ring_sample_count += _loop_offset;
@@ -495,7 +590,7 @@ void LogicSnapshot::capture_ended()
}
}
-void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t index1, uint64_t samples, bool isEnd)
+void LogicSnapshot::calc_mipmap(unsigned int order, uint64_t index0, uint8_t index1, uint64_t samples, bool isEnd)
{
void *lbp = _ch_data[order][index0].lbp[index1];
void *level1_ptr = (uint8_t*)lbp + LeafBlockSamples / 8;
@@ -610,6 +705,8 @@ const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_s
uint64_t logic_sample_index = start_sample + _loop_offset;
int order = get_ch_order(sig_index);
+ if (order == -1)
+ return NULL;
// uint64_t index0 = logic_sample_index >> (LeafBlockPower + RootScalePower);
// uint64_t index1 = (logic_sample_index & RootMask) >> LeafBlockPower;
// uint64_t offset = (start_sample & LeafMask) / 8;
@@ -618,7 +715,15 @@ const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_s
uint64_t index1 = (logic_sample_index / LeafBlockSamples) % RootScale;
uint64_t offset = (start_sample % LeafBlockSamples) / 8;
- uint8_t *block_buffer = (uint8_t*)_ch_data[order][index0].lbp[index1];
+ uint8_t *block_buffer;
+ if (_disk) {
+ // A decoder uses several channel pointers outside the snapshot lock.
+ static thread_local std::shared_ptr<uint8_t> pinned[CHANNEL_MAX_COUNT];
+ pinned[order] = disk_leaf(order, index0, index1);
+ block_buffer = pinned[order].get();
+ } else {
+ block_buffer = leaf_buffer(order, index0, index1);
+ }
int block_num = get_block_num_unlock();
@@ -658,7 +763,7 @@ const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_s
}
else{
if (lbp != NULL){
- *lbp = _ch_data[order][index0].lbp[index1];
+ *lbp = block_buffer;
}
_cur_ref_block_indexs[order].root_index = index0;
@@ -701,8 +806,9 @@ bool LogicSnapshot::get_sample_self(uint64_t index, int sig_index)
return (_ch_data[order][index0].first & root_pos_mask) != 0;
}
else {
- uint64_t *lbp = (uint64_t*)_ch_data[order][index0].lbp[index1];
- return *(lbp + ((index & LeafMask) >> ScalePower)) & index_mask;
+ const auto *lbp = reinterpret_cast<const uint64_t *>(leaf_buffer(order, index0, index1));
+ return lbp ? lbp[(index & LeafMask) >> ScalePower] & index_mask :
+ (_ch_data[order][index0].first & root_pos_mask) != 0;
}
}
@@ -728,6 +834,9 @@ bool LogicSnapshot::get_display_edges(std::vector<std::pair<bool, bool> > &edges
assert(start <= end);
assert(min_length > 0);
+ if (_disk && min_length >= DS_ZYNQ_TILE_SAMPLES)
+ return disk_display_edges(edges, togs, start, end, width, max_togs, pixels_offset, min_length, sig_index);
+
uint64_t index = start;
bool last_sample;
bool start_sample;
@@ -771,6 +880,37 @@ bool LogicSnapshot::get_display_edges(std::vector<std::pair<bool, bool> > &edges
return start_sample;
}
+bool LogicSnapshot::disk_display_edges(std::vector<std::pair<bool, bool>> &edges,
+ std::vector<std::pair<uint16_t, bool>> &togs, uint64_t start, uint64_t end,
+ uint16_t width, uint16_t max_togs, double pixels_offset, double min_length, uint16_t sig_index)
+{
+ const auto *tiles = ds_zynq_disk_tiles(_disk);
+ const int order = get_ch_order(sig_index);
+ if (order < 0)
+ return false;
+ const unsigned mask = 1u << _disk_channels[order];
+ uint64_t tile = start / DS_ZYNQ_TILE_SAMPLES;
+ const bool first = tiles[tile].first & mask;
+ bool level = first;
+ togs.emplace_back(0, first);
+ for (unsigned pixel = 0; pixel < width; pixel++) {
+ const double pixel_end = (pixels_offset + pixel + 1) * min_length;
+ const uint64_t last_tile = uint64_t(max(double(start), min(double(end), pixel_end))) / DS_ZYNQ_TILE_SAMPLES;
+ bool changes = false;
+ while (tile <= last_tile) {
+ changes |= (tiles[tile].changes & mask) || bool(tiles[tile].first & mask) != level;
+ level = tiles[tile].last & mask;
+ tile++;
+ }
+ edges.emplace_back(changes, level);
+ if (changes && togs.size() < max_togs)
+ togs.emplace_back(pixel, level);
+ }
+ if (width && togs.size() < max_togs)
+ togs.emplace_back(width - 1, level);
+ return first;
+}
+
bool LogicSnapshot::get_nxt_edge(uint64_t &index, bool last_sample, uint64_t end,
double min_length, int sig_index)
{
@@ -829,13 +969,13 @@ bool LogicSnapshot::get_nxt_edge_self(uint64_t &index, bool last_sample, uint64_
}
if (!edge_hit) {
- uint64_t *lbp = (uint64_t*)_ch_data[order][i].lbp[inner_tog_pos];
uint64_t blk_start = (i << (LeafBlockPower + RootScalePower)) + (inner_tog_pos << LeafBlockPower);
index = max(blk_start, index);
if (min_level < ScaleLevel) {
uint64_t block_end = min(index | LeafMask, end);
- edge_hit = block_nxt_edge(lbp, index, block_end, last_sample, min_level);
+ auto *lbp = reinterpret_cast<uint64_t *>(leaf_buffer(order, i, inner_tog_pos));
+ edge_hit = lbp && block_nxt_edge(lbp, index, block_end, last_sample, min_level);
}
else {
edge_hit = true;
@@ -922,12 +1062,12 @@ bool LogicSnapshot::get_pre_edge_self(uint64_t &index, bool last_sample,
}
if (!edge_hit) {
- uint64_t *lbp = (uint64_t*)_ch_data[order][i].lbp[inner_tog_pos];
uint64_t blk_end = ((i << (LeafBlockPower + RootScalePower)) +
(inner_tog_pos << LeafBlockPower)) | LeafMask;
index = min(blk_end, index);
if (min_level < ScaleLevel) {
- edge_hit = block_pre_edge(lbp, index, last_sample, min_level, sig_index);
+ auto *lbp = reinterpret_cast<uint64_t *>(leaf_buffer(order, i, inner_tog_pos));
+ edge_hit = lbp && block_pre_edge(lbp, index, last_sample, min_level, sig_index);
} else {
edge_hit = true;
}
@@ -1431,6 +1571,11 @@ uint64_t LogicSnapshot::get_block_size_unlock(int block_index)
assert(block_index < block_num);
auto align_sample_count = _ring_sample_count;
+ if (_disk) {
+ const uint64_t count = min(LeafBlockSamples,
+ align_sample_count - uint64_t(block_index) * LeafBlockSamples);
+ return (count + Scale - 1) / Scale * ScaleSize;
+ }
if (_loop_offset > 0)
{
@@ -1489,7 +1634,14 @@ uint8_t *LogicSnapshot::get_block_buf_unlock(int block_index, int sig_index, boo
uint64_t index = block_index / RootScale;
uint8_t pos = block_index % RootScale;
- uint8_t *lbp = (uint8_t*)_ch_data[order][index].lbp[pos];
+ uint8_t *lbp;
+ if (_disk) {
+ static thread_local std::shared_ptr<uint8_t> pinned;
+ pinned = disk_leaf(order, index, pos);
+ lbp = pinned.get();
+ } else {
+ lbp = leaf_buffer(order, index, pos);
+ }
if (lbp == NULL){
sample = (_ch_data[order][index].first & 1ULL << pos) != 0;
diff --git a/DSView/pv/data/logicsnapshot.h b/DSView/pv/data/logicsnapshot.h
index acd36dd..7893a3e 100644
--- a/DSView/pv/data/logicsnapshot.h
+++ b/DSView/pv/data/logicsnapshot.h
@@ -30,6 +30,8 @@
#include <utility>
#include <vector>
#include <map>
+#include <list>
+#include <memory>
#define CHANNEL_MAX_COUNT 64
@@ -99,6 +101,8 @@ public:
void clear();
void init();
+ bool load_zynq_recording(const QString &file, bool dense_channels = false);
+ bool is_disk_recording() const { return _disk != nullptr; }
void first_payload(const sr_datafeed_logic &logic, uint64_t total_sample_count, GSList *channels, bool able_free);
@@ -176,7 +180,13 @@ private:
int get_ch_order(int sig_index);
- void calc_mipmap(unsigned int order, uint8_t index0, uint8_t index1, uint64_t samples, bool isEnd);
+ void calc_mipmap(unsigned int order, uint64_t index0, uint8_t index1, uint64_t samples, bool isEnd);
+ std::shared_ptr<uint8_t> disk_leaf(unsigned order, uint64_t root, unsigned pos);
+ uint8_t *leaf_buffer(unsigned order, uint64_t root, unsigned pos);
+ bool disk_display_edges(std::vector<std::pair<bool, bool>> &edges,
+ std::vector<std::pair<uint16_t, bool>> &togs, uint64_t start, uint64_t end,
+ uint16_t width, uint16_t max_togs, double pixels_offset, double min_length,
+ uint16_t sig_index);
void append_cross_payload(const sr_datafeed_logic &logic);
@@ -249,6 +259,9 @@ private:
private:
std::vector<std::vector<struct RootNode>> _ch_data;
+ struct ds_zynq_disk *_disk = nullptr;
+ unsigned _disk_channels[8] = {};
+ std::list<std::pair<uint64_t, std::shared_ptr<uint8_t>>> _disk_cache;
uint8_t _byte_fraction;
uint16_t _ch_fraction;
uint8_t *_dest_ptr;
diff --git a/DSView/pv/deviceagent.h b/DSView/pv/deviceagent.h
index ae9132d..12a88a8 100644
--- a/DSView/pv/deviceagent.h
+++ b/DSView/pv/deviceagent.h
@@ -72,7 +72,11 @@ public:
}
inline bool is_hardware(){
- return _dev_type == DEV_TYPE_USB;
+ return _dev_type == DEV_TYPE_USB || is_network();
+ }
+
+ inline bool is_network(){
+ return _dev_type == DEV_TYPE_NETWORK;
}
inline bool is_virtual(){
diff --git a/DSView/pv/dock/triggerdock.cpp b/DSView/pv/dock/triggerdock.cpp
index 8280cdc..5716485 100644
--- a/DSView/pv/dock/triggerdock.cpp
+++ b/DSView/pv/dock/triggerdock.cpp
@@ -270,11 +270,15 @@ void TriggerDock::device_updated()
_session->get_device()->get_config_bool(SR_CONF_STREAM, stream);
sample_limits = _session->get_device()->get_sample_limit();
- _adv_radioButton->setEnabled(!stream);
- _position_spinBox->setEnabled(!stream);
- _position_slider->setEnabled(!stream);
-
- if (stream)
+ bool zynq_advanced = false;
+ if (_session->get_device()->is_network())
+ _session->get_device()->get_config_bool(SR_CONF_ZYNQ_ADVANCED, zynq_advanced);
+ const bool simple_only = stream || (_session->get_device()->is_network() && !zynq_advanced);
+ _adv_radioButton->setEnabled(!simple_only);
+ _position_spinBox->setEnabled(!simple_only);
+ _position_slider->setEnabled(!simple_only);
+
+ if (simple_only)
maxRange = 1;
else if (hw_depth >= sample_limits)
maxRange = DS_MAX_TRIG_PERCENT;
@@ -284,7 +288,7 @@ void TriggerDock::device_updated()
_position_spinBox->setRange(MinTrigPosition, maxRange);
_position_slider->setRange(MinTrigPosition, maxRange);
- if (_session->get_device()->is_virtual() || stream) {
+ if (_session->get_device()->is_virtual() || simple_only) {
_simple_radioButton->setChecked(true);
simple_trigger();
}
@@ -305,6 +309,8 @@ void TriggerDock::device_updated()
bool TriggerDock::commit_trigger()
{
+ // The standard editors always contain at least 16 positions.
+ const int editor_channels = qMax(_cur_ch_num, TriggerProbes);
// trigger position update
ds_trigger_set_pos(_position_slider->value());
@@ -334,7 +340,7 @@ bool TriggerDock::commit_trigger()
value0_str = _value0_lineEdit_list.at(i)->text();
value1_str = _value1_lineEdit_list.at(i)->text();
}
- ds_trigger_stage_set_value(i, _cur_ch_num, value0_str.toLocal8Bit().data(),
+ ds_trigger_stage_set_value(i, editor_channels, value0_str.toLocal8Bit().data(),
value1_str.toLocal8Bit().data());
}
} else if(_adv_tabWidget->currentIndex() == 1){
@@ -350,9 +356,9 @@ bool TriggerDock::commit_trigger()
edge_str = _serial_edge_lineEdit->text();
comp_str = _value1_lineEdit_list.at(1)->text();
}
- ds_trigger_stage_set_value(0, _cur_ch_num, start_str.toLocal8Bit().data(),
+ ds_trigger_stage_set_value(0, editor_channels, start_str.toLocal8Bit().data(),
stop_str.toLocal8Bit().data());
- ds_trigger_stage_set_value(1, _cur_ch_num, edge_str.toLocal8Bit().data(),
+ ds_trigger_stage_set_value(1, editor_channels, edge_str.toLocal8Bit().data(),
comp_str.toLocal8Bit().data());
//_serial_data_comboBox
diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp
index b63b17a..81b32f5 100644
--- a/DSView/pv/mainwindow.cpp
+++ b/DSView/pv/mainwindow.cpp
@@ -492,6 +492,11 @@ namespace pv
title = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_PACKET_ERROR), "Packet Error");
details = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_PACKET_ERROR_DET),
"the content of received packet are not expected!");
+ if (_device_agent->is_network()) {
+ QString reason;
+ if (_device_agent->get_config_string(SR_CONF_ZYNQ_LAST_ERROR, reason) && !reason.isEmpty())
+ details = reason;
+ }
_session->refresh(0);
break;
case SigSession::Data_overflow:
@@ -1988,6 +1993,12 @@ namespace pv
{
update_toolbar_view_status();
_protocol_widget->update_view_status();
+ if (_session->show_zynq_recording() || _session->has_zynq_disk_view()) {
+ _view->signals_changed(nullptr);
+ _view->auto_set_max_scale();
+ _view->set_scale_offset(_view->scale(), 0);
+ _view->update_view_port();
+ }
break;
}
case DSV_MSG_CURRENT_DEVICE_CHANGE_PREV:
@@ -2074,6 +2085,8 @@ namespace pv
{
_trigger_widget->device_updated();
_measure_widget->reload();
+ if (_view->can_resize_logic_rows())
+ _view->signals_changed(nullptr);
_view->check_calibration();
break;
}
diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp
index 1ad7cc4..cf8eaf3 100644
--- a/DSView/pv/sigsession.cpp
+++ b/DSView/pv/sigsession.cpp
@@ -315,9 +315,7 @@ namespace pv
std::string file_name = pv::path::ToUnicodePath(name);
dsv_info("Load file: \"%s\"", file_name.c_str());
- std::string file_str = name.toUtf8().toStdString();
-
- if (ds_device_from_file(file_str.c_str()) != SR_OK)
+ if (ds_device_from_file(name.toUtf8().constData()) != SR_OK)
{
dsv_err("Load file error!");
return false;
@@ -455,6 +453,29 @@ namespace pv
_capture_data->_cur_samplelimits = samplelimits;
}
+ bool SigSession::show_zynq_recording()
+ {
+ QString file;
+ if (!_device_agent.is_network() ||
+ !_device_agent.get_config_string(SR_CONF_ZYNQ_LAST_RECORDING, file) || file.isEmpty())
+ return false;
+ _device_agent.set_config_string(SR_CONF_ZYNQ_LAST_RECORDING, "");
+ clear_all_decode_task2();
+ auto *logic = _capture_data->get_logic();
+ if (!logic->load_zynq_recording(file))
+ return false;
+ set_cur_samplelimits(logic->get_sample_count());
+ _view_data = _capture_data;
+ attach_data_to_signal(_view_data);
+ _callback->trigger_message(DSV_MSG_DATA_POOL_CHANGED);
+ return true;
+ }
+
+ bool SigSession::has_zynq_disk_view() const
+ {
+ return _view_data->get_logic()->is_disk_recording();
+ }
+
void SigSession::capture_init()
{
// update instant setting
@@ -1223,7 +1244,10 @@ namespace pv
if (_capture_data->get_logic()->last_ended())
{
- _capture_data->get_logic()->set_loop(is_loop_mode());
+ bool live_recording = false;
+ if (_device_agent.is_network())
+ _device_agent.get_config_bool(SR_CONF_ZYNQ_LIVE_RECORDING, live_recording);
+ _capture_data->get_logic()->set_loop(is_loop_mode() || live_recording);
bool bNotFree = _is_decoding && _view_data == _capture_data;
@@ -1434,6 +1458,18 @@ namespace pv
feed_in_logic(*(const sr_datafeed_logic *)packet->payload);
break;
+ case SR_DF_ZYNQ_DISK:
+ {
+ auto *logic = _capture_data->get_logic();
+ if (logic->load_zynq_recording(QString::fromUtf8(static_cast<const char *>(packet->payload)), true)) {
+ set_cur_samplelimits(logic->get_sample_count());
+ } else {
+ _error = Pkt_data_err;
+ _callback->session_error();
+ }
+ break;
+ }
+
case SR_DF_DSO:
assert(packet->payload);
assert(!_is_task_end);
@@ -1812,7 +1848,15 @@ namespace pv
void SigSession::nodata_timeout()
{
- int flag;
+ bool disk_buffer = false;
+ if (_device_agent.is_network() &&
+ _device_agent.get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer) && disk_buffer) {
+ bool triggered;
+ int progress;
+ if (get_capture_status(triggered, progress) && triggered)
+ return;
+ }
+ int flag = -1;
_device_agent.get_config_byte(SR_CONF_TRIGGER_SOURCE, flag);
if (flag != DSO_TRIGGER_AUTO)
{
@@ -2247,7 +2291,7 @@ namespace pv
{
if (_device_agent.get_work_mode() == LOGIC)
{
- bool bAddDecoder = false;
+ bool bAddDecoder = show_zynq_recording() || has_zynq_disk_view();
bool bSwapBuffer = false;
if (is_single_mode())
diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h
index 3f000e3..9c34692 100644
--- a/DSView/pv/sigsession.h
+++ b/DSView/pv/sigsession.h
@@ -167,6 +167,8 @@ public:
bool set_default_device();
bool set_device(ds_device_handle dev_handle);
bool set_file(QString name);
+ bool show_zynq_recording();
+ bool has_zynq_disk_view() const;
void close_file(ds_device_handle dev_handle);
bool start_capture(bool instant);
bool stop_capture();
diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp
index d82a3b5..80f9ffc 100644
--- a/DSView/pv/toolbars/samplingbar.cpp
+++ b/DSView/pv/toolbars/samplingbar.cpp
@@ -22,6 +22,14 @@
#include "samplingbar.h"
#include <assert.h>
#include <QAction>
+#include <QInputDialog>
+#include <QFileDialog>
+#include <QDateTime>
+#include <QDir>
+#include <QFileInfo>
+#include <QStandardPaths>
+#include <QStorageInfo>
+#include <QSettings>
#include <QLabel>
#include <QAbstractItemView>
#include <math.h>
@@ -101,6 +109,32 @@ namespace pv
_device_type.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
addWidget(&_device_type);
addWidget(&_device_selector);
+ _action_zynq = addAction(tr("Zynq Ethernet..."));
+ connect(_action_zynq, &QAction::triggered, this, [this]() {
+ if (_session->is_working())
+ return;
+
+ QSettings settings;
+ bool accepted = false;
+ const auto address = QInputDialog::getText(this, tr("Connect Zynq"),
+ tr("Board IPv4 address"), QLineEdit::Normal,
+ settings.value("Zynq/IPv4", "192.168.1.68").toString(), &accepted).trimmed();
+ if (!accepted)
+ return;
+
+ ds_device_handle handle = 0;
+ const auto result = ds_add_zynq_device(address.toLatin1().constData(), &handle);
+ if (result != SR_OK) {
+ MsgBox::Show(result == SR_ERR_ARG ? tr("Enter a valid IPv4 address.") :
+ tr("No Zynq analyzer replied at %1 (UDP 37575 or TCP 37574/37572).").arg(address));
+ return;
+ }
+ settings.setValue("Zynq/IPv4", address);
+ update_device_list();
+ const int index = _device_selector.findData(QVariant::fromValue(handle));
+ if (index >= 0)
+ _device_selector.setCurrentIndex(index);
+ });
_configure_button.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
addWidget(&_configure_button);
@@ -268,6 +302,10 @@ namespace pv
if (ret == QDialog::Accepted)
{
+ bool disk_buffer = false;
+ if (_device_agent->is_network() &&
+ _device_agent->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer) && disk_buffer)
+ _session->set_collect_mode(COLLECT_SINGLE);
if (_session->have_view_data() == false)
this->commit_settings();
@@ -472,6 +510,7 @@ namespace pv
void SamplingBar::update_sample_count_selector()
{
bool stream_mode = false;
+ bool disk_buffer = false;
uint64_t hw_depth = 0;
uint64_t sw_depth;
uint64_t rle_depth = 0;
@@ -496,6 +535,8 @@ namespace pv
_updating_sample_count = true;
_device_agent->get_config_bool(SR_CONF_STREAM, stream_mode);
+ if (_device_agent->is_network())
+ _device_agent->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer);
_device_agent->get_config_uint64(SR_CONF_HW_DEPTH, hw_depth);
int mode = _device_agent->get_work_mode();
@@ -533,15 +574,36 @@ namespace pv
_sample_count.currentIndex())
.value<double>();
_sample_count.clear();
+ if (disk_buffer) {
+ _sample_count.addItem(QStringLiteral("До Stop"), QVariant::fromValue(double(0)));
+ _sample_count.setCurrentIndex(0);
+ _sample_count.setEnabled(false);
+ _updating_sample_count = false;
+ connect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int)));
+ return;
+ }
const uint64_t samplerate = _sample_rate.itemData(
_sample_rate.currentIndex())
.value<uint64_t>();
const double hw_duration = hw_depth / (samplerate * (1.0 / SR_SEC(1)));
+ uint64_t record_samples;
+ const bool timed_rj2 = stream_mode && _session->is_single_mode() &&
+ _device_agent->is_network() &&
+ _device_agent->get_config_uint64(SR_CONF_ZYNQ_RECORD_SAMPLES, record_samples);
if (mode == DSO)
duration = max_timebase;
+ else if (timed_rj2) {
+ if (pre_duration <= 0 && samplerate)
+ pre_duration = double(record_samples) / samplerate * SR_SEC(1);
+ for (int minutes = 60; minutes >= 1; minutes--)
+ _sample_count.addItem(QStringLiteral("%1 мин").arg(minutes),
+ QVariant::fromValue(double(SR_MIN(minutes))));
+ duration = SR_SEC(50);
+ }
else if (stream_mode)
- duration = sw_depth / (samplerate * (1.0 / SR_SEC(1)));
+ duration = (_device_agent->is_network() ? min(hw_depth, sw_depth) : sw_depth)
+ / (samplerate * (1.0 / SR_SEC(1)));
else if (rle_support)
duration = rle_depth / (samplerate * (1.0 / SR_SEC(1)));
else
@@ -615,7 +677,8 @@ namespace pv
}
_updating_sample_count = false;
- update_sample_count_selector_value();
+ if (!timed_rj2)
+ update_sample_count_selector_value();
on_samplecount_sel(_sample_count.currentIndex());
connect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int)));
@@ -643,7 +706,12 @@ namespace pv
}
else
{
- if (_device_agent->get_config_uint64(SR_CONF_LIMIT_SAMPLES, v))
+ if (_session->is_single_mode() && _device_agent->is_network() &&
+ _device_agent->get_config_uint64(SR_CONF_ZYNQ_RECORD_SAMPLES, v))
+ {
+ duration = (double)v;
+ }
+ else if (_device_agent->get_config_uint64(SR_CONF_LIMIT_SAMPLES, v))
{
duration = (double)v;
}
@@ -801,7 +869,10 @@ namespace pv
SR_CONF_SAMPLERATE,
sample_rate);
- if (_device_agent->get_work_mode() != DSO)
+ bool disk_buffer = false;
+ if (_device_agent->is_network())
+ _device_agent->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer);
+ if (_device_agent->get_work_mode() != DSO && !disk_buffer)
{
const uint64_t sample_count = ((uint64_t)ceil(sample_duration / SR_SEC(1) *
sample_rate) +
@@ -853,6 +924,50 @@ namespace pv
commit_settings();
+ uint64_t recording_samples;
+ bool disk_buffer = false;
+ if (_device_agent->is_network())
+ _device_agent->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer);
+ const bool record_rj2 = (disk_buffer || _session->is_single_mode()) &&
+ _device_agent->is_network() &&
+ _device_agent->get_config_uint64(SR_CONF_ZYNQ_RECORD_SAMPLES, recording_samples);
+ if (record_rj2) {
+ const auto rate = _device_agent->get_sample_rate();
+ const uint64_t samples = disk_buffer ? 0 : llround(get_hori_res() / SR_SEC(1) * rate);
+ unsigned channels = _session->get_ch_num(SR_CHANNEL_LOGIC);
+ if (!channels || !rate)
+ return false;
+ QSettings settings;
+ QDir directory(settings.value("Zynq/RecordDirectory",
+ QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).toString());
+ const QString suggested = directory.filePath(QStringLiteral("RJ2-%1.dsl")
+ .arg(QDateTime::currentDateTime().toString("yyyyMMdd-HHmmss-zzz")));
+ QString path = QFileDialog::getSaveFileName(this,
+ QStringLiteral("Сохранить захват RJ2"), suggested, "DSView (*.dsl)");
+ if (path.isEmpty())
+ return false;
+ if (!path.endsWith(".dsl", Qt::CaseInsensitive))
+ path += ".dsl";
+ QFileInfo info(path);
+ if (info.exists()) {
+ MsgBox::Show(QStringLiteral("Выберите имя нового файла."));
+ return false;
+ }
+ const QStorageInfo storage(info.absolutePath());
+ const uint64_t bytes = (samples + 7) / 8 * channels;
+ const bool rle = channels > 4 && rate > SR_MHZ(100);
+ if (!disk_buffer && !rle && storage.isReady() && storage.bytesAvailable() >= 0 &&
+ uint64_t(storage.bytesAvailable()) < bytes + bytes / 100 + 1048576) {
+ MsgBox::Show(QStringLiteral("Для выбранной длительности нужно около %1 ГБ свободного места.")
+ .arg(bytes / 1e9, 0, 'f', 1));
+ return false;
+ }
+ if ((!disk_buffer && !_device_agent->set_config_uint64(SR_CONF_ZYNQ_RECORD_SAMPLES, samples)) ||
+ !_device_agent->set_config_string(SR_CONF_ZYNQ_RECORD_FILE, path.toUtf8().constData()))
+ return false;
+ settings.setValue("Zynq/RecordDirectory", info.absolutePath());
+ }
+
if (_device_agent->get_work_mode() == DSO)
{
bool zero;
@@ -884,6 +999,8 @@ namespace pv
_is_run_as_instant = false;
bool ret = _session->start_capture(false);
+ if (!ret && record_rj2)
+ _device_agent->set_config_string(SR_CONF_ZYNQ_RECORD_FILE, "");
return ret;
}
@@ -1017,6 +1134,9 @@ namespace pv
void SamplingBar::reload()
{
QString iconPath = GetIconPath();
+ bool disk_buffer = false;
+ if (_device_agent->is_network())
+ _device_agent->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer);
_action_loop->setVisible(false);
@@ -1029,7 +1149,7 @@ namespace pv
else
{
update_mode_icon();
- _mode_action->setVisible(true);
+ _mode_action->setVisible(!disk_buffer);
_action_repeat->setVisible(true);
if (_session->is_loop_mode() && _device_agent->is_stream_mode() == false
@@ -1041,7 +1161,7 @@ namespace pv
_action_loop->setVisible(true);
}
_run_stop_action->setVisible(true);
- _instant_action->setVisible(true);
+ _instant_action->setVisible(!disk_buffer);
}
else if (mode == ANALOG)
{
@@ -1112,6 +1232,10 @@ namespace pv
}
update_mode_icon();
+ uint64_t record_samples;
+ if (_device_agent->is_network() &&
+ _device_agent->get_config_uint64(SR_CONF_ZYNQ_RECORD_SAMPLES, record_samples))
+ update_sample_count_selector();
}
void SamplingBar::update_device_list()
@@ -1172,11 +1296,15 @@ namespace pv
{
int bEnable = _session->is_working() == false;
int mode = _session->get_device()->get_work_mode();
+ bool disk_buffer = false;
+ if (_device_agent->is_network())
+ _device_agent->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer);
_device_type.setEnabled(bEnable);
_mode_button.setEnabled(bEnable);
_configure_button.setEnabled(bEnable);
_device_selector.setEnabled(bEnable);
+ _action_zynq->setEnabled(bEnable);
_action_loop->setVisible(false);
if (_session->get_device()->is_file()){
@@ -1237,6 +1365,13 @@ namespace pv
}
update_mode_icon();
+ if (disk_buffer)
+ {
+ _sample_count.setEnabled(false);
+ if (_sample_count.count())
+ _sample_count.setItemText(0, bEnable ? QStringLiteral("До Stop") :
+ QStringLiteral("Запись до Stop"));
+ }
if (_session->get_device()->is_demo() && bEnable)
{
diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h
index fde2169..724b535 100644
--- a/DSView/pv/toolbars/samplingbar.h
+++ b/DSView/pv/toolbars/samplingbar.h
@@ -162,6 +162,7 @@ namespace pv
QMenu *_mode_menu;
QAction *_action_repeat;
+ QAction *_action_zynq;
QAction *_action_single;
QAction *_action_loop;
diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp
index 0fab4b6..cd60ecb 100644
--- a/DSView/pv/view/header.cpp
+++ b/DSView/pv/view/header.cpp
@@ -28,6 +28,7 @@
#include <QMouseEvent>
#include <QPainter>
#include <QRect>
+#include <QScrollBar>
#include <QStyleOption>
#include <QApplication>
#include <assert.h>
@@ -112,6 +113,25 @@ pv::view::Trace* Header::get_mTrace(int &action, const QPoint &pt)
return NULL;
}
+static int handle_y(Trace *trace)
+{
+ return trace->get_y() + trace->get_totalHeight() / 2 + View::SignalMargin;
+}
+
+Trace* Header::resize_handle_at(const QPoint &point)
+{
+ if (!_view.can_resize_logic_rows() || point.x() < width() - 30)
+ return nullptr;
+ std::vector<Trace*> traces;
+ _view.get_traces(TIME_VIEW, traces);
+ for (auto *trace : traces) {
+ if (trace->get_type() == SR_CHANNEL_LOGIC && trace->enabled() &&
+ qAbs(point.y() - handle_y(trace)) <= 4)
+ return trace;
+ }
+ return nullptr;
+}
+
void Header::paintEvent(QPaintEvent*)
{
using pv::view::Trace;
@@ -141,6 +161,19 @@ void Header::paintEvent(QPaintEvent*)
t->paint_label(painter, w, dragging ? QPoint(-1, -1) : _mouse_point, fore);
}
+ if (_view.can_resize_logic_rows()) {
+ auto grip = fore;
+ grip.setAlpha(125);
+ painter.setPen(grip);
+ for (auto *trace : traces) {
+ if (trace->get_type() == SR_CHANNEL_LOGIC && trace->enabled()) {
+ const int y = handle_y(trace);
+ painter.drawLine(w - 25, y, w - 5, y);
+ painter.drawLine(w - 25, y + 2, w - 5, y + 2);
+ }
+ }
+ }
+
painter.end();
}
@@ -175,6 +208,17 @@ void Header::mousePressEvent(QMouseEvent *event)
{
assert(event);
+ if (event->button() == Qt::LeftButton) {
+ if (auto *trace = resize_handle_at(event->pos())) {
+ _resize_channel = trace->get_index();
+ _resize_start_y = event->globalY();
+ _resize_start_height = trace->get_totalHeight();
+ setCursor(Qt::SizeVerCursor);
+ event->accept();
+ return;
+ }
+ }
+
_mouse_is_down = true;
std::vector<Trace*> traces;
@@ -210,7 +254,7 @@ void Header::mousePressEvent(QMouseEvent *event)
if (~QApplication::keyboardModifiers() & Qt::ControlModifier)
_drag_traces.clear();
- _drag_traces.push_back(make_pair(mTrace, mTrace->get_zero_vpos()));
+ _drag_traces.push_back(make_pair(mTrace, mTrace->get_zero_vpos() + _view.vertical_offset()));
mTrace->set_old_v_offset(mTrace->get_v_offset());
}
@@ -239,6 +283,14 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
{
assert(event);
+ if (_resize_channel >= 0 && event->button() == Qt::LeftButton) {
+ _view.resize_logic_row(_resize_channel, _resize_start_height + event->globalY() - _resize_start_y);
+ _resize_channel = -1;
+ unsetCursor();
+ event->accept();
+ return;
+ }
+
_mouse_is_down = false;
// judge for color / name / trigger / move
@@ -302,6 +354,13 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
void Header::wheelEvent(QWheelEvent *event)
{
assert(event);
+ auto *scroll = _view.verticalScrollBar();
+ const int vertical_delta = event->angleDelta().y();
+ if (scroll->maximum() > 0 && vertical_delta) {
+ scroll->setValue(scroll->value() - vertical_delta / 3);
+ event->accept();
+ return;
+ }
int x = 0;
int y = 0;
@@ -414,6 +473,19 @@ void Header::mouseMoveEvent(QMouseEvent *event)
{
assert(event);
+ if (_resize_channel >= 0) {
+ if (event->buttons() & Qt::LeftButton) {
+ _view.resize_logic_row(_resize_channel, _resize_start_height + event->globalY() - _resize_start_y);
+ event->accept();
+ return;
+ }
+ _resize_channel = -1;
+ }
+ if (_drag_traces.empty() && resize_handle_at(event->pos()))
+ setCursor(Qt::SizeVerCursor);
+ else
+ unsetCursor();
+
if (_view.session().is_working() && _view.session().get_device()->get_work_mode() == LOGIC){
//Disable the hover status of trig button on left pannel.
return;
@@ -470,6 +542,8 @@ void Header::mouseMoveEvent(QMouseEvent *event)
void Header::leaveEvent(QEvent*)
{
+ if (_resize_channel < 0)
+ unsetCursor();
_mouse_point = QPoint(-1, -1);
update();
}
diff --git a/DSView/pv/view/header.h b/DSView/pv/view/header.h
index 51f6164..0191c03 100644
--- a/DSView/pv/view/header.h
+++ b/DSView/pv/view/header.h
@@ -49,6 +49,7 @@ public:
private:
pv::view::Trace* get_mTrace(int &action, const QPoint &pt);
+ Trace* resize_handle_at(const QPoint &point);
private:
void retranslateUi();
@@ -101,6 +102,9 @@ private:
std::list<std::pair<Trace*, int> > _drag_traces;
Trace *_context_trace;
bool _mouse_is_down;
+ int _resize_channel = -1;
+ int _resize_start_y = 0;
+ int _resize_start_height = 0;
};
} // namespace view
diff --git a/DSView/pv/view/trace.cpp b/DSView/pv/view/trace.cpp
index 5540899..ad68b39 100644
--- a/DSView/pv/view/trace.cpp
+++ b/DSView/pv/view/trace.cpp
@@ -127,7 +127,12 @@ void Trace::set_index_list(const std::list<int> &index_list)
int Trace::get_zero_vpos()
{
- return _v_offset;
+ return get_y();
+}
+
+int Trace::get_y() const
+{
+ return _v_offset - (_view ? _view->vertical_offset() : 0);
}
void Trace::resize()
@@ -138,7 +143,7 @@ void Trace::set_view(pv::view::View *view)
{
assert(view);
_view = view;
- connect(_view, SIGNAL(resize()), this, SLOT(resize()));
+ connect(_view, SIGNAL(resize()), this, SLOT(resize()), Qt::UniqueConnection);
}
void Trace::set_viewport(pv::view::Viewport *viewport)
diff --git a/DSView/pv/view/trace.h b/DSView/pv/view/trace.h
index d05c8fb..32e3a0d 100644
--- a/DSView/pv/view/trace.h
+++ b/DSView/pv/view/trace.h
@@ -239,9 +239,7 @@ public:
/**
* Gets the y-offset of the axis.
*/
- inline int get_y(){
- return _v_offset;
- }
+ int get_y() const;
/**
* Determines if a point is in the header rect.
diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp
index c35f8f8..088d6f8 100644
--- a/DSView/pv/view/view.cpp
+++ b/DSView/pv/view/view.cpp
@@ -578,6 +578,9 @@ void View::set_search_pos(uint64_t search_pos, bool hit)
void View::normalize_layout()
{
+ if (can_resize_logic_rows())
+ return;
+
int v_min = INT_MAX;
std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);
@@ -635,8 +638,10 @@ void View::update_scroll()
_updating_scroll = false;
// Set the vertical scrollbar
- verticalScrollBar()->setPageStep(areaSize.height());
- verticalScrollBar()->setRange(0,0);
+ const int visible_height = _time_viewport->height();
+ verticalScrollBar()->setPageStep(visible_height);
+ verticalScrollBar()->setRange(0, can_resize_logic_rows() ?
+ max(0, _logic_content_height - visible_height) : 0);
}
void View::update_scale_offset()
@@ -673,12 +678,37 @@ void View::mode_changed()
_scale = max(min(_scale, _maxscale), _minscale);
}
+bool View::can_resize_logic_rows() const
+{
+ return _device_agent->is_network() ||
+ (_device_agent->is_file() && _session->has_zynq_disk_view());
+}
+
+int View::vertical_offset() const
+{
+ return verticalScrollBar()->value();
+}
+
+void View::resize_logic_row(int channel, int height)
+{
+ if (!can_resize_logic_rows())
+ return;
+ const int requested = max(12, min(5 * MaxHeightUnit, height));
+ auto current = _logic_row_heights.find(channel);
+ if (current != _logic_row_heights.end() && current->second == requested)
+ return;
+ _logic_row_heights[channel] = requested;
+ signals_changed(nullptr);
+}
+
void View::signals_changed(const Trace* eventTrace)
{
double actualMargin = SignalMargin;
int total_rows = 0;
int label_size = 0;
uint8_t max_height = MaxHeightUnit;
+ const bool resizable_logic = can_resize_logic_rows();
+ _logic_content_height = 0;
std::vector<Trace*> time_traces;
std::vector<Trace*> fft_traces;
std::vector<Trace*> traces;
@@ -762,7 +792,15 @@ void View::signals_changed(const Trace* eventTrace)
max_height = (v + 1) * MaxHeightUnit;
}
- if (height < 2*actualMargin) {
+ if (resizable_logic) {
+ // Use the selected multiplier even when the tracks need scrolling.
+ if (_logic_max_height != max_height) {
+ _logic_row_heights.clear();
+ _logic_max_height = max_height;
+ }
+ _signalHeight = max_height;
+ }
+ else if (height < 2*actualMargin) {
actualMargin /= 2;
_signalHeight = max(1.0, (_time_viewport->height()
- 2 * actualMargin * label_size) * 1.0 / total_rows);
@@ -815,7 +853,13 @@ void View::signals_changed(const Trace* eventTrace)
if (t->rows_size() == 0)
continue;
- const double traceHeight = _signalHeight*t->rows_size();
+ int row_height = _signalHeight;
+ if (resizable_logic && t->get_type() == SR_CHANNEL_LOGIC) {
+ const auto custom = _logic_row_heights.find(t->get_index());
+ if (custom != _logic_row_heights.end())
+ row_height = custom->second;
+ }
+ const int traceHeight = row_height * t->rows_size();
t->set_totalHeight((int)traceHeight);
t->set_v_offset(next_v_offset + 0.5 * traceHeight + actualMargin);
next_v_offset += traceHeight + 2 * actualMargin;
@@ -831,6 +875,7 @@ void View::signals_changed(const Trace* eventTrace)
sig->set_scale(sig->get_totalHeight());
}
}
+ _logic_content_height = next_v_offset;
_time_viewport->clear_measure();
_session->update_dso_data_scale();
}
@@ -969,6 +1014,7 @@ void View::v_scroll_value_changed(int value)
{
(void)value;
_header->update();
+ set_update(_time_viewport, true);
viewport_update();
}
@@ -1367,6 +1413,10 @@ void View::splitterMoved(int pos, int index)
void View::reload()
{
+ _logic_row_heights.clear();
+ _logic_max_height = 0;
+ _logic_content_height = 0;
+ verticalScrollBar()->setValue(0);
clear();
/*
diff --git a/DSView/pv/view/view.h b/DSView/pv/view/view.h
index aa738ec..9ab29bc 100644
--- a/DSView/pv/view/view.h
+++ b/DSView/pv/view/view.h
@@ -25,6 +25,7 @@
#define DSVIEW_PV_VIEW_VIEW_H
#include <stdint.h>
+#include <map>
#include <set>
#include <vector>
@@ -192,6 +193,9 @@ public:
inline int get_signalHeight(){
return _signalHeight;
}
+ bool can_resize_logic_rows() const;
+ void resize_logic_row(int channel, int height);
+ int vertical_offset() const;
int headerWidth();
@@ -459,6 +463,9 @@ private:
int64_t _preOffset;
int _spanY;
int _signalHeight;
+ std::map<int, int> _logic_row_heights;
+ int _logic_max_height = 0;
+ int _logic_content_height = 0;
bool _updating_scroll;
// trigger position fix
diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp
index dea3b91..a9e6550 100644
--- a/DSView/pv/view/viewport.cpp
+++ b/DSView/pv/view/viewport.cpp
@@ -600,7 +600,18 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back)
QRect status_rect = QRect(cenPos.x() - radius, cenPos.y() + radius * 0.4, radius * 2, radius * 0.5);
- if (triggered) {
+ auto *device = _view.session().get_device();
+ bool disk_buffer = false;
+ if (device->is_network() &&
+ device->get_config_bool(SR_CONF_ZYNQ_DISK_BUFFER, disk_buffer) && disk_buffer) {
+ uint64_t tenths = 0;
+ device->get_config_uint64(SR_CONF_ZYNQ_RECORD_TENTHS, tenths);
+ const QString status = triggered
+ ? QStringLiteral("Запись в файл · %1 с · Stop для завершения").arg(tenths / 10.0, 0, 'f', 1)
+ : QStringLiteral("Ожидание триггера");
+ p.drawText(status_rect, Qt::AlignCenter | Qt::AlignVCenter, status);
+ }
+ else if (triggered) {
p.drawText(status_rect,
Qt::AlignCenter | Qt::AlignVCenter,
L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGERED), "Triggered! ") + QString::number(captured_progress)
diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c
index 054cddd..3efd5fe 100644
--- a/libsigrok4DSL/lib_main.c
+++ b/libsigrok4DSL/lib_main.c
@@ -21,6 +21,7 @@
#include "libsigrok-internal.h"
#include "log.h"
+#include <gio/gio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
@@ -336,6 +337,54 @@ SR_API int ds_get_device_list(struct ds_device_base_info **out_list, int *out_co
return SR_OK;
}
+SR_API int ds_add_zynq_device(const char *address, ds_device_handle *preferred)
+{
+ if (!address || !preferred || ds_is_collecting())
+ return SR_ERR_ARG;
+
+ GInetAddress *ip = g_inet_address_new_from_string(address);
+ if (!ip)
+ return SR_ERR_ARG;
+ const gboolean ipv4 = g_inet_address_get_family(ip) == G_SOCKET_FAMILY_IPV4;
+ g_object_unref(ip);
+ if (!ipv4)
+ return SR_ERR_ARG;
+
+ *preferred = 0;
+ for (enum zynq_transport mode = ZYNQ_PL_STREAM; mode <= ZYNQ_TCP_BUFFER; mode++) {
+ struct sr_dev_inst *candidate = sr_zynq_probe(address, mode);
+ if (!candidate) {
+ if (mode == ZYNQ_PL_BUFFER && *preferred)
+ break;
+ continue;
+ }
+
+ pthread_mutex_lock(&lib_ctx.mutext);
+ struct sr_dev_inst *existing = NULL;
+ for (const GSList *entry = lib_ctx.device_list; entry; entry = entry->next) {
+ struct sr_dev_inst *device = entry->data;
+ if (device->dev_type == DEV_TYPE_NETWORK &&
+ strcmp(device->name, candidate->name) == 0) {
+ existing = device;
+ break;
+ }
+ }
+
+ if (existing) {
+ sr_dev_inst_free(candidate);
+ candidate = existing;
+ } else {
+ lib_ctx.device_list = g_slist_append(lib_ctx.device_list, candidate);
+ }
+ if (!*preferred)
+ *preferred = candidate->handle;
+ pthread_mutex_unlock(&lib_ctx.mutext);
+ if (mode == ZYNQ_PL_STREAM || mode == ZYNQ_PL_BUFFER)
+ break;
+ }
+ return *preferred ? SR_OK : SR_ERR;
+}
+
/**
* Active a device.
*/
diff --git a/libsigrok4DSL/libsigrok-internal.h b/libsigrok4DSL/libsigrok-internal.h
index a5534c0..4676313 100644
--- a/libsigrok4DSL/libsigrok-internal.h
+++ b/libsigrok4DSL/libsigrok-internal.h
@@ -249,6 +249,9 @@ struct ds_trigger {
};
+enum zynq_transport { ZYNQ_PL_STREAM, ZYNQ_PL_BUFFER, ZYNQ_TCP_STREAM, ZYNQ_TCP_BUFFER };
+SR_PRIV struct sr_dev_inst *sr_zynq_probe(const char *address, enum zynq_transport transport);
+
/*--- device.c --------------------------------------------------------------*/
SR_PRIV struct sr_channel *sr_channel_new(uint16_t index, int type, gboolean enabled, const char *name);
diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h
index 28d8a0c..a55d387 100644
--- a/libsigrok4DSL/libsigrok.h
+++ b/libsigrok4DSL/libsigrok.h
@@ -174,6 +174,7 @@ enum sr_device_type{
DEV_TYPE_FILELOG = 2,
DEV_TYPE_USB = 3,
DEV_TYPE_SERIAL = 4,
+ DEV_TYPE_NETWORK = 5,
};
/** Data types used by sr_config_info(). */
@@ -202,6 +203,7 @@ enum sr_datafeed_packet_type {
SR_DF_FRAME_BEGIN,
SR_DF_FRAME_END,
SR_DF_OVERFLOW,
+ SR_DF_ZYNQ_DISK,
};
/** Values for sr_datafeed_analog.mq. */
@@ -323,6 +325,7 @@ enum DSLOGIC_OPERATION_MODE
LO_OP_EXTEST = 3,
/** SDRAM loopback test mode */
LO_OP_LPTEST = 4,
+ LO_OP_ZYNQ_SNAPSHOT = 100,
};
enum DSO_MEASURE_TYPE {
@@ -933,6 +936,14 @@ enum sr_config_option_id
/** Stream */
SR_CONF_STREAM = 30052,
+ SR_CONF_ZYNQ_RECORD_FILE = 30990,
+ SR_CONF_ZYNQ_RECORD_SAMPLES = 30991,
+ SR_CONF_ZYNQ_LAST_ERROR = 30992,
+ SR_CONF_ZYNQ_ADVANCED = 30993,
+ SR_CONF_ZYNQ_DISK_BUFFER = 30994,
+ SR_CONF_ZYNQ_LAST_RECORDING = 30995,
+ SR_CONF_ZYNQ_LIVE_RECORDING = 30996,
+ SR_CONF_ZYNQ_RECORD_TENTHS = 30997,
/** DSO Roll */
SR_CONF_ROLL = 30053,
@@ -1409,6 +1420,7 @@ SR_API void ds_set_user_data_dir(const char *dir);
* User need call g_free() to release the buffer. If the list is empty, the out_list is null.
*/
SR_API int ds_get_device_list(struct ds_device_base_info** out_list, int *out_count);
+SR_API int ds_add_zynq_device(const char *address, ds_device_handle *preferred);
/**
* Active a device.
@@ -1436,6 +1448,24 @@ SR_API int ds_have_actived_device();
*/
SR_API int ds_device_from_file(const char *file_path);
+struct ds_zynq_record_info {
+ uint64_t samples;
+ unsigned clock, divider, mask, leaf_samples;
+ gboolean indexed;
+};
+SR_API int ds_zynq_record_info(const char *path, struct ds_zynq_record_info *info);
+SR_API int ds_zynq_record_window(const char *source, const char *target, unsigned first_leaf);
+struct ds_zynq_disk;
+struct ds_zynq_tile {
+ uint8_t first, last, changes;
+};
+#define DS_ZYNQ_TILE_SAMPLES 262144u
+SR_API struct ds_zynq_disk *ds_zynq_disk_open(const char *path, struct ds_zynq_record_info *info);
+SR_API void ds_zynq_disk_close(struct ds_zynq_disk *disk);
+SR_API const struct ds_zynq_tile *ds_zynq_disk_tiles(const struct ds_zynq_disk *disk);
+SR_API int ds_zynq_disk_leaf(struct ds_zynq_disk *disk, unsigned leaf, unsigned channel,
+ void *data, unsigned capacity);
+
/**
* Remove one device from the list, and destory it.
* User need to call ds_get_device_list() to get the new list.
diff --git a/libsigrok4DSL/session_driver.c b/libsigrok4DSL/session_driver.c
index 3b298d4..90d0ff1 100644
--- a/libsigrok4DSL/session_driver.c
+++ b/libsigrok4DSL/session_driver.c
@@ -1356,6 +1356,22 @@ static int dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *statu
}
}
+static int receive_disk_recording(int fd, int revents, const struct sr_dev_inst *sdi)
+{
+ (void)fd;
+ if (revents != -1) {
+ const struct sr_datafeed_packet disk = {
+ .type = SR_DF_ZYNQ_DISK, .status = SR_PKT_OK, .payload = sdi->path
+ };
+ ds_data_forward(sdi, &disk);
+ }
+ const struct sr_datafeed_packet end = {.type = SR_DF_END, .status = SR_PKT_OK};
+ ds_data_forward(sdi, &end);
+ sr_session_source_remove(-1);
+ close_archive(sdi->priv);
+ return FALSE;
+}
+
static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
{
(void)cb_data;
@@ -1399,6 +1415,14 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
return SR_ERR;
}
+ if (sdi->mode == LOGIC && unzLocateFile(vdev->archive, "zynq_recording.json", 0) == UNZ_OK) {
+ std_session_send_df_header(sdi, LOG_PREFIX);
+ int result = sr_session_source_add(-1, 0, 0, receive_disk_recording, sdi);
+ if (result != SR_OK)
+ close_archive(vdev);
+ return result;
+ }
+
if (vdev->version == 1)
{
if (unzLocateFile(vdev->archive, "data", 0) != UNZ_OK)