Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raptor Engineering Public Development
dsview
Commits
800f4c61
Commit
800f4c61
authored
Nov 04, 2015
by
DreamSourceLab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file save support @ OSC & DAQ mode
parent
df05c5c9
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
767 additions
and
352 deletions
+767
-352
DSView/pv/data/analogsnapshot.cpp
DSView/pv/data/analogsnapshot.cpp
+2
-2
DSView/pv/device/file.cpp
DSView/pv/device/file.cpp
+4
-1
DSView/pv/devicemanager.cpp
DSView/pv/devicemanager.cpp
+1
-1
DSView/pv/mainwindow.cpp
DSView/pv/mainwindow.cpp
+3
-3
DSView/pv/sigsession.cpp
DSView/pv/sigsession.cpp
+59
-23
DSView/pv/sigsession.h
DSView/pv/sigsession.h
+1
-1
DSView/pv/toolbars/filebar.cpp
DSView/pv/toolbars/filebar.cpp
+5
-11
DSView/pv/view/analogsignal.cpp
DSView/pv/view/analogsignal.cpp
+1
-3
DSView/pv/view/dsosignal.cpp
DSView/pv/view/dsosignal.cpp
+30
-7
DSView/pv/view/logicsignal.cpp
DSView/pv/view/logicsignal.cpp
+5
-0
DSView/pv/view/logicsignal.h
DSView/pv/view/logicsignal.h
+2
-1
DSView/pv/view/view.cpp
DSView/pv/view/view.cpp
+5
-2
libsigrok4DSL/hardware/DSL/dscope.c
libsigrok4DSL/hardware/DSL/dscope.c
+2
-2
libsigrok4DSL/hardware/DSL/dslogic.c
libsigrok4DSL/hardware/DSL/dslogic.c
+96
-84
libsigrok4DSL/hardware/demo/demo.c
libsigrok4DSL/hardware/demo/demo.c
+269
-179
libsigrok4DSL/libsigrok.h
libsigrok4DSL/libsigrok.h
+6
-0
libsigrok4DSL/session_driver.c
libsigrok4DSL/session_driver.c
+145
-11
libsigrok4DSL/session_file.c
libsigrok4DSL/session_file.c
+131
-21
No files found.
DSView/pv/data/analogsnapshot.cpp
View file @
800f4c61
...
...
@@ -47,7 +47,7 @@ const float AnalogSnapshot::LogEnvelopeScaleFactor =
const
uint64_t
AnalogSnapshot
::
EnvelopeDataUnit
=
64
*
1024
;
// bytes
AnalogSnapshot
::
AnalogSnapshot
(
const
sr_datafeed_analog
&
analog
,
uint64_t
_total_sample_len
,
unsigned
int
channel_num
)
:
Snapshot
(
sizeof
(
uint16_t
),
_total_sample_len
,
channel_num
)
Snapshot
(
sizeof
(
uint16_t
)
*
channel_num
,
_total_sample_len
,
channel_num
)
{
boost
::
lock_guard
<
boost
::
recursive_mutex
>
lock
(
_mutex
);
memset
(
_envelope_levels
,
0
,
sizeof
(
_envelope_levels
));
...
...
@@ -66,7 +66,7 @@ void AnalogSnapshot::append_payload(
const
sr_datafeed_analog
&
analog
)
{
boost
::
lock_guard
<
boost
::
recursive_mutex
>
lock
(
_mutex
);
append_data
(
analog
.
data
,
analog
.
num_samples
);
append_data
(
analog
.
data
,
analog
.
num_samples
);
// Generate the first mip-map from the data
append_payload_to_envelope_levels
();
...
...
DSView/pv/device/file.cpp
View file @
800f4c61
...
...
@@ -23,6 +23,8 @@
#include "inputfile.h"
#include "sessionfile.h"
#include <QFileInfo>
#include <boost/filesystem.hpp>
#include <libsigrok4DSL/libsigrok.h>
...
...
@@ -39,7 +41,8 @@ File::File(QString path) :
QString
File
::
format_device_title
()
const
{
return
_path
;
QFileInfo
fi
(
_path
);
return
fi
.
fileName
();
}
File
*
File
::
create
(
QString
name
)
...
...
DSView/pv/devicemanager.cpp
View file @
800f4c61
...
...
@@ -102,7 +102,7 @@ std::list<boost::shared_ptr<device::DevInst> > DeviceManager::driver_scan(
//release_driver(driver);
// Check If DSL hardware driver
if
(
str
cmp
(
driver
->
name
,
"demo"
)
!=
0
)
{
if
(
str
ncmp
(
driver
->
name
,
"virtual"
,
7
)
)
{
QDir
dir
(
QCoreApplication
::
applicationDirPath
());
if
(
!
dir
.
cd
(
"res"
))
return
driver_devices
;
...
...
DSView/pv/mainwindow.cpp
View file @
800f4c61
...
...
@@ -319,8 +319,7 @@ void MainWindow::update_device_list()
errorMessage
,
infoMessage
));
}
if
(
strcmp
(
selected_device
->
dev_inst
()
->
driver
->
name
,
"demo"
)
!=
0
&&
strcmp
(
selected_device
->
dev_inst
()
->
driver
->
name
,
"virtual-session"
)
!=
0
)
{
if
(
strncmp
(
selected_device
->
dev_inst
()
->
driver
->
name
,
"virtual"
,
7
))
{
_logo_bar
->
dsl_connected
(
true
);
QString
ses_name
=
config_path
+
QString
::
fromUtf8
(
selected_device
->
dev_inst
()
->
driver
->
name
)
+
...
...
@@ -521,7 +520,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
QString
driver_name
=
_session
.
get_device
()
->
dev_inst
()
->
driver
->
name
;
QString
mode_name
=
QString
::
number
(
_session
.
get_device
()
->
dev_inst
()
->
mode
);
QString
file_name
=
dir
.
absolutePath
()
+
"/"
+
driver_name
+
mode_name
+
".dsc"
;
if
(
!
file_name
.
isEmpty
())
if
(
strncmp
(
driver_name
.
toLocal8Bit
(),
"virtual"
,
7
)
&&
!
file_name
.
isEmpty
())
store_session
(
file_name
);
}
event
->
accept
();
...
...
DSView/pv/sigsession.cpp
View file @
800f4c61
...
...
@@ -177,19 +177,45 @@ void SigSession::set_file(QString name) throw(QString)
}
}
void
SigSession
::
save_file
(
const
QString
name
){
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_logic_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
void
SigSession
::
save_file
(
const
QString
name
,
int
type
){
unsigned
char
*
data
;
int
unit_size
;
uint64_t
sample_count
;
if
(
type
==
ANALOG
)
{
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
AnalogSnapshot
>
>
&
snapshots
=
_analog_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
AnalogSnapshot
>
&
snapshot
=
snapshots
.
front
();
data
=
(
unsigned
char
*
)
snapshot
->
get_data
();
unit_size
=
snapshot
->
unit_size
();
sample_count
=
snapshot
->
get_sample_count
();
}
else
if
(
type
==
DSO
)
{
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
DsoSnapshot
>
>
&
snapshots
=
_dso_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
DsoSnapshot
>
&
snapshot
=
snapshots
.
front
();
data
=
(
unsigned
char
*
)
snapshot
->
get_data
();
// snapshot->unit_size() is not valid for dso, replaced by enabled channel number
unit_size
=
get_ch_num
(
SR_CHANNEL_DSO
);
sample_count
=
snapshot
->
get_sample_count
();
}
else
{
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_logic_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
data
=
(
unsigned
char
*
)
snapshot
->
get_data
();
unit_size
=
snapshot
->
unit_size
();
sample_count
=
snapshot
->
get_sample_count
();
}
sr_session_save
(
name
.
toLocal8Bit
().
data
(),
_dev_inst
->
dev_inst
(),
(
unsigned
char
*
)
snapshot
->
get_data
(),
snapshot
->
unit_size
(),
snapshot
->
get_sample_count
());
data
,
unit_size
,
sample_count
);
}
QList
<
QString
>
SigSession
::
getSuportedExportFormats
(){
...
...
@@ -365,8 +391,8 @@ void SigSession::set_default_device(boost::function<void (const QString)> error_
// Try and find the DreamSourceLab device and select that by default
BOOST_FOREACH
(
boost
::
shared_ptr
<
pv
::
device
::
DevInst
>
dev
,
devices
)
if
(
dev
->
dev_inst
()
&&
strcmp
(
dev
->
dev_inst
()
->
driver
->
name
,
"
demo"
)
!=
0
)
{
str
n
cmp
(
dev
->
dev_inst
()
->
driver
->
name
,
"
virtual"
,
7
)
!=
0
)
{
default_device
=
dev
;
break
;
}
...
...
@@ -423,7 +449,10 @@ void SigSession::start_capture(bool instant,
}
// update setting
_instant
=
instant
;
if
(
strcmp
(
_dev_inst
->
dev_inst
()
->
driver
->
name
,
"virtual-session"
))
_instant
=
instant
;
else
_instant
=
true
;
if
(
~
_instant
)
_view_timer
.
blockSignals
(
false
);
...
...
@@ -545,7 +574,7 @@ void SigSession::sample_thread_proc(boost::shared_ptr<device::DevInst> dev_inst,
assert
(
s
);
boost
::
shared_ptr
<
view
::
LogicSignal
>
logicSig
;
if
(
logicSig
=
dynamic_pointer_cast
<
view
::
LogicSignal
>
(
s
))
{
if
(
logicSig
->
get_trig
()
!=
0
)
{
if
(
logicSig
->
has_trig
()
)
{
ds_trigger_set_en
(
true
);
logicSig
->
set_trig
(
logicSig
->
get_trig
());
}
...
...
@@ -628,12 +657,14 @@ void SigSession::add_group()
_group_traces
.
push_back
(
signal
);
_group_cnt
++
;
if
(
_capture_state
==
Stopped
)
{
const
deque
<
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
>
&
snapshots
=
_logic_data
->
get_snapshots
();
if
(
!
snapshots
.
empty
())
{
//if (!_cur_group_snapshot)
//{
// Create a new data snapshot
_cur_group_snapshot
=
boost
::
shared_ptr
<
data
::
GroupSnapshot
>
(
new
data
::
GroupSnapshot
(
_logic_data
->
get_snapshots
()
.
front
(),
signal
->
get_index_list
()));
new
data
::
GroupSnapshot
(
snapshots
.
front
(),
signal
->
get_index_list
()));
//_cur_group_snapshot->append_payload();
_group_data
->
push_snapshot
(
_cur_group_snapshot
);
_cur_group_snapshot
.
reset
();
...
...
@@ -724,10 +755,6 @@ void SigSession::init_signals()
if
(
logic_probe_count
!=
0
)
{
_logic_data
.
reset
(
new
data
::
Logic
());
assert
(
_logic_data
);
_group_data
.
reset
(
new
data
::
Group
());
assert
(
_group_data
);
_group_cnt
=
0
;
}
if
(
dso_probe_count
!=
0
)
{
...
...
@@ -739,10 +766,17 @@ void SigSession::init_signals()
_analog_data
.
reset
(
new
data
::
Analog
());
assert
(
_analog_data
);
}
_group_data
.
reset
(
new
data
::
Group
());
assert
(
_group_data
);
_group_cnt
=
0
;
}
// Make the logic probe list
{
_group_traces
.
clear
();
vector
<
boost
::
shared_ptr
<
view
::
GroupSignal
>
>
().
swap
(
_group_traces
);
for
(
const
GSList
*
l
=
_dev_inst
->
dev_inst
()
->
channels
;
l
;
l
=
l
->
next
)
{
const
sr_channel
*
const
probe
=
(
const
sr_channel
*
)
l
->
data
;
...
...
@@ -853,8 +887,10 @@ void SigSession::refresh(int holdtime)
_analog_data
->
clear
();
_cur_analog_snapshot
.
reset
();
}
_data_lock
=
true
;
_refresh_timer
.
start
(
holdtime
);
if
(
strncmp
(
_dev_inst
->
dev_inst
()
->
driver
->
name
,
"virtual"
,
7
))
{
_data_lock
=
true
;
_refresh_timer
.
start
(
holdtime
);
}
data_updated
();
}
...
...
DSView/pv/sigsession.h
View file @
800f4c61
...
...
@@ -117,7 +117,7 @@ public:
void
set_file
(
QString
name
)
throw
(
QString
);
void
save_file
(
const
QString
name
);
void
save_file
(
const
QString
name
,
int
type
);
void
set_default_device
(
boost
::
function
<
void
(
const
QString
)
>
error_handler
);
void
export_file
(
const
QString
name
,
QWidget
*
parent
,
const
QString
ext
);
...
...
DSView/pv/toolbars/filebar.cpp
View file @
800f4c61
...
...
@@ -200,22 +200,16 @@ void FileBar::on_actionSave_triggered()
msg
.
setStandardButtons
(
QMessageBox
::
Ok
);
msg
.
setIcon
(
QMessageBox
::
Warning
);
msg
.
exec
();
}
else
if
(
_session
.
get_device
()
->
dev_inst
()
->
mode
!=
LOGIC
)
{
QMessageBox
msg
(
this
);
msg
.
setText
(
tr
(
"File Save"
));
msg
.
setInformativeText
(
tr
(
"DSView currently only support saving logic data to file!"
));
msg
.
setStandardButtons
(
QMessageBox
::
Ok
);
msg
.
setIcon
(
QMessageBox
::
Warning
);
msg
.
exec
();
}
else
{
}
else
{
QString
file_name
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
""
,
tr
(
"DSView Data (*.dsl)"
));
this
,
tr
(
"Save File"
),
""
,
tr
(
"DSView Data (*.dsl)"
));
if
(
!
file_name
.
isEmpty
())
{
QFileInfo
f
(
file_name
);
if
(
f
.
suffix
().
compare
(
"dsl"
))
file_name
.
append
(
tr
(
".dsl"
));
_session
.
save_file
(
file_name
);
_session
.
save_file
(
file_name
,
_session
.
get_device
()
->
dev_inst
()
->
mode
);
}
}
}
...
...
DSView/pv/view/analogsignal.cpp
View file @
800f4c61
...
...
@@ -137,8 +137,7 @@ void AnalogSignal::paint_trace(QPainter &p,
//p.setPen(QPen(_colour, 2, Qt::SolidLine));
QPointF
*
points
=
new
QPointF
[
sample_count
];
QPointF
*
point
=
points
;
QPointF
*
point
=
points
;
for
(
int64_t
sample
=
start
;
sample
!=
end
;
sample
++
)
{
const
float
x
=
(
sample
/
samples_per_pixel
-
pixels_offset
)
+
left
;
...
...
@@ -147,7 +146,6 @@ void AnalogSignal::paint_trace(QPainter &p,
}
p
.
drawPolyline
(
points
,
point
-
points
);
//delete[] samples;
delete
[]
points
;
}
...
...
DSView/pv/view/dsosignal.cpp
View file @
800f4c61
...
...
@@ -120,8 +120,6 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
//_trig_vpos(probe->index * 0.5 + 0.25),
//_zeroPos(probe->index * 0.5 + 0.25)
_trig_vpos
(
0.5
),
_zeroPos
(
0.5
),
_zero_off
(
255
/
2.0
),
_autoV
(
false
),
_autoH
(
false
),
_hover_en
(
false
),
...
...
@@ -495,6 +493,19 @@ bool DsoSignal::load_settings()
_dev_inst
->
set_config
(
_probe
,
NULL
,
SR_CONF_COUPLING
,
g_variant_new_byte
(
_acCoupling
));
// -- vpos
double
vpos
;
gvar
=
_dev_inst
->
get_config
(
_probe
,
NULL
,
SR_CONF_VPOS
);
if
(
gvar
!=
NULL
)
{
vpos
=
g_variant_get_double
(
gvar
);
g_variant_unref
(
gvar
);
}
else
{
qDebug
()
<<
"ERROR: config_get SR_CONF_COUPLING failed."
;
return
false
;
}
_zeroPos
=
min
(
max
((
0.5
-
vpos
/
(
_vDial
->
get_value
()
*
DS_CONF_DSO_VDIVS
)),
0.0
),
1.0
);
_zero_off
=
_zeroPos
*
255
;
if
(
_view
)
{
_view
->
set_need_update
(
true
);
_view
->
update
();
...
...
@@ -657,6 +668,7 @@ uint64_t DsoSignal::get_factor()
void
DsoSignal
::
set_ms_show
(
bool
show
)
{
_ms_show
=
show
;
_view
->
set_need_update
(
true
);
}
bool
DsoSignal
::
get_ms_show
()
const
...
...
@@ -1093,7 +1105,12 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
const
QRectF
x10_rect
=
get_rect
(
DSO_X10
,
y
,
right
);
const
QRectF
x100_rect
=
get_rect
(
DSO_X100
,
y
,
right
);
if
(
enabled
())
{
if
(
chEn_rect
.
contains
(
pt
))
{
if
(
strcmp
(
_dev_inst
->
dev_inst
()
->
driver
->
name
,
"virtual-session"
)
&&
!
_view
->
session
().
get_data_lock
())
set_enable
(
!
enabled
());
return
true
;
}
else
if
(
enabled
())
{
if
(
vDec_rect
.
contains
(
pt
))
{
go_vDialPre
();
}
else
if
(
vInc_rect
.
contains
(
pt
))
{
...
...
@@ -1114,10 +1131,8 @@ bool DsoSignal::mouse_press(int right, const QPoint pt)
setted
=
true
;
}
}
}
else
if
(
chEn_rect
.
contains
(
pt
))
{
if
(
!
_view
->
session
().
get_data_lock
())
set_enable
(
!
enabled
());
}
else
if
(
acdc_rect
.
contains
(
pt
))
{
}
else
if
(
strcmp
(
_dev_inst
->
dev_inst
()
->
driver
->
name
,
"virtual-session"
)
&&
acdc_rect
.
contains
(
pt
))
{
if
(
strcmp
(
_view
->
session
().
get_device
()
->
dev_inst
()
->
driver
->
name
,
"DSLogic"
)
==
0
)
set_acCoupling
((
get_acCoupling
()
+
1
)
%
2
);
else
...
...
@@ -1284,6 +1299,14 @@ void DsoSignal::paint_measure(QPainter &p)
_ms_string
[
DSO_MS_VMEA
]
=
"Vmean: "
+
(
abs
(
value_vmean
)
>
1000
?
QString
::
number
(
value_vmean
/
1000.0
,
'f'
,
2
)
+
"V"
:
QString
::
number
(
value_vmean
,
'f'
,
2
)
+
"mV"
);
}
}
}
else
{
_ms_string
[
DSO_MS_VMAX
]
=
"Vmax: #####"
;
_ms_string
[
DSO_MS_VMIN
]
=
"Vmin: #####"
;
_ms_string
[
DSO_MS_PERD
]
=
"Perd: #####"
;
_ms_string
[
DSO_MS_FREQ
]
=
"Freq: #####"
;
_ms_string
[
DSO_MS_VP2P
]
=
"Vp-p: #####"
;
_ms_string
[
DSO_MS_VRMS
]
=
"Vrms: #####"
;
_ms_string
[
DSO_MS_VMEA
]
=
"Vmean: #####"
;
}
QColor
measure_colour
=
_colour
;
...
...
DSView/pv/view/logicsignal.cpp
View file @
800f4c61
...
...
@@ -105,6 +105,11 @@ boost::shared_ptr<pv::data::Logic> LogicSignal::logic_data() const
return
_data
;
}
bool
LogicSignal
::
has_trig
()
const
{
return
(
_trig
!=
NONTRIG
);
}
LogicSignal
::
LogicSetRegions
LogicSignal
::
get_trig
()
const
{
return
_trig
;
...
...
DSView/pv/view/logicsignal.h
View file @
800f4c61
...
...
@@ -54,7 +54,7 @@ private:
static
const
int
StateRound
;
enum
LogicSetRegions
{
NONTRIG
=
-
1
,
NONTRIG
=
0
,
POSTRIG
,
HIGTRIG
,
NEGTRIG
,
...
...
@@ -82,6 +82,7 @@ public:
/**
*
*/
bool
has_trig
()
const
;
LogicSetRegions
get_trig
()
const
;
void
set_trig
(
int
trig
);
...
...
DSView/pv/view/view.cpp
View file @
800f4c61
...
...
@@ -226,8 +226,11 @@ void View::zoom(double steps, int offset)
}
}
}
_offset
=
cursor_offset
-
_scale
*
offset
;
_offset
=
max
(
min
(
_offset
,
get_max_offset
()),
get_min_offset
());
if
(
_session
.
get_device
()
->
dev_inst
()
->
mode
!=
DSO
)
{
_offset
=
cursor_offset
-
_scale
*
offset
;
_offset
=
max
(
min
(
_offset
,
get_max_offset
()),
get_min_offset
());
}
if
(
_scale
!=
_preScale
||
_offset
!=
_preOffset
)
{
_header
->
update
();
...
...
libsigrok4DSL/hardware/DSL/dscope.c
View file @
800f4c61
...
...
@@ -1485,10 +1485,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
ret
=
command_dso_ctrl
(
usb
->
devhdl
,
dso_cmd_gen
(
sdi
,
ch
,
SR_CONF_VPOS
));
}
if
(
ret
==
SR_OK
)
sr_dbg
(
"%s: setting VPOS of channel %d to %
d
mv"
,
sr_dbg
(
"%s: setting VPOS of channel %d to %
lf
mv"
,
__func__
,
ch
->
index
,
ch
->
vpos
);
else
sr_dbg
(
"%s: setting VPOS of channel %d to %
d
mv failed"
,
sr_dbg
(
"%s: setting VPOS of channel %d to %
lf
mv failed"
,
__func__
,
ch
->
index
,
ch
->
vpos
);
}
else
if
(
id
==
SR_CONF_TIMEBASE
)
{
devc
->
timebase
=
g_variant_get_uint64
(
data
);
...
...
libsigrok4DSL/hardware/DSL/dslogic.c
View file @
800f4c61
This diff is collapsed.
Click to expand it.
libsigrok4DSL/hardware/demo/demo.c
View file @
800f4c61
This diff is collapsed.
Click to expand it.
libsigrok4DSL/libsigrok.h
View file @
800f4c61
...
...
@@ -753,6 +753,12 @@ enum {
SR_CONF_ZERO
,
SR_CONF_ZERO_OVER
,
/** status for dso channel */
SR_CONF_STATUS_PERIOD
,
SR_CONF_STATUS_PCNT
,
SR_CONF_STATUS_MAX
,
SR_CONF_STATUS_MIN
,
/** Stream */
SR_CONF_STREAM
,
...
...
libsigrok4DSL/session_driver.c
View file @
800f4c61
...
...
@@ -54,6 +54,8 @@ struct session_vdev {
uint64_t
total_samples
;
int
unitsize
;
int
num_probes
;
uint64_t
timebase
;
struct
sr_status
mstatus
;
};
static
GSList
*
dev_insts
=
NULL
;
...
...
@@ -69,6 +71,8 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *cb_sdi)
struct
session_vdev
*
vdev
;
struct
sr_datafeed_packet
packet
;
struct
sr_datafeed_logic
logic
;
struct
sr_datafeed_dso
dso
;
struct
sr_datafeed_analog
analog
;
GSList
*
l
;
int
ret
,
got_data
;
(
void
)
fd
;
...
...
@@ -87,11 +91,31 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *cb_sdi)
ret
=
zip_fread
(
vdev
->
capfile
,
vdev
->
buf
,
CHUNKSIZE
);
if
(
ret
>
0
)
{
got_data
=
TRUE
;
packet
.
type
=
SR_DF_LOGIC
;
packet
.
payload
=
&
logic
;
logic
.
length
=
ret
;
logic
.
unitsize
=
vdev
->
unitsize
;
logic
.
data
=
vdev
->
buf
;
if
(
sdi
->
mode
==
DSO
)
{
packet
.
type
=
SR_DF_DSO
;
packet
.
payload
=
&
dso
;
dso
.
num_samples
=
ret
/
vdev
->
unitsize
;
dso
.
data
=
vdev
->
buf
;
dso
.
probes
=
sdi
->
channels
;
dso
.
mq
=
SR_MQ_VOLTAGE
;
dso
.
unit
=
SR_UNIT_VOLT
;
dso
.
mqflags
=
SR_MQFLAG_AC
;
}
else
if
(
sdi
->
mode
==
ANALOG
){
packet
.
type
=
SR_DF_ANALOG
;
packet
.
payload
=
&
analog
;
analog
.
probes
=
sdi
->
channels
;
analog
.
num_samples
=
ret
/
vdev
->
unitsize
;
analog
.
mq
=
SR_MQ_VOLTAGE
;
analog
.
unit
=
SR_UNIT_VOLT
;
analog
.
mqflags
=
SR_MQFLAG_AC
;
analog
.
data
=
vdev
->
buf
;
}
else
{
packet
.
type
=
SR_DF_LOGIC
;
packet
.
payload
=
&
logic
;
logic
.
length
=
ret
;
logic
.
unitsize
=
vdev
->
unitsize
;
logic
.
data
=
vdev
->
buf
;
}
vdev
->
bytes_read
+=
ret
;
sr_session_send
(
cb_sdi
,
&
packet
);
}
else
{
...
...
@@ -166,7 +190,9 @@ static int dev_close(struct sr_dev_inst *sdi)
return
SR_OK
;
}
static
int
config_get
(
int
id
,
GVariant
**
data
,
const
struct
sr_dev_inst
*
sdi
)
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
session_vdev
*
vdev
;
...
...
@@ -185,14 +211,63 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
}
else
return
SR_ERR
;
break
;
default:
case
SR_CONF_TIMEBASE
:
if
(
sdi
)
{
vdev
=
sdi
->
priv
;
*
data
=
g_variant_new_uint64
(
vdev
->
timebase
);
}
else
return
SR_ERR
;
break
;
case
SR_CONF_EN_CH
:
if
(
sdi
&&
ch
)
{
*
data
=
g_variant_new_boolean
(
ch
->
enabled
);
}
else
return
SR_ERR
;
break
;
case
SR_CONF_COUPLING
:
if
(
sdi
&&
ch
)
{
*
data
=
g_variant_new_byte
(
ch
->
coupling
);
}
else
return
SR_ERR
;
break
;
case
SR_CONF_VDIV
:
if
(
sdi
&&
ch
)
{
*
data
=
g_variant_new_uint64
(
ch
->
vdiv
);
}
else
return
SR_ERR
;
break
;
case
SR_CONF_FACTOR
:
if
(
sdi
&&
ch
)
{
*
data
=
g_variant_new_uint64
(
ch
->
vfactor
);
}
else
return
SR_ERR
;
break
;
case
SR_CONF_VPOS
:
if
(
sdi
&&
ch
)
{
*
data
=
g_variant_new_double
(
ch
->
vpos
);
}
else
return
SR_ERR
;
break
;
case
SR_CONF_MAX_DSO_SAMPLERATE
:
if
(
!
sdi
)
return
SR_ERR
;
*
data
=
g_variant_new_uint64
(
vdev
->
samplerate
);
break
;
case
SR_CONF_MAX_DSO_SAMPLELIMITS
:
if
(
!
sdi
)
return
SR_ERR
;
*
data
=
g_variant_new_uint64
(
vdev
->
total_samples
);
break
;
default:
return
SR_ERR_ARG
;
}
return
SR_OK
;
}
static
int
config_set
(
int
id
,
GVariant
*
data
,
const
struct
sr_dev_inst
*
sdi
)
static
int
config_set
(
int
id
,
GVariant
*
data
,
const
struct
sr_dev_inst
*
sdi
,
struct
sr_channel
*
ch
,
const
struct
sr_channel_group
*
cg
)
{
struct
session_vdev
*
vdev
;
...
...
@@ -204,7 +279,11 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
samplerates
[
0
]
=
vdev
->
samplerate
;
sr_info
(
"Setting samplerate to %"
PRIu64
"."
,
vdev
->
samplerate
);
break
;
case
SR_CONF_SESSIONFILE
:
case
SR_CONF_TIMEBASE
:
vdev
->
timebase
=
g_variant_get_uint64
(
data
);
sr_info
(
"Setting timebase to %"
PRIu64
"."
,
vdev
->
timebase
);
break
;
case
SR_CONF_SESSIONFILE
:
vdev
->
sessionfile
=
g_strdup
(
g_variant_get_bytestring
(
data
));
sr_info
(
"Setting sessionfile to '%s'."
,
vdev
->
sessionfile
);
break
;
...
...
@@ -223,7 +302,46 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
case
SR_CONF_CAPTURE_NUM_PROBES
:
vdev
->
num_probes
=
g_variant_get_uint64
(
data
);
break
;
default:
case
SR_CONF_EN_CH
:
ch
->
enabled
=
g_variant_get_boolean
(
data
);
break
;
case
SR_CONF_COUPLING
:
ch
->
coupling
=
g_variant_get_byte
(
data
);
break
;
case
SR_CONF_VDIV
:
ch
->
vdiv
=
g_variant_get_uint64
(
data
);
break
;
case
SR_CONF_FACTOR
:
ch
->
vfactor
=
g_variant_get_uint64
(
data
);
break
;
case
SR_CONF_VPOS
:
ch
->
vpos
=
g_variant_get_double
(
data
);
break
;
case
SR_CONF_STATUS_PERIOD
:
if
(
ch
->
index
==
0
)
vdev
->
mstatus
.
ch0_period
=
g_variant_get_uint64
(
data
);
else
vdev
->
mstatus
.
ch1_period
=
g_variant_get_uint64
(
data
);
break
;
case
SR_CONF_STATUS_PCNT
:
if
(
ch
->
index
==
0
)
vdev
->
mstatus
.
ch0_pcnt
=
g_variant_get_uint64
(
data
);
else
vdev
->
mstatus
.
ch1_pcnt
=
g_variant_get_uint64
(
data
);
break
;
case
SR_CONF_STATUS_MAX
:
if
(
ch
->
index
==
0
)
vdev
->
mstatus
.
ch0_max
=
g_variant_get_uint64
(
data
);
else
vdev
->
mstatus
.
ch1_max
=
g_variant_get_uint64
(
data
);
break
;
case
SR_CONF_STATUS_MIN
:
if
(
ch
->
index
==
0
)
vdev
->
mstatus
.
ch0_min
=
g_variant_get_uint64
(
data
);
else
vdev
->
mstatus
.
ch1_min
=
g_variant_get_uint64
(
data
);
break
;
default:
sr_err
(
"Unknown capability: %d."
,
id
);
return
SR_ERR
;
}
...
...
@@ -268,6 +386,22 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
return
SR_OK
;
}
static
int
dev_status_get
(
struct
sr_dev_inst
*
sdi
,
struct
sr_status
*
status
,
int
begin
,
int
end
)
{
(
void
)
begin
;
(
void
)
end
;
struct
session_vdev
*
vdev
;
if
(
sdi
)
{
vdev
=
sdi
->
priv
;
*
status
=
vdev
->
mstatus
;
return
SR_OK
;
}
else
{
return
SR_ERR
;
}
}
static
int
dev_acquisition_start
(
const
struct
sr_dev_inst
*
sdi
,
void
*
cb_data
)
{
...
...
@@ -324,7 +458,7 @@ SR_PRIV struct sr_dev_driver session_driver = {
.
dev_open
=
dev_open
,
.
dev_close
=
dev_close
,
.
dev_test
=
NULL
,
.
dev_status_get
=
NULL
,
.
dev_status_get
=
dev_status_get
,
.
dev_acquisition_start
=
dev_acquisition_start
,
.
dev_acquisition_stop
=
NULL
,
.
priv
=
NULL
,
...
...
libsigrok4DSL/session_file.c
View file @
800f4c61
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment