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
a2a326f0
Commit
a2a326f0
authored
May 16, 2018
by
DreamSourceLab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file save/load and export support for DAQ mode
Fix file save/load and export issue
parent
fd7c9cd1
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
362 additions
and
92 deletions
+362
-92
DSView/pv/data/analogsnapshot.cpp
DSView/pv/data/analogsnapshot.cpp
+35
-8
DSView/pv/data/analogsnapshot.h
DSView/pv/data/analogsnapshot.h
+8
-4
DSView/pv/data/dsosnapshot.cpp
DSView/pv/data/dsosnapshot.cpp
+22
-0
DSView/pv/data/dsosnapshot.h
DSView/pv/data/dsosnapshot.h
+6
-0
DSView/pv/data/logicsnapshot.h
DSView/pv/data/logicsnapshot.h
+4
-3
DSView/pv/data/snapshot.cpp
DSView/pv/data/snapshot.cpp
+7
-0
DSView/pv/data/snapshot.h
DSView/pv/data/snapshot.h
+6
-0
DSView/pv/dialogs/storeprogress.cpp
DSView/pv/dialogs/storeprogress.cpp
+1
-1
DSView/pv/storesession.cpp
DSView/pv/storesession.cpp
+126
-33
libsigrok4DSL/hardware/DSL/dscope.c
libsigrok4DSL/hardware/DSL/dscope.c
+0
-1
libsigrok4DSL/hardware/DSL/dsl.c
libsigrok4DSL/hardware/DSL/dsl.c
+1
-1
libsigrok4DSL/hardware/demo/demo.c
libsigrok4DSL/hardware/demo/demo.c
+1
-2
libsigrok4DSL/hwdriver.c
libsigrok4DSL/hwdriver.c
+2
-2
libsigrok4DSL/libsigrok-internal.h
libsigrok4DSL/libsigrok-internal.h
+0
-2
libsigrok4DSL/libsigrok.h
libsigrok4DSL/libsigrok.h
+1
-1
libsigrok4DSL/output/csv.c
libsigrok4DSL/output/csv.c
+58
-24
libsigrok4DSL/proto.h
libsigrok4DSL/proto.h
+2
-0
libsigrok4DSL/session_driver.c
libsigrok4DSL/session_driver.c
+57
-10
libsigrok4DSL/session_file.c
libsigrok4DSL/session_file.c
+25
-0
No files found.
DSView/pv/data/analogsnapshot.cpp
View file @
a2a326f0
...
...
@@ -46,11 +46,10 @@ const float AnalogSnapshot::LogEnvelopeScaleFactor =
const
uint64_t
AnalogSnapshot
::
EnvelopeDataUnit
=
64
*
1024
;
// bytes
AnalogSnapshot
::
AnalogSnapshot
()
:
Snapshot
(
sizeof
(
uint16_t
),
1
,
1
),
_unit_bytes
(
1
),
_unit_pitch
(
0
)
Snapshot
(
sizeof
(
uint16_t
),
1
,
1
)
{
memset
(
_envelope_levels
,
0
,
sizeof
(
_envelope_levels
));
_unit_pitch
=
0
;
}
AnalogSnapshot
::~
AnalogSnapshot
()
...
...
@@ -150,7 +149,9 @@ void AnalogSnapshot::first_payload(const sr_datafeed_analog &analog, uint64_t to
for
(
const
GSList
*
l
=
channels
;
l
;
l
=
l
->
next
)
{
sr_channel
*
const
probe
=
(
sr_channel
*
)
l
->
data
;
assert
(
probe
);
if
(
probe
->
type
==
SR_CHANNEL_ANALOG
&&
probe
->
enabled
)
{
// TODO: data of disabled channels should not be captured.
//if (probe->type == SR_CHANNEL_ANALOG && probe->enabled) {
if
(
probe
->
type
==
SR_CHANNEL_ANALOG
)
{
_ch_index
.
push_back
(
probe
->
index
);
}
}
...
...
@@ -369,14 +370,40 @@ int AnalogSnapshot::get_ch_order(int sig_index)
return
order
;
}
uint8_t
AnalogSnapshot
::
get_unit_bytes
()
const
int
AnalogSnapshot
::
get_scale_factor
()
const
{
return
_unit_bytes
;
return
EnvelopeScaleFactor
;
}
int
AnalogSnapshot
::
get_scale_factor
()
const
bool
AnalogSnapshot
::
has_data
(
int
index
)
{
return
EnvelopeScaleFactor
;
for
(
auto
&
iter
:
_ch_index
)
{
if
(
iter
==
index
)
return
true
;
}
return
false
;
}
int
AnalogSnapshot
::
get_block_num
()
{
const
uint64_t
size
=
_sample_count
*
get_unit_bytes
()
*
get_channel_num
();
return
(
size
>>
LeafBlockPower
)
+
((
size
&
LeafMask
)
!=
0
);
}
uint64_t
AnalogSnapshot
::
get_block_size
(
int
block_index
)
{
assert
(
block_index
<
get_block_num
());
if
(
block_index
<
get_block_num
()
-
1
)
{
return
LeafBlockSamples
;
}
else
{
const
uint64_t
size
=
_sample_count
*
get_unit_bytes
()
*
get_channel_num
();
if
(
size
%
LeafBlockSamples
==
0
)
return
LeafBlockSamples
;
else
return
size
%
LeafBlockSamples
;
}
}
}
// namespace data
...
...
DSView/pv/data/analogsnapshot.h
View file @
a2a326f0
...
...
@@ -77,6 +77,10 @@ private:
static
const
float
LogEnvelopeScaleFactor
;
static
const
uint64_t
EnvelopeDataUnit
;
static
const
uint64_t
LeafBlockPower
=
21
;
static
const
uint64_t
LeafBlockSamples
=
1
<<
LeafBlockPower
;
static
const
uint64_t
LeafMask
=
~
(
~
0ULL
<<
LeafBlockPower
);
public:
AnalogSnapshot
();
...
...
@@ -97,10 +101,12 @@ public:
int
get_ch_order
(
int
sig_index
);
uint8_t
get_unit_bytes
()
const
;
int
get_scale_factor
()
const
;
bool
has_data
(
int
index
);
int
get_block_num
();
uint64_t
get_block_size
(
int
block_index
);
private:
void
append_data
(
void
*
data
,
uint64_t
samples
,
uint16_t
pitch
);
void
free_envelop
();
...
...
@@ -111,8 +117,6 @@ private:
private:
struct
Envelope
_envelope_levels
[
DS_MAX_ANALOG_PROBES_NUM
][
ScaleStepCount
];
uint8_t
_unit_bytes
;
uint16_t
_unit_pitch
;
friend
class
AnalogSnapshotTest
::
Basic
;
};
...
...
DSView/pv/data/dsosnapshot.cpp
View file @
a2a326f0
...
...
@@ -415,5 +415,27 @@ bool DsoSnapshot::has_data(int index)
return
false
;
}
int
DsoSnapshot
::
get_block_num
()
{
const
uint64_t
size
=
_sample_count
*
get_unit_bytes
()
*
get_channel_num
();
return
(
size
>>
LeafBlockPower
)
+
((
size
&
LeafMask
)
!=
0
);
}
uint64_t
DsoSnapshot
::
get_block_size
(
int
block_index
)
{
assert
(
block_index
<
get_block_num
());
if
(
block_index
<
get_block_num
()
-
1
)
{
return
LeafBlockSamples
;
}
else
{
const
uint64_t
size
=
_sample_count
*
get_unit_bytes
()
*
get_channel_num
();
if
(
size
%
LeafBlockSamples
==
0
)
return
LeafBlockSamples
;
else
return
size
%
LeafBlockSamples
;
}
}
}
// namespace data
}
// namespace pv
DSView/pv/data/dsosnapshot.h
View file @
a2a326f0
...
...
@@ -68,6 +68,10 @@ private:
static
const
float
LogEnvelopeScaleFactor
;
static
const
uint64_t
EnvelopeDataUnit
;
static
const
uint64_t
LeafBlockPower
=
21
;
static
const
uint64_t
LeafBlockSamples
=
1
<<
LeafBlockPower
;
static
const
uint64_t
LeafMask
=
~
(
~
0ULL
<<
LeafBlockPower
);
static
const
int
VrmsScaleFactor
;
public:
...
...
@@ -94,6 +98,8 @@ public:
double
cal_vmean
(
int
index
)
const
;
bool
has_data
(
int
index
);
int
get_block_num
();
uint64_t
get_block_size
(
int
block_index
);
private:
void
append_data
(
void
*
data
,
uint64_t
samples
,
bool
instant
);
...
...
DSView/pv/data/logicsnapshot.h
View file @
a2a326f0
...
...
@@ -55,12 +55,13 @@ private:
static
const
uint64_t
RootScale
=
1
<<
RootScalePower
;
static
const
uint64_t
LeafBlockSpace
=
(
Scale
+
Scale
*
Scale
+
Scale
*
Scale
*
Scale
+
Scale
*
Scale
*
Scale
*
Scale
)
/
8
;
static
const
uint64_t
LeafBlockSamples
=
1
<<
ScaleLevel
*
ScalePower
;
static
const
uint64_t
LeafBlockPower
=
ScaleLevel
*
ScalePower
;
static
const
uint64_t
LeafBlockSamples
=
1
<<
LeafBlockPower
;
static
const
uint64_t
RootNodeSamples
=
LeafBlockSamples
*
RootScale
;
static
const
uint64_t
RootMask
=
~
(
~
0ULL
<<
RootScalePower
)
<<
ScaleLevel
*
Scale
Power
;
static
const
uint64_t
LeafMask
=
~
(
~
0ULL
<<
ScaleLevel
*
Scale
Power
);
static
const
uint64_t
RootMask
=
~
(
~
0ULL
<<
RootScalePower
)
<<
LeafBlock
Power
;
static
const
uint64_t
LeafMask
=
~
(
~
0ULL
<<
LeafBlock
Power
);
static
const
uint64_t
LevelMask
[
ScaleLevel
];
static
const
uint64_t
LevelOffset
[
ScaleLevel
];
...
...
DSView/pv/data/snapshot.cpp
View file @
a2a326f0
...
...
@@ -46,6 +46,8 @@ Snapshot::Snapshot(int unit_size, uint64_t total_sample_count, unsigned int chan
_last_ended
(
true
)
{
assert
(
_unit_size
>
0
);
_unit_bytes
=
1
;
_unit_pitch
=
0
;
}
Snapshot
::~
Snapshot
()
...
...
@@ -123,6 +125,11 @@ int Snapshot::unit_size() const
return
_unit_size
;
}
uint8_t
Snapshot
::
get_unit_bytes
()
const
{
return
_unit_bytes
;
}
unsigned
int
Snapshot
::
get_channel_num
()
const
{
return
_channel_num
;
...
...
DSView/pv/data/snapshot.h
View file @
a2a326f0
...
...
@@ -45,6 +45,7 @@ public:
const
void
*
get_data
()
const
;
int
unit_size
()
const
;
uint8_t
get_unit_bytes
()
const
;
bool
memory_failed
()
const
;
bool
empty
()
const
;
...
...
@@ -55,6 +56,9 @@ public:
unsigned
int
get_channel_num
()
const
;
virtual
void
capture_ended
();
virtual
bool
has_data
(
int
index
)
=
0
;
virtual
int
get_block_num
()
=
0
;
virtual
uint64_t
get_block_size
(
int
block_index
)
=
0
;
protected:
virtual
void
free_data
();
...
...
@@ -72,6 +76,8 @@ protected:
uint64_t
_total_sample_count
;
uint64_t
_ring_sample_count
;
int
_unit_size
;
uint8_t
_unit_bytes
;
uint16_t
_unit_pitch
;
bool
_memory_failed
;
bool
_last_ended
;
};
...
...
DSView/pv/dialogs/storeprogress.cpp
View file @
a2a326f0
...
...
@@ -39,7 +39,7 @@ StoreProgress::StoreProgress(SigSession &session, QWidget *parent) :
_progress
.
setValue
(
0
);
_progress
.
setMaximum
(
100
);
QVBoxLayout
*
add_layout
=
new
QVBoxLayout
(
this
);
QVBoxLayout
*
add_layout
=
new
QVBoxLayout
();
add_layout
->
addWidget
(
&
_info
,
0
,
Qt
::
AlignCenter
);
add_layout
->
addWidget
(
&
_progress
);
add_layout
->
addWidget
(
&
_button_box
);
...
...
DSView/pv/storesession.cpp
View file @
a2a326f0
This diff is collapsed.
Click to expand it.
libsigrok4DSL/hardware/DSL/dscope.c
View file @
a2a326f0
...
...
@@ -123,7 +123,6 @@ static const char *probeMapUnits[] = {
"g"
,
"m"
,
"m/s"
,
"Custom"
,
};
static
const
uint64_t
samplerates
[]
=
{
...
...
libsigrok4DSL/hardware/DSL/dsl.c
View file @
a2a326f0
...
...
@@ -1342,7 +1342,7 @@ static void receive_transfer(struct libusb_transfer *transfer)
analog
.
mq
=
SR_MQ_VOLTAGE
;
analog
.
unit
=
SR_UNIT_VOLT
;
analog
.
mqflags
=
SR_MQFLAG_AC
;
analog
.
data
=
(
float
*
)
cur_buf
;
analog
.
data
=
cur_buf
;
}
if
((
devc
->
limit_samples
&&
devc
->
num_bytes
<
devc
->
actual_bytes
)
||
...
...
libsigrok4DSL/hardware/demo/demo.c
View file @
a2a326f0
...
...
@@ -187,7 +187,6 @@ static const char *probeMapUnits[] = {
"g"
,
"m"
,
"m/s"
,
"Custom"
,
};
static
const
int
const_dc
=
1
.
95
/
10
*
255
;
...
...
@@ -1162,7 +1161,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
analog
.
mq
=
SR_MQ_VOLTAGE
;
analog
.
unit
=
SR_UNIT_VOLT
;
analog
.
mqflags
=
SR_MQFLAG_AC
;
analog
.
data
=
(
float
*
)
devc
->
buf
;
analog
.
data
=
devc
->
buf
;
}
if
(
sdi
->
mode
==
DSO
&&
!
devc
->
instant
)
{
...
...
libsigrok4DSL/hwdriver.c
View file @
a2a326f0
...
...
@@ -252,7 +252,7 @@ SR_PRIV void sr_hw_cleanup_all(void)
}
/** A floating reference can be passed in for data. */
SR_
PRIV
struct
sr_config
*
sr_config_new
(
int
key
,
GVariant
*
data
)
SR_
API
struct
sr_config
*
sr_config_new
(
int
key
,
GVariant
*
data
)
{
struct
sr_config
*
src
;
...
...
@@ -264,7 +264,7 @@ SR_PRIV struct sr_config *sr_config_new(int key, GVariant *data)
return
src
;
}
SR_
PRIV
void
sr_config_free
(
struct
sr_config
*
src
)
SR_
API
void
sr_config_free
(
struct
sr_config
*
src
)
{
if
(
!
src
||
!
src
->
data
)
{
...
...
libsigrok4DSL/libsigrok-internal.h
View file @
a2a326f0
...
...
@@ -109,8 +109,6 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial);
/*--- hwdriver.c ------------------------------------------------------------*/
SR_PRIV
void
sr_hw_cleanup_all
(
void
);
SR_PRIV
struct
sr_config
*
sr_config_new
(
int
key
,
GVariant
*
data
);
SR_PRIV
void
sr_config_free
(
struct
sr_config
*
src
);
SR_PRIV
int
sr_source_remove
(
int
fd
);
SR_PRIV
int
sr_source_add
(
int
fd
,
int
events
,
int
timeout
,
sr_receive_data_callback_t
cb
,
void
*
cb_data
);
...
...
libsigrok4DSL/libsigrok.h
View file @
a2a326f0
...
...
@@ -379,7 +379,7 @@ struct sr_datafeed_analog {
uint64_t
mqflags
;
/** The analog value(s). The data is interleaved according to
* the probes list. */
float
*
data
;
void
*
data
;
};
/** Input (file) format struct. */
...
...
libsigrok4DSL/output/csv.c
View file @
a2a326f0
...
...
@@ -30,11 +30,14 @@
struct
context
{
unsigned
int
num_enabled_channels
;
uint64_t
samplerate
;
uint64_t
limit_samples
;
char
separator
;
gboolean
header_done
;
int
*
channel_index
;
float
*
channel_vdiv
;
double
*
channel_vpos
;
double
*
channel_mmin
;
double
*
channel_mmax
;
uint64_t
timebase
;
uint64_t
mask
;
uint64_t
pre_data
;
...
...
@@ -84,6 +87,8 @@ static int init(struct sr_output *o, GHashTable *options)
ctx
->
channel_index
=
g_malloc
(
sizeof
(
int
)
*
ctx
->
num_enabled_channels
);
ctx
->
channel_vdiv
=
g_malloc
(
sizeof
(
float
)
*
ctx
->
num_enabled_channels
);
ctx
->
channel_vpos
=
g_malloc
(
sizeof
(
double
)
*
ctx
->
num_enabled_channels
);
ctx
->
channel_mmax
=
g_malloc
(
sizeof
(
double
)
*
ctx
->
num_enabled_channels
);
ctx
->
channel_mmin
=
g_malloc
(
sizeof
(
double
)
*
ctx
->
num_enabled_channels
);
/* Once more to map the enabled channels. */
for
(
i
=
0
,
l
=
o
->
sdi
->
channels
;
l
;
l
=
l
->
next
)
{
...
...
@@ -97,6 +102,8 @@ static int init(struct sr_output *o, GHashTable *options)
ctx
->
mask
|=
(
1
<<
i
);
ctx
->
channel_vdiv
[
i
]
=
ch
->
vdiv
*
ch
->
vfactor
>=
500
?
ch
->
vdiv
*
ch
->
vfactor
/
100
.
0
f
:
ch
->
vdiv
*
ch
->
vfactor
*
10
.
0
f
;
ctx
->
channel_vpos
[
i
]
=
ch
->
vdiv
*
ch
->
vfactor
>=
500
?
ch
->
vpos
/
1000
:
ch
->
vpos
;
ctx
->
channel_mmax
[
i
]
=
ch
->
map_max
;
ctx
->
channel_mmin
[
i
]
=
ch
->
map_min
;
i
++
;
}
...
...
@@ -107,7 +114,6 @@ static GString *gen_header(const struct sr_output *o)
{
struct
context
*
ctx
;
struct
sr_channel
*
ch
;
GVariant
*
gvar
;
GString
*
header
;
GSList
*
l
;
time_t
t
;
...
...
@@ -129,27 +135,28 @@ static GString *gen_header(const struct sr_output *o)
g_string_append_printf
(
header
,
"; Channels (%d/%d)
\n
"
,
ctx
->
num_enabled_channels
,
num_channels
);
if
(
ctx
->
samplerate
==
0
)
{
if
(
sr_config_get
(
o
->
sdi
->
driver
,
o
->
sdi
,
NULL
,
NULL
,
SR_CONF_SAMPLERATE
,
&
gvar
)
==
SR_OK
)
{
ctx
->
samplerate
=
g_variant_get_uint64
(
gvar
);
g_variant_unref
(
gvar
);
}
}
if
(
ctx
->
samplerate
!=
0
)
{
char
*
samplerate_s
=
sr_samplerate_string
(
ctx
->
samplerate
);
g_string_append_printf
(
header
,
"; Sample rate: %s
\n
"
,
samplerate_s
);
g_free
(
samplerate_s
);
}
// if (ctx->samplerate == 0) {
// if (sr_config_get(o->sdi->driver, o->sdi, NULL, NULL, SR_CONF_SAMPLERATE,
// &gvar) == SR_OK) {
// ctx->samplerate = g_variant_get_uint64(gvar);
// g_variant_unref(gvar);
// }
// }
char
*
samplerate_s
=
sr_samplerate_string
(
ctx
->
samplerate
);
g_string_append_printf
(
header
,
"; Sample rate: %s
\n
"
,
samplerate_s
);
g_free
(
samplerate_s
);
if
(
sr_config_get
(
o
->
sdi
->
driver
,
o
->
sdi
,
NULL
,
NULL
,
SR_CONF_LIMIT_SAMPLES
,
&
gvar
)
==
SR_OK
)
{
uint64_t
depth
=
g_variant_get_uint64
(
gvar
);
g_variant_unref
(
gvar
);
char
*
depth_s
=
sr_samplecount_string
(
depth
);
g_string_append_printf
(
header
,
"; Sample count: %s
\n
"
,
depth_s
);
g_free
(
depth_s
);
}
// if (sr_config_get(o->sdi->driver, o->sdi, NULL, NULL, SR_CONF_LIMIT_SAMPLES,
// &gvar) == SR_OK) {
// uint64_t depth = g_variant_get_uint64(gvar);
// g_variant_unref(gvar);
// char *depth_s = sr_samplecount_string(depth);
// g_string_append_printf(header, "; Sample count: %s\n", depth_s);
// g_free(depth_s);
// }
char
*
depth_s
=
sr_samplecount_string
(
ctx
->
limit_samples
);
g_string_append_printf
(
header
,
"; Sample count: %s
\n
"
,
depth_s
);
g_free
(
depth_s
);
if
(
ctx
->
type
==
SR_CHANNEL_LOGIC
)
g_string_append_printf
(
header
,
"Time(s),"
);
...
...
@@ -162,6 +169,8 @@ static GString *gen_header(const struct sr_output *o)
if
(
ctx
->
type
==
SR_CHANNEL_DSO
)
{
char
*
unit_s
=
(
ch
->
vdiv
*
ch
->
vfactor
)
>=
500
?
"V"
:
"mV"
;
g_string_append_printf
(
header
,
" %s (Unit: %s),"
,
ch
->
name
,
unit_s
);
}
else
if
(
ctx
->
type
==
SR_CHANNEL_ANALOG
)
{
g_string_append_printf
(
header
,
" %s (Unit: %s),"
,
ch
->
name
,
ch
->
map_unit
);
}
else
{
g_string_append_printf
(
header
,
" %s,"
,
ch
->
name
);
}
...
...
@@ -180,6 +189,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
const
struct
sr_datafeed_meta
*
meta
;
const
struct
sr_datafeed_logic
*
logic
;
const
struct
sr_datafeed_dso
*
dso
;
const
struct
sr_datafeed_analog
*
analog
;
const
struct
sr_config
*
src
;
GSList
*
l
;
struct
context
*
ctx
;
...
...
@@ -198,9 +208,10 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
meta
=
packet
->
payload
;
for
(
l
=
meta
->
config
;
l
;
l
=
l
->
next
)
{
src
=
l
->
data
;
if
(
src
->
key
!=
SR_CONF_SAMPLERATE
)
continue
;
ctx
->
samplerate
=
g_variant_get_uint64
(
src
->
data
);
if
(
src
->
key
==
SR_CONF_SAMPLERATE
)
ctx
->
samplerate
=
g_variant_get_uint64
(
src
->
data
);
else
if
(
src
->
key
==
SR_CONF_LIMIT_SAMPLES
)
ctx
->
limit_samples
=
g_variant_get_uint64
(
src
->
data
);
}
break
;
case
SR_DF_LOGIC
:
...
...
@@ -251,6 +262,29 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
g_string_append_printf
(
*
out
,
"
\n
"
);
}
break
;
case
SR_DF_ANALOG
:
analog
=
packet
->
payload
;
if
(
!
ctx
->
header_done
)
{
*
out
=
gen_header
(
o
);
ctx
->
header_done
=
TRUE
;
}
else
{
*
out
=
g_string_sized_new
(
512
);
}
for
(
i
=
0
;
i
<
(
uint64_t
)
analog
->
num_samples
;
i
++
)
{
for
(
j
=
0
;
j
<
ctx
->
num_enabled_channels
;
j
++
)
{
idx
=
ctx
->
channel_index
[
j
];
p
=
analog
->
data
+
i
*
ctx
->
num_enabled_channels
+
idx
*
((
ctx
->
num_enabled_channels
>
1
)
?
1
:
0
);
g_string_append_printf
(
*
out
,
"%0.2f"
,
ctx
->
channel_mmin
[
j
]
+
(
255
.
0
-
*
p
)
/
255
.
0
*
(
ctx
->
channel_mmax
[
j
]
-
ctx
->
channel_mmin
[
j
]));
g_string_append_c
(
*
out
,
ctx
->
separator
);
}
/* Drop last separator. */
g_string_truncate
(
*
out
,
(
*
out
)
->
len
-
1
);
g_string_append_printf
(
*
out
,
"
\n
"
);
}
break
;
}
return
SR_OK
;
...
...
libsigrok4DSL/proto.h
View file @
a2a326f0
...
...
@@ -80,6 +80,8 @@ SR_API int sr_config_list(const struct sr_dev_driver *driver,
SR_API
const
struct
sr_config_info
*
sr_config_info_get
(
int
key
);
SR_API
const
struct
sr_config_info
*
sr_config_info_name_get
(
const
char
*
optname
);
SR_API
int
sr_status_get
(
const
struct
sr_dev_inst
*
sdi
,
struct
sr_status
*
status
,
gboolean
prg
,
int
begin
,
int
end
);
SR_API
struct
sr_config
*
sr_config_new
(
int
key
,
GVariant
*
data
);
SR_API
void
sr_config_free
(
struct
sr_config
*
src
);
/*--- session.c -------------------------------------------------------------*/
...
...
libsigrok4DSL/session_driver.c
View file @
a2a326f0
...
...
@@ -88,6 +88,22 @@ static const int hwoptions[] = {
SR_CONF_MAX_HEIGHT
,
};
static
const
int32_t
probeOptions
[]
=
{
SR_CONF_PROBE_MAP_UNIT
,
SR_CONF_PROBE_MAP_MIN
,
SR_CONF_PROBE_MAP_MAX
,
};
static
const
char
*
probeMapUnits
[]
=
{
"V"
,
"A"
,
"°C"
,
"°F"
,
"g"
,
"m"
,
"m/s"
,
};
static
int
trans_data
(
struct
sr_dev_inst
*
sdi
)
{
// translate for old format
...
...
@@ -151,6 +167,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *cb_sdi)
/* already done with this instance */
continue
;
assert
(
vdev
->
unit_bits
>
0
);
assert
(
vdev
->
cur_channel
>=
0
);
if
(
vdev
->
cur_channel
<
vdev
->
num_probes
)
{
if
(
vdev
->
version
==
1
)
{
...
...
@@ -167,7 +184,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *cb_sdi)
(
probe
->
type
==
SR_CHANNEL_DSO
)
?
"O"
:
(
probe
->
type
==
SR_CHANNEL_ANALOG
)
?
"A"
:
"U"
;
snprintf
(
file_name
,
31
,
"%s-%d/%d"
,
type_name
,
probe
->
index
,
vdev
->
cur_block
);
sdi
->
mode
==
LOGIC
?
probe
->
index
:
0
,
vdev
->
cur_block
);
if
(
!
(
vdev
->
capfile
=
zip_fopen
(
vdev
->
archive
,
file_name
,
0
)))
{
sr_err
(
"Failed to open capture file '%s' in "
"session file '%s'."
,
file_name
,
vdev
->
sessionfile
);
...
...
@@ -191,7 +208,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *cb_sdi)
if
(
sdi
->
mode
==
DSO
)
{
packet
.
type
=
SR_DF_DSO
;
packet
.
payload
=
&
dso
;
dso
.
num_samples
=
ret
/
vdev
->
enabled
_probes
;
dso
.
num_samples
=
ret
/
vdev
->
num
_probes
;
dso
.
data
=
vdev
->
buf
;
dso
.
probes
=
sdi
->
channels
;
dso
.
mq
=
SR_MQ_VOLTAGE
;
...
...
@@ -201,7 +218,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *cb_sdi)
packet
.
type
=
SR_DF_ANALOG
;
packet
.
payload
=
&
analog
;
analog
.
probes
=
sdi
->
channels
;
analog
.
num_samples
=
ret
/
vdev
->
num_probes
;
analog
.
num_samples
=
ret
/
vdev
->
num_probes
/
((
vdev
->
unit_bits
+
7
)
/
8
)
;
analog
.
unit_bits
=
vdev
->
unit_bits
;
analog
.
mq
=
SR_MQ_VOLTAGE
;
analog
.
unit
=
SR_UNIT_VOLT
;
...
...
@@ -299,12 +316,7 @@ static int dev_open(struct sr_dev_inst *sdi)
vdev
->
cur_channel
=
0
;
vdev
->
file_opened
=
FALSE
;
vdev
->
num_blocks
=
0
;
if
(
sdi
->
mode
==
DSO
)
vdev
->
unit_bits
=
8
;
else
if
(
sdi
->
mode
==
ANALOG
)
vdev
->
unit_bits
=
16
;
else
vdev
->
unit_bits
=
1
;
vdev
->
unit_bits
=
1
;
vdev
->
max_height
=
0
;
dev_insts
=
g_slist_append
(
dev_insts
,
sdi
);
...
...
@@ -401,6 +413,21 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
}
else
return
SR_ERR
;
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
;
case
SR_CONF_TRIGGER_VALUE
:
if
(
sdi
&&
ch
)
{
*
data
=
g_variant_new_byte
(
ch
->
trig_value
);
...
...
@@ -534,6 +561,15 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
case
SR_CONF_PROBE_VPOS
:
ch
->
vpos
=
g_variant_get_double
(
data
);
break
;
case
SR_CONF_PROBE_MAP_UNIT
:
ch
->
map_unit
=
g_variant_get_string
(
data
,
NULL
);
break
;
case
SR_CONF_PROBE_MAP_MIN
:
ch
->
map_min
=
g_variant_get_double
(
data
);
break
;
case
SR_CONF_PROBE_MAP_MAX
:
ch
->
map_max
=
g_variant_get_double
(
data
);
break
;
case
SR_CONF_TRIGGER_VALUE
:
ch
->
trig_value
=
g_variant_get_byte
(
data
);
break
;
...
...
@@ -623,6 +659,14 @@ static int config_list(int key, GVariant **data,
case
SR_CONF_MAX_HEIGHT
:
*
data
=
g_variant_new_strv
(
maxHeights
,
ARRAY_SIZE
(
maxHeights
));
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_MAP_UNIT
:
*
data
=
g_variant_new_strv
(
probeMapUnits
,
ARRAY_SIZE
(
probeMapUnits
));
break
;
default:
return
SR_ERR_ARG
;
}
...
...
@@ -687,7 +731,10 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi,
vdev
->
file_opened
=
TRUE
;
vdev
->
cur_channel
=
vdev
->
num_probes
-
1
;
}
else
{
vdev
->
cur_channel
=
0
;
if
(
sdi
->
mode
==
LOGIC
)
vdev
->
cur_channel
=
0
;
else
vdev
->
cur_channel
=
vdev
->
num_probes
-
1
;
}
for
(
l
=
sdi
->
channels
;
l
;
l
=
l
->
next
)
{
...
...
libsigrok4DSL/session_file.c
View file @
a2a326f0
...
...
@@ -267,6 +267,8 @@ SR_API int sr_session_load(const char *filename)
probenum
=
strtoul
(
keys
[
j
]
+
7
,
NULL
,
10
);
sr_dev_trigger_set
(
sdi
,
probenum
,
val
);
}
else
if
(
!
strncmp
(
keys
[
j
],
"enable"
,
6
))
{
if
(
mode
!=
LOGIC
)
continue
;
probenum
=
strtoul
(
keys
[
j
]
+
6
,
NULL
,
10
);
tmp_u64
=
strtoull
(
val
,
NULL
,
10
);
if
(
probenum
<
g_slist_length
(
sdi
->
channels
))
{
...
...
@@ -346,6 +348,29 @@ SR_API int sr_session_load(const char *filename)
sdi
->
driver
->
config_set
(
SR_CONF_STATUS_MIN
,
g_variant_new_uint64
(
tmp_u64
),
sdi
,
probe
,
NULL
);
}
}
else
if
(
!
strncmp
(
keys
[
j
],
"mapUnit"
,
7
))
{
probenum
=
strtoul
(
keys
[
j
]
+
7
,
NULL
,
10
);
if
(
probenum
<
g_slist_length
(
sdi
->
channels
))
{
probe
=
g_slist_nth
(
sdi
->
channels
,
probenum
)
->
data
;
sdi
->
driver
->
config_set
(
SR_CONF_PROBE_MAP_UNIT
,
g_variant_new_string
(
val
),
sdi
,
probe
,
NULL
);
}
}
else
if
(
!
strncmp
(
keys
[
j
],
"mapMax"
,
6
))
{
probenum
=
strtoul
(
keys
[
j
]
+
6
,
NULL
,
10
);
tmp_double
=
strtod
(
val
,
NULL
);
if
(
probenum
<
g_slist_length
(
sdi
->
channels
))
{
probe
=
g_slist_nth
(
sdi
->
channels
,
probenum
)
->
data
;
sdi
->
driver
->
config_set
(
SR_CONF_PROBE_MAP_MAX
,
g_variant_new_double
(
tmp_double
),
sdi
,
probe
,
NULL
);
}
}
else
if
(
!
strncmp
(
keys
[
j
],
"mapMin"
,
6
))
{
probenum
=
strtoul
(
keys
[
j
]
+
6
,
NULL
,
10
);
tmp_double
=
strtod
(
val
,
NULL
);
if
(
probenum
<
g_slist_length
(
sdi
->
channels
))
{
probe
=
g_slist_nth
(
sdi
->
channels
,
probenum
)
->
data
;
sdi
->
driver
->
config_set
(
SR_CONF_PROBE_MAP_MIN
,
g_variant_new_double
(
tmp_double
),
sdi
,
probe
,
NULL
);
}
}
}
g_strfreev
(
keys
);
...
...
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