Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Raptor Engineering Public Development
dsview
Commits
ce357d97
Commit
ce357d97
authored
10 years ago
by
DreamSourceLab
Browse files
Options
Download
Email Patches
Plain Diff
v0.4 release
parent
99920715
Changes
50
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
0 additions
and
2185 deletions
+0
-2185
DSLogic-gui/cmake_modules/Findlibusb-1.0.cmake
DSLogic-gui/cmake_modules/Findlibusb-1.0.cmake
+0
-64
DSLogic-gui/icons/checkbox.png
DSLogic-gui/icons/checkbox.png
+0
-0
DSLogic-gui/icons/fullscreen.png
DSLogic-gui/icons/fullscreen.png
+0
-0
DSLogic-gui/icons/logo_muColor.png
DSLogic-gui/icons/logo_muColor.png
+0
-0
DSLogic-gui/icons/photo.png
DSLogic-gui/icons/photo.png
+0
-0
DSLogic-gui/icons/radiobutton.png
DSLogic-gui/icons/radiobutton.png
+0
-0
DSLogic-gui/icons/set.png
DSLogic-gui/icons/set.png
+0
-0
DSLogic-gui/icons/setting.png
DSLogic-gui/icons/setting.png
+0
-0
DSLogic-gui/pv/decoder/decoder.cpp
DSLogic-gui/pv/decoder/decoder.cpp
+0
-55
DSLogic-gui/pv/decoder/decoder.h
DSLogic-gui/pv/decoder/decoder.h
+0
-115
DSLogic-gui/pv/decoder/decoderfactory.cpp
DSLogic-gui/pv/decoder/decoderfactory.cpp
+0
-67
DSLogic-gui/pv/decoder/decoderfactory.h
DSLogic-gui/pv/decoder/decoderfactory.h
+0
-49
DSLogic-gui/pv/decoder/democonfig.cpp
DSLogic-gui/pv/decoder/democonfig.cpp
+0
-260
DSLogic-gui/pv/decoder/democonfig.h
DSLogic-gui/pv/decoder/democonfig.h
+0
-91
DSLogic-gui/pv/decoder/dmx512config.ui
DSLogic-gui/pv/decoder/dmx512config.ui
+0
-103
DSLogic-gui/pv/decoder/ds1wire.cpp
DSLogic-gui/pv/decoder/ds1wire.cpp
+0
-455
DSLogic-gui/pv/decoder/ds1wire.h
DSLogic-gui/pv/decoder/ds1wire.h
+0
-91
DSLogic-gui/pv/decoder/dsdmx512.cpp
DSLogic-gui/pv/decoder/dsdmx512.cpp
+0
-380
DSLogic-gui/pv/decoder/dsdmx512.h
DSLogic-gui/pv/decoder/dsdmx512.h
+0
-89
DSLogic-gui/pv/decoder/dsi2c.cpp
DSLogic-gui/pv/decoder/dsi2c.cpp
+0
-366
No files found.
DSLogic-gui/cmake_modules/Findlibusb-1.0.cmake
deleted
100644 → 0
View file @
99920715
#
# LIBUSB_1_FOUND - system has libusb
# LIBUSB_1_INCLUDE_DIRS - the libusb include directory
# LIBUSB_1_LIBRARIES - Link these to use libusb
# LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb
#
# Adapted from cmake-modules Google Code project
#
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
#
# (Changes for libusb) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if
(
LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS
)
# in cache already
set
(
LIBUSB_FOUND TRUE
)
else
(
LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS
)
find_path
(
LIBUSB_1_INCLUDE_DIR
NAMES
libusb-1.0/libusb.h
PATHS
/usr/local/include
PATH_SUFFIXES
libusb-1.0
)
find_library
(
LIBUSB_1_LIBRARY
NAMES
usb-1.0
PATHS
/usr/local/lib
)
set
(
LIBUSB_1_INCLUDE_DIRS
${
LIBUSB_1_INCLUDE_DIR
}
)
set
(
LIBUSB_1_LIBRARIES
${
LIBUSB_1_LIBRARY
}
)
if
(
LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES
)
set
(
LIBUSB_1_FOUND TRUE
)
endif
(
LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES
)
if
(
LIBUSB_1_FOUND
)
if
(
NOT libusb_1_FIND_QUIETLY
)
message
(
STATUS
"Found libusb-1.0:"
)
message
(
STATUS
" - Includes:
${
LIBUSB_1_INCLUDE_DIRS
}
"
)
message
(
STATUS
" - Libraries:
${
LIBUSB_1_LIBRARIES
}
"
)
endif
(
NOT libusb_1_FIND_QUIETLY
)
else
(
LIBUSB_1_FOUND
)
if
(
libusb_1_FIND_REQUIRED
)
message
(
FATAL_ERROR
"Could not find libusb"
)
endif
(
libusb_1_FIND_REQUIRED
)
endif
(
LIBUSB_1_FOUND
)
# show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
mark_as_advanced
(
LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES
)
endif
(
LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS
)
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/checkbox.png
deleted
100644 → 0
View file @
99920715
243 Bytes
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/fullscreen.png
deleted
100644 → 0
View file @
99920715
7.23 KB
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/logo_muColor.png
deleted
100644 → 0
View file @
99920715
488 Bytes
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/photo.png
deleted
100644 → 0
View file @
99920715
1017 Bytes
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/radiobutton.png
deleted
100644 → 0
View file @
99920715
241 Bytes
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/set.png
deleted
100644 → 0
View file @
99920715
1.7 KB
This diff is collapsed.
Click to expand it.
DSLogic-gui/icons/setting.png
deleted
100644 → 0
View file @
99920715
576 Bytes
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/decoder.cpp
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "decoder.h"
namespace
pv
{
namespace
decoder
{
Decoder
::
Decoder
(
boost
::
shared_ptr
<
pv
::
data
::
Logic
>
data
,
std
::
list
<
int
>
sel_probes
,
QMap
<
QString
,
int
>
options_index
)
:
_data
(
data
),
_sel_probes
(
sel_probes
),
_options_index
(
options_index
),
_total_state
(
0
),
_max_state_samples
(
0
)
{
}
std
::
list
<
int
>
Decoder
::
get_probes
()
{
return
_sel_probes
;
}
QMap
<
QString
,
int
>
Decoder
::
get_options_index
()
{
return
_options_index
;
}
void
Decoder
::
set_data
(
boost
::
shared_ptr
<
data
::
Logic
>
_logic_data
)
{
assert
(
_logic_data
);
_data
=
_logic_data
;
}
}
// namespace decoder
}
// namespace pv
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/decoder.h
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSLOGIC_PV_DECODER_H
#define DSLOGIC_PV_DECODER_H
#include <boost/shared_ptr.hpp>
#include <QColor>
#include <QMap>
#include <QVariant>
#include <stdint.h>
#include <vector>
namespace
pv
{
namespace
data
{
class
Logic
;
}
namespace
decoder
{
enum
{
DEC_CMD
=
0
,
DEC_DATA
=
1
,
DEC_CNT
=
2
,
DEC_NODETAIL
};
struct
ds_view_state
{
uint64_t
index
;
uint64_t
samples
;
uint16_t
type
;
uint8_t
state
;
uint8_t
data
;
};
enum
{
I2C
=
0
,
SPI
,
Serial
,
Dmx512
,
Wire1
};
static
QString
protocol_list
[]
=
{
"I2C"
,
"SPI"
,
"Serial"
,
"DMX512"
,
"1-Wire"
,
NULL
,
};
class
Decoder
{
protected:
static
const
int
_view_scale
=
8
;
Decoder
(
boost
::
shared_ptr
<
pv
::
data
::
Logic
>
data
,
std
::
list
<
int
>
sel_probes
,
QMap
<
QString
,
int
>
options_index
);
public:
std
::
list
<
int
>
get_probes
();
QMap
<
QString
,
int
>
get_options_index
();
void
set_data
(
boost
::
shared_ptr
<
data
::
Logic
>
_logic_data
);
public:
virtual
QString
get_decode_name
()
=
0
;
virtual
void
recode
(
std
::
list
<
int
>
sel_probes
,
QMap
<
QString
,
QVariant
>&
options
,
QMap
<
QString
,
int
>
options_index
)
=
0
;
virtual
void
decode
()
=
0
;
virtual
void
fill_color_table
(
std
::
vector
<
QColor
>&
_color_table
)
=
0
;
virtual
void
fill_state_table
(
std
::
vector
<
QString
>&
_state_table
)
=
0
;
virtual
void
get_subsampled_states
(
std
::
vector
<
struct
ds_view_state
>
&
states
,
uint64_t
start
,
uint64_t
end
,
float
min_length
)
=
0
;
private:
protected:
boost
::
shared_ptr
<
pv
::
data
::
Logic
>
_data
;
std
::
list
<
int
>
_sel_probes
;
QMap
<
QString
,
int
>
_options_index
;
uint64_t
_total_state
;
uint64_t
_max_state_samples
;
};
}
// namespace decoder
}
// namespace pv
#endif // DSLOGIC_PV_DECODER_H
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/decoderfactory.cpp
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "decoderfactory.h"
#include "dsi2c.h"
#include "dsspi.h"
#include "dsserial.h"
#include "dsdmx512.h"
#include "ds1wire.h"
namespace
pv
{
namespace
decoder
{
DecoderFactory
::
DecoderFactory
()
{
}
Decoder
*
DecoderFactory
::
createDecoder
(
int
type
,
boost
::
shared_ptr
<
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
)
{
Decoder
*
decoder
=
NULL
;
switch
(
type
)
{
case
I2C
:
decoder
=
new
dsI2c
(
data
,
_sel_probes
,
_options
,
_options_index
);
break
;
case
SPI
:
decoder
=
new
dsSpi
(
data
,
_sel_probes
,
_options
,
_options_index
);
break
;
case
Serial
:
decoder
=
new
dsSerial
(
data
,
_sel_probes
,
_options
,
_options_index
);
break
;
case
Dmx512
:
decoder
=
new
dsDmx512
(
data
,
_sel_probes
,
_options
,
_options_index
);
break
;
case
Wire1
:
decoder
=
new
ds1Wire
(
data
,
_sel_probes
,
_options
,
_options_index
);
break
;
default:
decoder
=
new
dsI2c
(
data
,
_sel_probes
,
_options
,
_options_index
);
}
return
decoder
;
}
}
// namespace decoder
}
// namespace pv
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/decoderfactory.h
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSLOGIC_PV_DECODERFACTORY_H
#define DSLOGIC_PV_DECODERFACTORY_H
#include "decoder.h"
#include <QMap>
#include <QVariant>
namespace
pv
{
namespace
decoder
{
class
DecoderFactory
{
public:
DecoderFactory
();
public:
Decoder
*
createDecoder
(
int
type
,
boost
::
shared_ptr
<
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
);
};
}
// namespace decoder
}
// namespace pv
#endif // DSLOGIC_PV_DECODERFACTORY_H
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/democonfig.cpp
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "democonfig.h"
#include "ui_i2cconfig.h"
#include "ui_spiconfig.h"
#include "ui_serialconfig.h"
#include "ui_dmx512config.h"
#include "ui_wire1config.h"
#include "decoder.h"
#include "../sigsession.h"
#include "../view/signal.h"
#include "../view/logicsignal.h"
#include <assert.h>
namespace
pv
{
namespace
decoder
{
DemoConfig
::
DemoConfig
(
QWidget
*
parent
,
struct
sr_dev_inst
*
sdi
,
int
protocol
)
:
QDialog
(
parent
),
_sdi
(
sdi
),
_protocol
(
protocol
)
{
assert
(
_sdi
);
i2c_ui
=
NULL
;
spi_ui
=
NULL
;
wire1_ui
=
NULL
;
serial_ui
=
NULL
;
dmx512_ui
=
NULL
;
if
(
_protocol
==
I2C
)
{
i2c_ui
=
new
Ui
::
I2cConfig
;
i2c_ui
->
setupUi
(
this
);
i2c_ui
->
setupUi
(
this
);
for
(
const
GSList
*
l
=
_sdi
->
probes
;
l
;
l
=
l
->
next
)
{
sr_probe
*
const
probe
=
(
sr_probe
*
)
l
->
data
;
assert
(
probe
);
i2c_ui
->
scl_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
i2c_ui
->
sda_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
}
i2c_ui
->
scl_comboBox
->
setCurrentIndex
(
0
);
i2c_ui
->
sda_comboBox
->
setCurrentIndex
(
1
);
}
else
if
(
_protocol
==
SPI
)
{
spi_ui
=
new
Ui
::
SpiConfig
;
spi_ui
->
setupUi
(
this
);
spi_ui
->
setupUi
(
this
);
for
(
const
GSList
*
l
=
_sdi
->
probes
;
l
;
l
=
l
->
next
)
{
sr_probe
*
const
probe
=
(
sr_probe
*
)
l
->
data
;
assert
(
probe
);
spi_ui
->
ssn_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
spi_ui
->
sclk_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
spi_ui
->
mosi_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
spi_ui
->
miso_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
}
spi_ui
->
ssn_comboBox
->
setCurrentIndex
(
0
);
spi_ui
->
sclk_comboBox
->
setCurrentIndex
(
1
);
spi_ui
->
mosi_comboBox
->
setCurrentIndex
(
2
);
spi_ui
->
miso_comboBox
->
setCurrentIndex
(
3
);
}
else
if
(
_protocol
==
Serial
)
{
serial_ui
=
new
Ui
::
SerialConfig
;
serial_ui
->
setupUi
(
this
);
serial_ui
->
setupUi
(
this
);
for
(
const
GSList
*
l
=
_sdi
->
probes
;
l
;
l
=
l
->
next
)
{
sr_probe
*
const
probe
=
(
sr_probe
*
)
l
->
data
;
assert
(
probe
);
serial_ui
->
serial_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
}
serial_ui
->
serial_comboBox
->
setCurrentIndex
(
0
);
}
else
if
(
_protocol
==
Dmx512
)
{
dmx512_ui
=
new
Ui
::
Dmx512Config
;
dmx512_ui
->
setupUi
(
this
);
dmx512_ui
->
setupUi
(
this
);
for
(
const
GSList
*
l
=
_sdi
->
probes
;
l
;
l
=
l
->
next
)
{
sr_probe
*
const
probe
=
(
sr_probe
*
)
l
->
data
;
assert
(
probe
);
dmx512_ui
->
probe_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
}
dmx512_ui
->
probe_comboBox
->
setCurrentIndex
(
0
);
}
else
if
(
_protocol
==
Wire1
)
{
wire1_ui
=
new
Ui
::
Wire1Config
;
wire1_ui
->
setupUi
(
this
);
wire1_ui
->
setupUi
(
this
);
for
(
const
GSList
*
l
=
_sdi
->
probes
;
l
;
l
=
l
->
next
)
{
sr_probe
*
const
probe
=
(
sr_probe
*
)
l
->
data
;
assert
(
probe
);
wire1_ui
->
probe_comboBox
->
addItem
(
QString
::
number
(
probe
->
index
)
+
" - "
+
probe
->
name
);
}
wire1_ui
->
probe_comboBox
->
setCurrentIndex
(
0
);
}
}
DemoConfig
::~
DemoConfig
()
{
if
(
i2c_ui
)
delete
i2c_ui
;
if
(
spi_ui
)
delete
spi_ui
;
if
(
serial_ui
)
delete
serial_ui
;
if
(
dmx512_ui
)
delete
dmx512_ui
;
if
(
wire1_ui
)
delete
wire1_ui
;
}
void
DemoConfig
::
accept
()
{
using
namespace
Qt
;
QDialog
::
accept
();
if
(
_protocol
==
I2C
)
{
if
(
!
_sel_probes
.
empty
())
_sel_probes
.
clear
();
_sel_probes
.
push_back
(
i2c_ui
->
scl_comboBox
->
currentIndex
());
_sel_probes
.
push_back
(
i2c_ui
->
sda_comboBox
->
currentIndex
());
}
else
if
(
_protocol
==
SPI
)
{
const
int
ssn_option
=
spi_ui
->
cs_comboBox
->
currentText
().
contains
(
"low"
,
Qt
::
CaseInsensitive
)
?
0
:
spi_ui
->
cs_comboBox
->
currentText
().
contains
(
"high"
,
Qt
::
CaseInsensitive
)
?
1
:
-
1
;
if
(
!
_sel_probes
.
empty
())
_sel_probes
.
clear
();
if
(
ssn_option
!=
-
1
)
_sel_probes
.
push_back
(
spi_ui
->
ssn_comboBox
->
currentIndex
());
_sel_probes
.
push_back
(
spi_ui
->
sclk_comboBox
->
currentIndex
());
_sel_probes
.
push_back
(
spi_ui
->
mosi_comboBox
->
currentIndex
());
_sel_probes
.
push_back
(
spi_ui
->
miso_comboBox
->
currentIndex
());
if
(
!
_options
.
empty
())
_options
.
clear
();
_options
.
insert
(
"cpol"
,
spi_ui
->
cpol_comboBox
->
currentText
().
contains
(
"0"
,
Qt
::
CaseInsensitive
)
?
0
:
1
);
_options
.
insert
(
"cpha"
,
spi_ui
->
cpha_comboBox
->
currentText
().
contains
(
"0"
,
Qt
::
CaseInsensitive
)
?
0
:
1
);
_options
.
insert
(
"bits"
,
spi_ui
->
bits_comboBox
->
currentText
().
toUInt
());
_options
.
insert
(
"order"
,
spi_ui
->
order_comboBox
->
currentText
().
contains
(
"MSB"
,
Qt
::
CaseInsensitive
)
?
1
:
0
);
_options
.
insert
(
"ssn"
,
ssn_option
);
if
(
!
_options_index
.
empty
())
_options_index
.
clear
();
_options_index
.
insert
(
"cpol"
,
spi_ui
->
cpol_comboBox
->
currentIndex
());
_options_index
.
insert
(
"cpha"
,
spi_ui
->
cpha_comboBox
->
currentIndex
());
_options_index
.
insert
(
"bits"
,
spi_ui
->
bits_comboBox
->
currentIndex
());
_options_index
.
insert
(
"order"
,
spi_ui
->
order_comboBox
->
currentIndex
());
_options_index
.
insert
(
"ssn"
,
spi_ui
->
ssn_comboBox
->
currentIndex
());
}
else
if
(
_protocol
==
Serial
)
{
if
(
!
_sel_probes
.
empty
())
_sel_probes
.
clear
();
_sel_probes
.
push_back
(
serial_ui
->
serial_comboBox
->
currentIndex
());
if
(
!
_options
.
empty
())
_options
.
clear
();
_options
.
insert
(
"baudrate"
,
(
serial_ui
->
baud_checkBox
->
checkState
()
==
Qt
::
Checked
)
?
0
:
serial_ui
->
baud_comboBox
->
currentText
().
toULongLong
());
_options
.
insert
(
"stopbits"
,
serial_ui
->
stopbits_comboBox
->
currentText
().
toFloat
());
_options
.
insert
(
"parity"
,
serial_ui
->
parity_comboBox
->
currentText
().
contains
(
"even"
,
Qt
::
CaseInsensitive
)
?
0
:
serial_ui
->
parity_comboBox
->
currentText
().
contains
(
"odd"
,
Qt
::
CaseInsensitive
)
?
1
:
-
1
);
_options
.
insert
(
"order"
,
serial_ui
->
order_comboBox
->
currentText
().
contains
(
"LSB"
,
Qt
::
CaseInsensitive
)
?
1
:
0
);
_options
.
insert
(
"bits"
,
serial_ui
->
bits_comboBox
->
currentText
().
toUInt
());
_options
.
insert
(
"idle"
,
serial_ui
->
idle_comboBox
->
currentText
().
contains
(
"Low"
,
Qt
::
CaseInsensitive
)
?
0
:
1
);
if
(
!
_options_index
.
empty
())
_options_index
.
clear
();
_options_index
.
insert
(
"baudrate"
,
(
serial_ui
->
baud_checkBox
->
checkState
()
==
Qt
::
Checked
)
?
-
1
:
serial_ui
->
baud_comboBox
->
currentIndex
());
_options_index
.
insert
(
"stopbits"
,
serial_ui
->
stopbits_comboBox
->
currentIndex
());
_options_index
.
insert
(
"parity"
,
serial_ui
->
parity_comboBox
->
currentIndex
());
_options_index
.
insert
(
"order"
,
serial_ui
->
order_comboBox
->
currentIndex
());
_options_index
.
insert
(
"bits"
,
serial_ui
->
bits_comboBox
->
currentIndex
());
_options_index
.
insert
(
"idle"
,
serial_ui
->
idle_comboBox
->
currentIndex
());
}
else
if
(
_protocol
==
Dmx512
)
{
if
(
!
_sel_probes
.
empty
())
_sel_probes
.
clear
();
_sel_probes
.
push_back
(
dmx512_ui
->
probe_comboBox
->
currentIndex
());
}
else
if
(
_protocol
==
Wire1
)
{
if
(
!
_sel_probes
.
empty
())
_sel_probes
.
clear
();
_sel_probes
.
push_back
(
wire1_ui
->
probe_comboBox
->
currentIndex
());
}
}
void
DemoConfig
::
set_config
(
std
::
list
<
int
>
sel_probes
,
QMap
<
QString
,
int
>
options_index
)
{
if
(
_protocol
==
I2C
)
{
i2c_ui
->
scl_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
i2c_ui
->
sda_comboBox
->
setCurrentIndex
(
sel_probes
.
back
());
}
else
if
(
_protocol
==
SPI
)
{
spi_ui
->
ssn_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
sel_probes
.
pop_front
();
spi_ui
->
sclk_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
sel_probes
.
pop_front
();
spi_ui
->
mosi_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
sel_probes
.
pop_front
();
spi_ui
->
miso_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
sel_probes
.
pop_front
();
spi_ui
->
cpol_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"cpol"
));
spi_ui
->
cpha_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"cpha"
));
spi_ui
->
bits_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"bits"
));
spi_ui
->
order_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"order"
));
spi_ui
->
ssn_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"ssn"
));
}
else
if
(
_protocol
==
Serial
)
{
serial_ui
->
serial_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
if
(
options_index
.
value
(
"baudrate"
)
==
-
1
)
serial_ui
->
baud_checkBox
->
setChecked
(
true
);
else
serial_ui
->
baud_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"baudrate"
));
serial_ui
->
stopbits_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"stopbits"
));
serial_ui
->
parity_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"parity"
));
serial_ui
->
order_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"order"
));
serial_ui
->
bits_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"bits"
));
serial_ui
->
idle_comboBox
->
setCurrentIndex
(
options_index
.
value
(
"idle"
));
}
else
if
(
_protocol
==
Dmx512
)
{
dmx512_ui
->
probe_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
}
else
if
(
_protocol
==
Wire1
)
{
wire1_ui
->
probe_comboBox
->
setCurrentIndex
(
sel_probes
.
front
());
}
}
std
::
list
<
int
>
DemoConfig
::
get_sel_probes
()
{
return
_sel_probes
;
}
QMap
<
QString
,
QVariant
>
&
DemoConfig
::
get_options
()
{
return
_options
;
}
QMap
<
QString
,
int
>
DemoConfig
::
get_options_index
()
{
return
_options_index
;
}
}
// namespace decoder
}
// namespace pv
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/democonfig.h
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSLOGIC_PV_DEMOCONFIG_H
#define DSLOGIC_PV_DEMOCONFIG_H
#include <QDialog>
#include <QMap>
#include <QVariant>
#include "../sigsession.h"
#include <libsigrok4DSLogic/libsigrok.h>
#include <vector>
namespace
Ui
{
class
I2cConfig
;
class
SpiConfig
;
class
SerialConfig
;
class
Dmx512Config
;
class
Wire1Config
;
}
namespace
pv
{
namespace
decoder
{
class
DemoConfig
:
public
QDialog
{
Q_OBJECT
public:
DemoConfig
(
QWidget
*
parent
=
0
,
sr_dev_inst
*
sdi
=
0
,
int
protocol
=
0
);
virtual
~
DemoConfig
();
void
set_config
(
std
::
list
<
int
>
sel_probes
,
QMap
<
QString
,
int
>
options_index
);
std
::
list
<
int
>
get_sel_probes
();
QMap
<
QString
,
QVariant
>&
get_options
();
QMap
<
QString
,
int
>
get_options_index
();
protected:
void
accept
();
signals:
public
slots
:
private:
sr_dev_inst
*
_sdi
;
int
_protocol
;
std
::
list
<
int
>
_sel_probes
;
QMap
<
QString
,
QVariant
>
_options
;
QMap
<
QString
,
int
>
_options_index
;
Ui
::
I2cConfig
*
i2c_ui
;
Ui
::
SpiConfig
*
spi_ui
;
Ui
::
SerialConfig
*
serial_ui
;
Ui
::
Dmx512Config
*
dmx512_ui
;
Ui
::
Wire1Config
*
wire1_ui
;
};
}
// namespace decoder
}
// namespace pv
#endif // DSLOGIC_PV_DEMOCONFIG_H
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/dmx512config.ui
deleted
100644 → 0
View file @
99920715
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
Dmx512Config
</class>
<widget
class=
"QDialog"
name=
"Dmx512Config"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
360
</width>
<height>
150
</height>
</rect>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
360
</width>
<height>
150
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
360
</width>
<height>
150
</height>
</size>
</property>
<property
name=
"windowTitle"
>
<string>
Dialog
</string>
</property>
<widget
class=
"QDialogButtonBox"
name=
"buttonBox"
>
<property
name=
"geometry"
>
<rect>
<x>
10
</x>
<y>
100
</y>
<width>
341
</width>
<height>
32
</height>
</rect>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"standardButtons"
>
<set>
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
</set>
</property>
</widget>
<widget
class=
"QComboBox"
name=
"probe_comboBox"
>
<property
name=
"geometry"
>
<rect>
<x>
130
</x>
<y>
40
</y>
<width>
141
</width>
<height>
20
</height>
</rect>
</property>
</widget>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"geometry"
>
<rect>
<x>
21
</x>
<y>
40
</y>
<width>
84
</width>
<height>
16
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
Data Signal
</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>
buttonBox
</sender>
<signal>
accepted()
</signal>
<receiver>
Dmx512Config
</receiver>
<slot>
accept()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
248
</x>
<y>
254
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
157
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
buttonBox
</sender>
<signal>
rejected()
</signal>
<receiver>
Dmx512Config
</receiver>
<slot>
reject()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
316
</x>
<y>
260
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
286
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/ds1wire.cpp
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ds1wire.h"
#include <math.h>
using
namespace
boost
;
using
namespace
std
;
namespace
pv
{
namespace
decoder
{
const
QColor
ds1Wire
::
ColorTable
[
TableSize
]
=
{
QColor
(
255
,
255
,
255
,
150
),
QColor
(
0
,
255
,
0
,
150
),
QColor
(
255
,
0
,
0
,
150
),
QColor
(
0
,
255
,
0
,
150
),
QColor
(
255
,
0
,
0
,
150
),
QColor
(
0
,
0
,
255
,
150
),
QColor
(
0
,
0
,
255
,
150
),
QColor
(
0
,
255
,
255
,
150
),
};
const
QString
ds1Wire
::
StateTable
[
TableSize
]
=
{
"UNKNOWN"
,
"RESET"
,
"PRESENCE"
,
"COMMAND"
,
"FAMILY CODE"
,
"SERIAL NUMBER"
,
"CRC"
,
"DATA"
};
ds1Wire
::
ds1Wire
(
boost
::
shared_ptr
<
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
)
:
Decoder
(
data
,
_sel_probes
,
_options_index
)
{
(
void
)
_options
;
assert
(
_sel_probes
.
size
()
==
1
);
_wire_index
=
_sel_probes
.
front
();
}
ds1Wire
::~
ds1Wire
()
{
}
QString
ds1Wire
::
get_decode_name
()
{
return
"1-Wire"
;
}
void
ds1Wire
::
recode
(
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>&
_options
,
QMap
<
QString
,
int
>
_options_index
)
{
(
void
)
_options
;
assert
(
_sel_probes
.
size
()
==
1
);
_wire_index
=
_sel_probes
.
front
();
this
->
_sel_probes
=
_sel_probes
;
this
->
_options_index
=
_options_index
;
decode
();
}
void
ds1Wire
::
decode
()
{
assert
(
_data
);
_max_width
=
0
;
uint8_t
cur_state
=
Unknown
;
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
uint64_t
flag_index1
;
uint64_t
flag_index2
;
uint64_t
flag_index3
;
uint64_t
flag_index4
;
//uint64_t start_index;
//uint64_t stop_index;
//bool edge1;
//bool edge2;
uint64_t
left
=
0
;
uint64_t
right
=
snapshot
->
get_sample_count
()
-
1
;
const
uint64_t
samplerate
=
_data
->
get_samplerate
();
double
pulse_width1
;
double
pulse_width2
;
double
pulse_width3
;
double
pulse_width4
;
uint8_t
data
;
bool
valid
=
false
;
if
(
!
_state_index
.
empty
())
_state_index
.
clear
();
while
(
left
<
right
&&
pulse_width1
!=
0
)
// Regular Speed
{
// search reset flag
pulse_width1
=
get_next_pulse_width
(
0
,
samplerate
,
left
,
right
,
snapshot
);
flag_index1
=
left
;
if
(
pulse_width1
>=
0.48
&&
pulse_width1
<=
0.96
)
{
// tRSTL
pulse_width2
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
snapshot
);
flag_index2
=
left
;
if
(
pulse_width2
>=
0.015
&&
pulse_width2
<=
0.06
)
{
// tPDH
pulse_width3
=
get_next_pulse_width
(
0
,
samplerate
,
left
,
right
,
snapshot
);
flag_index3
=
left
;
if
(
pulse_width3
>=
0.06
&&
pulse_width3
<=
0.24
)
{
// tPDL
pulse_width4
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
snapshot
);
flag_index4
=
left
;
if
(
pulse_width2
+
pulse_width3
+
pulse_width4
>=
0.48
)
{
cur_state
=
Reset
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
flag_index1
,
flag_index2
-
flag_index1
),
std
::
make_pair
(
cur_state
,
0
)));
cur_state
=
Presence
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
flag_index3
,
flag_index4
-
flag_index3
),
std
::
make_pair
(
cur_state
,
0
)));
}
else
{
continue
;
}
}
else
{
continue
;
}
}
else
{
continue
;
}
}
else
{
continue
;
}
uint64_t
start
;
uint64_t
end
;
int
i
;
if
(
cur_state
==
Presence
)
{
data
=
get_next_data
(
false
,
valid
,
start
,
end
,
samplerate
,
left
,
right
,
snapshot
);
if
(
valid
)
{
cur_state
=
Command
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
data
)));
}
else
{
continue
;
}
}
if
(
cur_state
==
Command
)
{
data
=
get_next_data
(
false
,
valid
,
start
,
end
,
samplerate
,
left
,
right
,
snapshot
);
if
(
valid
)
{
cur_state
=
Family
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
data
)));
}
else
{
continue
;
}
}
if
(
cur_state
==
Family
)
{
for
(
i
=
0
;
i
<
6
;
i
++
)
{
data
=
get_next_data
(
false
,
valid
,
start
,
end
,
samplerate
,
left
,
right
,
snapshot
);
if
(
valid
)
{
cur_state
=
Serial
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
data
)));
}
else
{
break
;
}
}
if
(
i
!=
6
)
continue
;
}
if
(
cur_state
==
Serial
)
{
data
=
get_next_data
(
false
,
valid
,
start
,
end
,
samplerate
,
left
,
right
,
snapshot
);
if
(
valid
)
{
cur_state
=
Crc
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
data
)));
}
else
{
continue
;
}
}
if
(
cur_state
==
Crc
)
{
while
(
1
)
{
data
=
get_next_data
(
false
,
valid
,
start
,
end
,
samplerate
,
left
,
right
,
snapshot
);
if
(
valid
)
{
cur_state
=
Data
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
data
)));
}
else
{
break
;
}
}
}
}
// if (cur_state == Unknown) {
// while(1) { // Overdrive Speed
// }
// }
}
double
ds1Wire
::
get_next_pulse_width
(
bool
level
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
)
{
double
pulse_width
=
0
;
uint64_t
flag_index1
;
uint64_t
flag_index2
;
bool
edge1
;
bool
edge2
;
if
(
snapshot
->
get_first_edge
(
flag_index1
,
edge1
,
left
,
right
,
_wire_index
,
level
,
_wire_index
,
-
1
)
==
SR_OK
)
{
left
=
flag_index1
;
if
(
snapshot
->
get_first_edge
(
flag_index2
,
edge2
,
left
,
right
,
_wire_index
,
!
level
,
_wire_index
,
-
1
)
==
SR_OK
)
{
pulse_width
=
(
flag_index2
-
flag_index1
)
*
1000.0
f
/
samplerate
;
}
}
return
pulse_width
;
}
uint8_t
ds1Wire
::
get_next_data
(
bool
speed
,
bool
&
valid
,
uint64_t
&
start
,
uint64_t
&
end
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
)
{
uint8_t
data
=
0
;
double
pulse_width1
;
uint64_t
org_left
=
left
;
int
i
;
valid
=
true
;
if
(
speed
==
false
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
pulse_width1
=
get_next_pulse_width
(
0
,
samplerate
,
left
,
right
,
snapshot
);
start
=
(
i
==
0
)
?
left
:
start
;
end
=
(
i
==
7
)
?
left
+
samplerate
*
0.001
*
0.06
:
end
;
if
(
pulse_width1
>=
0.001
&&
pulse_width1
<
0.015
)
{
pulse_width1
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
snapshot
);
if
(
pulse_width1
>=
0.046
)
{
data
=
data
+
(
1
<<
i
);
org_left
=
left
;
}
else
{
left
=
org_left
;
valid
=
false
;
break
;
}
}
else
if
(
pulse_width1
>=
0.06
&&
pulse_width1
<
0.12
)
{
pulse_width1
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
snapshot
);
if
(
pulse_width1
>=
0.001
)
{
org_left
=
left
;
//data = data << 1;
}
else
{
left
=
org_left
;
valid
=
false
;
break
;
}
}
else
{
left
=
org_left
;
valid
=
false
;
break
;
}
}
}
else
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
pulse_width1
=
get_next_pulse_width
(
0
,
samplerate
,
left
,
right
,
snapshot
);
start
=
(
i
==
0
)
?
left
:
start
;
end
=
(
i
==
7
)
?
left
+
samplerate
*
0.001
*
0.006
:
end
;
if
(
pulse_width1
>=
0.001
&&
pulse_width1
<
0.002
)
{
pulse_width1
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
snapshot
);
if
(
pulse_width1
>=
0.006
)
{
org_left
=
left
;
data
=
data
+
(
1
<<
i
);
}
else
{
left
=
org_left
;
valid
=
false
;
break
;
}
}
else
if
(
pulse_width1
>=
0.006
&&
pulse_width1
<
0.016
)
{
pulse_width1
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
snapshot
);
if
(
pulse_width1
>=
0.001
)
{
org_left
=
left
;
//data = data << 1;
}
else
{
left
=
org_left
;
valid
=
false
;
break
;
}
}
else
{
left
=
org_left
;
valid
=
false
;
break
;
}
}
}
return
data
;
}
void
ds1Wire
::
fill_color_table
(
std
::
vector
<
QColor
>&
_color_table
)
{
int
i
;
for
(
i
=
0
;
i
<
TableSize
;
i
++
)
_color_table
.
push_back
(
ColorTable
[
i
]);
}
void
ds1Wire
::
fill_state_table
(
std
::
vector
<
QString
>&
_state_table
)
{
int
i
;
for
(
i
=
0
;
i
<
TableSize
;
i
++
)
_state_table
.
push_back
(
StateTable
[
i
]);
}
void
ds1Wire
::
get_subsampled_states
(
std
::
vector
<
struct
ds_view_state
>
&
states
,
uint64_t
start
,
uint64_t
end
,
float
min_length
)
{
ds_view_state
view_state
;
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
assert
(
end
<=
snapshot
->
get_sample_count
());
assert
(
start
<=
end
);
assert
(
min_length
>
0
);
if
(
!
states
.
empty
())
states
.
clear
();
if
(
_state_index
.
empty
())
return
;
if
(
start
>
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
first
)
return
;
if
(
end
<
_state_index
.
at
(
0
).
first
.
first
)
return
;
if
(
min_length
*
_view_scale
>
_max_width
)
{
view_state
.
index
=
_state_index
.
at
(
0
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
first
+
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
second
-
_state_index
.
at
(
0
).
first
.
first
;
view_state
.
type
=
DEC_NODETAIL
;
view_state
.
state
=
0
;
view_state
.
data
=
0
;
states
.
push_back
(
view_state
);
return
;
}
uint64_t
view_start
=
0
;
uint64_t
view_end
=
0
;
uint64_t
minIndex
=
0
;
uint64_t
maxIndex
=
_state_index
.
size
()
-
1
;
uint64_t
i
=
start
*
1.0
f
/
snapshot
->
get_sample_count
()
*
maxIndex
;
bool
check_flag
=
false
;
int
times
=
0
;
while
(
times
<=
32
)
{
if
(
_state_index
.
at
(
i
).
first
.
first
+
_state_index
.
at
(
i
).
first
.
second
>=
start
)
{
check_flag
=
true
;
}
else
{
minIndex
=
i
;
i
=
ceil
((
i
+
maxIndex
)
/
2.0
f
);
}
if
(
check_flag
)
{
if
(
i
==
0
)
{
view_start
=
i
;
break
;
}
else
if
(
_state_index
.
at
(
i
-
1
).
first
.
first
+
_state_index
.
at
(
i
-
1
).
first
.
second
<
start
)
{
view_start
=
i
;
break
;
}
else
{
maxIndex
=
i
;
i
=
(
i
+
minIndex
)
/
2
;
}
check_flag
=
false
;
}
times
++
;
}
i
=
view_start
;
check_flag
=
false
;
times
=
0
;
minIndex
=
view_start
;
//maxIndex = _state_index.size() - 1;
maxIndex
=
min
(
_state_index
.
size
()
-
1
,
(
size_t
)
end
);
view_end
=
view_start
;
while
(
times
<=
32
)
{
if
(
_state_index
.
at
(
i
).
first
.
first
<=
end
)
{
check_flag
=
true
;
}
else
{
maxIndex
=
i
;
i
=
(
i
+
minIndex
)
/
2
;
}
if
(
check_flag
)
{
if
(
i
==
maxIndex
)
{
view_end
=
i
;
break
;
}
else
if
(
_state_index
.
at
(
i
+
1
).
first
.
first
>
end
)
{
view_end
=
i
;
break
;
}
else
{
minIndex
=
i
;
i
=
ceil
((
i
+
maxIndex
)
/
2.0
f
);
}
check_flag
=
false
;
}
times
++
;
}
assert
(
view_end
>=
view_start
);
for
(
uint64_t
i
=
view_start
;
i
<=
view_end
;
i
++
)
{
if
(
_state_index
.
at
(
i
).
first
.
second
>=
min_length
*
_view_scale
)
{
view_state
.
index
=
_state_index
.
at
(
i
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
i
).
first
.
second
;
view_state
.
type
=
(
_state_index
.
at
(
i
).
second
.
first
==
Reset
||
_state_index
.
at
(
i
).
second
.
first
==
Presence
)
?
DEC_CMD
:
DEC_DATA
;
view_state
.
state
=
_state_index
.
at
(
i
).
second
.
first
;
view_state
.
data
=
_state_index
.
at
(
i
).
second
.
second
;
states
.
push_back
(
view_state
);
}
else
{
view_state
.
index
=
_state_index
.
at
(
i
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
i
).
first
.
second
;
view_state
.
type
=
DEC_NODETAIL
;
view_state
.
state
=
0
;
view_state
.
data
=
0
;
states
.
push_back
(
view_state
);
}
}
}
}
// namespace decoder
}
// namespace pv
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/ds1wire.h
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSLOGIC_PV_DS1WIRE_H
#define DSLOGIC_PV_DS1WIRE_H
#include "decoder.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"
#include <boost/shared_ptr.hpp>
namespace
pv
{
namespace
data
{
class
LogicSnapshot
;
}
namespace
decoder
{
class
ds1Wire
:
public
Decoder
{
private:
static
const
int
TableSize
=
8
;
static
const
QColor
ColorTable
[
TableSize
];
static
const
QString
StateTable
[
TableSize
];
enum
{
Unknown
=
0
,
Reset
,
Presence
,
Command
,
Family
,
Serial
,
Crc
,
Data
};
private:
double
get_next_pulse_width
(
bool
level
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
);
uint8_t
get_next_data
(
bool
speed
,
bool
&
valid
,
uint64_t
&
start
,
uint64_t
&
end
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
);
public:
ds1Wire
(
boost
::
shared_ptr
<
pv
::
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
);
virtual
~
ds1Wire
();
QString
get_decode_name
();
void
recode
(
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>&
_options
,
QMap
<
QString
,
int
>
_options_index
);
void
decode
();
void
fill_color_table
(
std
::
vector
<
QColor
>&
_color_table
);
void
fill_state_table
(
std
::
vector
<
QString
>&
_state_table
);
void
get_subsampled_states
(
std
::
vector
<
struct
ds_view_state
>
&
states
,
uint64_t
start
,
uint64_t
end
,
float
min_length
);
private:
int
_wire_index
;
uint64_t
_max_width
;
std
::
vector
<
pv
::
data
::
LogicSnapshot
::
EdgePair
>
_cur_edges
;
std
::
vector
<
std
::
pair
<
std
::
pair
<
uint64_t
,
uint64_t
>
,
std
::
pair
<
uint8_t
,
uint8_t
>
>
>
_state_index
;
};
}
// namespace decoder
}
// namespace pv
#endif // DSLOGIC_PV_DS1WIRE_H
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/dsdmx512.cpp
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dsdmx512.h"
#include <math.h>
using
namespace
boost
;
using
namespace
std
;
namespace
pv
{
namespace
decoder
{
const
QColor
dsDmx512
::
ColorTable
[
TableSize
]
=
{
QColor
(
255
,
255
,
255
,
150
),
QColor
(
0
,
255
,
0
,
150
),
QColor
(
255
,
0
,
0
,
150
),
QColor
(
0
,
255
,
0
,
150
),
QColor
(
255
,
0
,
0
,
150
),
QColor
(
0
,
0
,
255
,
150
),
QColor
(
0
,
0
,
255
,
150
),
QColor
(
0
,
255
,
255
,
150
),
};
const
QString
dsDmx512
::
StateTable
[
TableSize
]
=
{
"UNKNOWN"
,
"BREAK"
,
"MAB"
,
"START"
,
"START CODE"
,
"STOP"
,
"MARK"
,
"SLOT"
};
dsDmx512
::
dsDmx512
(
boost
::
shared_ptr
<
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
)
:
Decoder
(
data
,
_sel_probes
,
_options_index
)
{
(
void
)
_options
;
assert
(
_sel_probes
.
size
()
==
1
);
_dmx_index
=
_sel_probes
.
front
();
}
dsDmx512
::~
dsDmx512
()
{
}
QString
dsDmx512
::
get_decode_name
()
{
return
"DMX512"
;
}
void
dsDmx512
::
recode
(
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>&
_options
,
QMap
<
QString
,
int
>
_options_index
)
{
(
void
)
_options
;
assert
(
_sel_probes
.
size
()
==
1
);
_dmx_index
=
_sel_probes
.
front
();
this
->
_sel_probes
=
_sel_probes
;
this
->
_options_index
=
_options_index
;
decode
();
}
void
dsDmx512
::
decode
()
{
assert
(
_data
);
_max_width
=
0
;
uint8_t
cur_state
=
Unknown
;
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
//uint64_t flag_index;
uint64_t
start_index
;
uint64_t
stop_index
;
//bool edge;
uint64_t
left
=
0
;
uint64_t
right
=
snapshot
->
get_sample_count
()
-
1
;
const
uint64_t
samplerate
=
_data
->
get_samplerate
();
double
pulse_width
;
bool
valid
;
if
(
!
_state_index
.
empty
())
_state_index
.
clear
();
while
(
1
)
{
// search Break flag
pulse_width
=
get_next_pulse_width
(
0
,
samplerate
,
left
,
right
,
stop_index
,
snapshot
);
start_index
=
left
;
if
(
pulse_width
>=
0.088
&&
pulse_width
<=
1000
)
{
// Break
cur_state
=
Break
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start_index
,
stop_index
-
start_index
),
std
::
make_pair
(
cur_state
,
0
)));
_max_width
=
max
(
_max_width
,
stop_index
-
start_index
);
}
else
if
(
pulse_width
==
0
){
break
;
}
else
{
continue
;
}
if
(
cur_state
==
Break
)
{
pulse_width
=
get_next_pulse_width
(
1
,
samplerate
,
left
,
right
,
stop_index
,
snapshot
);
start_index
=
left
;
if
(
pulse_width
>=
0.012
&&
pulse_width
<=
1000
)
{
// Marker After Break
cur_state
=
Mab
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start_index
,
stop_index
-
start_index
),
std
::
make_pair
(
cur_state
,
0
)));
_max_width
=
max
(
_max_width
,
stop_index
-
start_index
);
}
else
{
continue
;
}
}
if
(
cur_state
==
Mab
)
{
get_next_data
(
true
,
valid
,
cur_state
,
samplerate
,
left
,
right
,
snapshot
);
}
while
(
valid
)
get_next_data
(
false
,
valid
,
cur_state
,
samplerate
,
left
,
right
,
snapshot
);
}
}
double
dsDmx512
::
get_next_pulse_width
(
bool
level
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
uint64_t
&
end
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
)
{
double
pulse_width
=
0
;
uint64_t
flag_index1
;
uint64_t
flag_index2
;
bool
edge1
;
bool
edge2
;
if
(
snapshot
->
get_first_edge
(
flag_index1
,
edge1
,
left
,
right
,
_dmx_index
,
level
,
_dmx_index
,
-
1
)
==
SR_OK
)
{
left
=
flag_index1
;
if
(
snapshot
->
get_first_edge
(
flag_index2
,
edge2
,
left
,
right
,
_dmx_index
,
!
level
,
_dmx_index
,
-
1
)
==
SR_OK
)
{
end
=
flag_index2
;
pulse_width
=
(
flag_index2
-
flag_index1
)
*
1000.0
f
/
samplerate
;
}
}
return
pulse_width
;
}
uint8_t
dsDmx512
::
get_next_data
(
bool
code
,
bool
&
valid
,
uint8_t
&
cur_state
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
)
{
uint8_t
data
=
0
;
double
pulse_width
;
uint64_t
org_left
=
left
;
//int i;
uint64_t
samplesPerBit
=
ceil
(
samplerate
*
0.001
*
0.004
);
const
uint64_t
dmx_mask
=
1ULL
<<
_dmx_index
;
bool
edge
;
uint64_t
start
=
left
;
uint64_t
end
=
left
;
const
uint8_t
*
src_ptr
;
const
int
unit_size
=
snapshot
->
get_unit_size
();
valid
=
false
;
pulse_width
=
get_next_pulse_width
(
0
,
samplerate
,
left
,
right
,
end
,
snapshot
);
if
(
pulse_width
>=
0.00392
&&
pulse_width
<=
0.00408
*
9
)
{
// Start bit
org_left
=
left
;
start
=
left
;
end
=
start
+
samplesPerBit
;
cur_state
=
Start
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
0
)));
_max_width
=
max
(
_max_width
,
end
-
start
);
}
else
{
left
=
org_left
;
return
data
;
}
if
(
cur_state
==
Start
)
{
src_ptr
=
(
uint8_t
*
)
snapshot
->
get_data
();
start
=
end
;
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
0.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
0
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
1.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
1
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
2.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
2
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
3.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
3
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
4.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
4
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
5.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
5
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
6.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
6
);
data
=
data
+
(((
*
(
uint64_t
*
)(
src_ptr
+
(
int
)(
start
+
samplesPerBit
*
7.5
)
*
unit_size
)
&
dmx_mask
)
!=
0
)
<<
7
);
end
=
start
+
samplesPerBit
*
8
;
cur_state
=
code
?
Scode
:
Slot
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
data
)));
_max_width
=
max
(
_max_width
,
end
-
start
);
}
org_left
=
end
;
left
=
start
+
samplesPerBit
*
8.5
;
if
((
*
(
uint64_t
*
)(
src_ptr
+
left
*
unit_size
)
&
dmx_mask
)
!=
0
)
{
if
(
snapshot
->
get_first_edge
(
end
,
edge
,
left
,
right
,
_dmx_index
,
0
,
_dmx_index
,
-
1
)
==
SR_OK
)
{
pulse_width
=
(
end
-
org_left
)
*
1000.0
f
/
samplerate
;
if
(
pulse_width
>=
0.008
&&
pulse_width
<=
1000
)
{
start
=
org_left
;
end
=
start
+
samplesPerBit
*
2
;
cur_state
=
Stop
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
start
,
end
-
start
),
std
::
make_pair
(
cur_state
,
0
)));
_max_width
=
max
(
_max_width
,
end
-
start
);
}
}
else
{
left
=
org_left
;
return
data
;
}
}
else
{
return
data
;
}
valid
=
true
;
return
data
;
}
void
dsDmx512
::
fill_color_table
(
std
::
vector
<
QColor
>&
_color_table
)
{
int
i
;
for
(
i
=
0
;
i
<
TableSize
;
i
++
)
_color_table
.
push_back
(
ColorTable
[
i
]);
}
void
dsDmx512
::
fill_state_table
(
std
::
vector
<
QString
>&
_state_table
)
{
int
i
;
for
(
i
=
0
;
i
<
TableSize
;
i
++
)
_state_table
.
push_back
(
StateTable
[
i
]);
}
void
dsDmx512
::
get_subsampled_states
(
std
::
vector
<
struct
ds_view_state
>
&
states
,
uint64_t
start
,
uint64_t
end
,
float
min_length
)
{
ds_view_state
view_state
;
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
assert
(
end
<=
snapshot
->
get_sample_count
());
assert
(
start
<=
end
);
assert
(
min_length
>
0
);
if
(
!
states
.
empty
())
states
.
clear
();
if
(
_state_index
.
empty
())
return
;
if
(
start
>
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
first
)
return
;
if
(
end
<
_state_index
.
at
(
0
).
first
.
first
)
return
;
if
(
min_length
*
_view_scale
>
_max_width
)
{
view_state
.
index
=
_state_index
.
at
(
0
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
first
+
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
second
-
_state_index
.
at
(
0
).
first
.
first
;
view_state
.
type
=
DEC_NODETAIL
;
view_state
.
state
=
0
;
view_state
.
data
=
0
;
states
.
push_back
(
view_state
);
return
;
}
uint64_t
view_start
=
0
;
uint64_t
view_end
=
0
;
uint64_t
minIndex
=
0
;
uint64_t
maxIndex
=
_state_index
.
size
()
-
1
;
uint64_t
i
=
start
*
1.0
f
/
snapshot
->
get_sample_count
()
*
maxIndex
;
bool
check_flag
=
false
;
int
times
=
0
;
while
(
times
<=
32
)
{
if
(
_state_index
.
at
(
i
).
first
.
first
+
_state_index
.
at
(
i
).
first
.
second
>=
start
)
{
check_flag
=
true
;
}
else
{
minIndex
=
i
;
i
=
ceil
((
i
+
maxIndex
)
/
2.0
f
);
}
if
(
check_flag
)
{
if
(
i
==
0
)
{
view_start
=
i
;
break
;
}
else
if
(
_state_index
.
at
(
i
-
1
).
first
.
first
+
_state_index
.
at
(
i
-
1
).
first
.
second
<
start
)
{
view_start
=
i
;
break
;
}
else
{
maxIndex
=
i
;
i
=
(
i
+
minIndex
)
/
2
;
}
check_flag
=
false
;
}
times
++
;
}
i
=
view_start
;
check_flag
=
false
;
times
=
0
;
minIndex
=
view_start
;
//maxIndex = _state_index.size() - 1;
maxIndex
=
min
(
_state_index
.
size
()
-
1
,
(
size_t
)
end
);
view_end
=
view_start
;
while
(
times
<=
32
)
{
if
(
_state_index
.
at
(
i
).
first
.
first
<=
end
)
{
check_flag
=
true
;
}
else
{
maxIndex
=
i
;
i
=
(
i
+
minIndex
)
/
2
;
}
if
(
check_flag
)
{
if
(
i
==
maxIndex
)
{
view_end
=
i
;
break
;
}
else
if
(
_state_index
.
at
(
i
+
1
).
first
.
first
>
end
)
{
view_end
=
i
;
break
;
}
else
{
minIndex
=
i
;
i
=
ceil
((
i
+
maxIndex
)
/
2.0
f
);
}
check_flag
=
false
;
}
times
++
;
}
assert
(
view_end
>=
view_start
);
for
(
uint64_t
i
=
view_start
;
i
<=
view_end
;
i
++
)
{
if
(
_state_index
.
at
(
i
).
first
.
second
>=
min_length
*
_view_scale
)
{
view_state
.
index
=
_state_index
.
at
(
i
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
i
).
first
.
second
;
view_state
.
type
=
(
_state_index
.
at
(
i
).
second
.
first
==
Slot
)
?
DEC_CNT
:
(
_state_index
.
at
(
i
).
second
.
first
==
Scode
)
?
DEC_DATA
:
DEC_CMD
;
view_state
.
state
=
_state_index
.
at
(
i
).
second
.
first
;
view_state
.
data
=
_state_index
.
at
(
i
).
second
.
second
;
states
.
push_back
(
view_state
);
}
else
{
view_state
.
index
=
_state_index
.
at
(
i
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
i
).
first
.
second
;
view_state
.
type
=
DEC_NODETAIL
;
view_state
.
state
=
0
;
view_state
.
data
=
0
;
states
.
push_back
(
view_state
);
}
}
}
}
// namespace decoder
}
// namespace pv
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/dsdmx512.h
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSLOGIC_PV_DSDMX512_H
#define DSLOGIC_PV_DSDMX512_H
#include "decoder.h"
#include "../data/logic.h"
#include "../data/logicsnapshot.h"
#include <boost/shared_ptr.hpp>
namespace
pv
{
namespace
data
{
class
LogicSnapshot
;
}
namespace
decoder
{
class
dsDmx512
:
public
Decoder
{
private:
static
const
int
TableSize
=
8
;
static
const
QColor
ColorTable
[
TableSize
];
static
const
QString
StateTable
[
TableSize
];
enum
{
Unknown
=
0
,
Break
,
Mab
,
Start
,
Scode
,
Stop
,
Mark
,
Slot
};
private:
double
get_next_pulse_width
(
bool
level
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
uint64_t
&
end
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
);
uint8_t
get_next_data
(
bool
code
,
bool
&
valid
,
uint8_t
&
cur_state
,
uint64_t
samplerate
,
uint64_t
&
left
,
uint64_t
right
,
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
);
public:
dsDmx512
(
boost
::
shared_ptr
<
pv
::
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
);
virtual
~
dsDmx512
();
QString
get_decode_name
();
void
recode
(
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>&
_options
,
QMap
<
QString
,
int
>
_options_index
);
void
decode
();
void
fill_color_table
(
std
::
vector
<
QColor
>&
_color_table
);
void
fill_state_table
(
std
::
vector
<
QString
>&
_state_table
);
void
get_subsampled_states
(
std
::
vector
<
struct
ds_view_state
>
&
states
,
uint64_t
start
,
uint64_t
end
,
float
min_length
);
private:
int
_dmx_index
;
uint64_t
_max_width
;
std
::
vector
<
std
::
pair
<
std
::
pair
<
uint64_t
,
uint64_t
>
,
std
::
pair
<
uint8_t
,
uint8_t
>
>
>
_state_index
;
};
}
// namespace decoder
}
// namespace pv
#endif // DSLOGIC_PV_DSDMX512_H
This diff is collapsed.
Click to expand it.
DSLogic-gui/pv/decoder/dsi2c.cpp
deleted
100644 → 0
View file @
99920715
/*
* This file is part of the DSLogic-gui project.
* DSLogic-gui is based on PulseView.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
* Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dsi2c.h"
#include <math.h>
using
namespace
boost
;
using
namespace
std
;
namespace
pv
{
namespace
decoder
{
const
QColor
dsI2c
::
ColorTable
[
TableSize
]
=
{
QColor
(
255
,
255
,
255
,
150
),
QColor
(
0
,
255
,
0
,
150
),
QColor
(
255
,
0
,
0
,
150
),
QColor
(
0
,
255
,
0
,
150
),
QColor
(
255
,
0
,
0
,
150
),
QColor
(
0
,
0
,
255
,
150
),
QColor
(
0
,
0
,
255
,
150
),
QColor
(
0
,
255
,
255
,
150
),
};
const
QString
dsI2c
::
StateTable
[
TableSize
]
=
{
"UNKNOWN"
,
"START"
,
"STOP"
,
"ACK"
,
"NAK"
,
"READ @"
,
"WRITE @"
,
"DATA"
};
dsI2c
::
dsI2c
(
boost
::
shared_ptr
<
data
::
Logic
>
data
,
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>
&
_options
,
QMap
<
QString
,
int
>
_options_index
)
:
Decoder
(
data
,
_sel_probes
,
_options_index
)
{
(
void
)
_options
;
assert
(
_sel_probes
.
size
()
==
2
);
_scl_index
=
_sel_probes
.
front
();
_sda_index
=
_sel_probes
.
back
();
}
dsI2c
::~
dsI2c
()
{
}
QString
dsI2c
::
get_decode_name
()
{
return
"I2C"
;
}
void
dsI2c
::
recode
(
std
::
list
<
int
>
_sel_probes
,
QMap
<
QString
,
QVariant
>&
_options
,
QMap
<
QString
,
int
>
_options_index
)
{
(
void
)
_options
;
assert
(
_sel_probes
.
size
()
==
2
);
_scl_index
=
_sel_probes
.
front
();
_sda_index
=
_sel_probes
.
back
();
this
->
_sel_probes
=
_sel_probes
;
this
->
_options_index
=
_options_index
;
decode
();
}
void
dsI2c
::
decode
()
{
assert
(
_data
);
_max_width
=
0
;
uint8_t
cur_state
=
Unknown
;
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
uint64_t
flag_index
;
uint64_t
start_index
;
uint64_t
stop_index
;
bool
edge
;
uint64_t
left
=
0
;
uint64_t
right
=
snapshot
->
get_sample_count
()
-
1
;
if
(
!
_state_index
.
empty
())
_state_index
.
clear
();
while
(
1
)
{
// search start flag
if
(
snapshot
->
get_first_edge
(
flag_index
,
edge
,
left
,
right
,
_sda_index
,
-
1
,
_scl_index
,
1
)
==
SR_OK
)
{
left
=
flag_index
+
1
;
if
(
cur_state
==
Start
)
{
stop_index
=
flag_index
;
snapshot
->
get_edges
(
_cur_edges
,
start_index
,
stop_index
,
_scl_index
,
1
);
cmd_decode
(
snapshot
);
data_decode
(
snapshot
);
_cur_edges
.
clear
();
}
if
(
edge
==
false
)
{
cur_state
=
Start
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
flag_index
-
1
,
2
),
std
::
make_pair
(
cur_state
,
0
)));
}
else
{
cur_state
=
Stop
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
flag_index
-
1
,
2
),
std
::
make_pair
(
cur_state
,
0
)));
}
start_index
=
flag_index
+
1
;
_max_width
=
max
(
_max_width
,
(
uint64_t
)
2
);
}
else
{
if
(
cur_state
==
Start
)
{
stop_index
=
snapshot
->
get_sample_count
()
-
1
;
snapshot
->
get_edges
(
_cur_edges
,
start_index
,
stop_index
,
_scl_index
,
1
);
cmd_decode
(
snapshot
);
data_decode
(
snapshot
);
_cur_edges
.
clear
();
}
_cur_edges
.
clear
();
break
;
}
}
}
void
dsI2c
::
cmd_decode
(
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
)
{
uint8_t
cur_state
;
const
uint8_t
*
src_ptr
;
const
int
unit_size
=
snapshot
->
get_unit_size
();
//const uint8_t *const end_src_ptr = (uint8_t*)snapshot->get_data() +
// snapshot->get_sample_count() * unit_size;
//const uint64_t scl_mask = 1ULL << _scl_index;
const
uint64_t
sda_mask
=
1ULL
<<
_sda_index
;
if
(
_cur_edges
.
size
()
>
9
)
{
uint8_t
slave_addr
=
0
;
bool
read
;
bool
nak
;
//int index = 0;
src_ptr
=
(
uint8_t
*
)
snapshot
->
get_data
();
slave_addr
=
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
0
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
slave_addr
=
(
slave_addr
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
1
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
slave_addr
=
(
slave_addr
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
2
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
slave_addr
=
(
slave_addr
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
3
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
slave_addr
=
(
slave_addr
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
4
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
slave_addr
=
(
slave_addr
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
5
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
slave_addr
=
(
slave_addr
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
6
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
read
=
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
7
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
nak
=
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
8
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
cur_state
=
read
?
Read
:
Write
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
_cur_edges
.
at
(
0
).
first
-
1
,
_cur_edges
.
at
(
7
).
first
-
_cur_edges
.
at
(
0
).
first
+
2
),
std
::
make_pair
(
cur_state
,
slave_addr
)));
cur_state
=
nak
?
Nak
:
Ack
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
_cur_edges
.
at
(
8
).
first
-
1
,
2
),
std
::
make_pair
(
cur_state
,
0
)));
_max_width
=
max
(
_max_width
,
_cur_edges
.
at
(
7
).
first
-
_cur_edges
.
at
(
0
).
first
+
2
);
//_cur_edges.erase(_cur_edges.begin(), _cur_edges.begin() + 9);
}
}
void
dsI2c
::
data_decode
(
const
boost
::
shared_ptr
<
data
::
LogicSnapshot
>
&
snapshot
)
{
uint8_t
cur_state
;
const
uint8_t
*
src_ptr
;
const
int
unit_size
=
snapshot
->
get_unit_size
();
//const uint8_t *const end_src_ptr = (uint8_t*)snapshot->get_data() +
// snapshot->get_sample_count() * unit_size;
//const uint64_t scl_mask = 1ULL << _scl_index;
const
uint64_t
sda_mask
=
1ULL
<<
_sda_index
;
uint64_t
edge_size
=
_cur_edges
.
size
();
uint64_t
index
=
9
;
while
(
edge_size
>
index
+
9
)
{
uint8_t
data
=
0
;
bool
nak
;
src_ptr
=
(
uint8_t
*
)
snapshot
->
get_data
();
data
=
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
1
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
2
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
3
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
4
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
5
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
6
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
data
=
(
data
<<
1
)
+
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
7
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
nak
=
((
*
(
uint64_t
*
)(
src_ptr
+
_cur_edges
[
index
+
8
].
first
*
unit_size
)
&
sda_mask
)
!=
0
);
cur_state
=
Data
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
_cur_edges
.
at
(
index
).
first
-
1
,
_cur_edges
.
at
(
index
+
7
).
first
-
_cur_edges
.
at
(
index
).
first
+
2
),
std
::
make_pair
(
cur_state
,
data
)));
cur_state
=
nak
?
Nak
:
Ack
;
_state_index
.
push_back
(
std
::
make_pair
(
std
::
make_pair
(
_cur_edges
.
at
(
index
+
8
).
first
-
1
,
2
),
std
::
make_pair
(
cur_state
,
0
)));
_max_width
=
max
(
_max_width
,
_cur_edges
.
at
(
index
+
7
).
first
-
_cur_edges
.
at
(
index
).
first
+
2
);
//_cur_edges.erase(_cur_edges.begin(), _cur_edges.begin() + 9);
index
+=
9
;
}
}
void
dsI2c
::
fill_color_table
(
std
::
vector
<
QColor
>&
_color_table
)
{
int
i
;
for
(
i
=
0
;
i
<
TableSize
;
i
++
)
_color_table
.
push_back
(
ColorTable
[
i
]);
}
void
dsI2c
::
fill_state_table
(
std
::
vector
<
QString
>&
_state_table
)
{
int
i
;
for
(
i
=
0
;
i
<
TableSize
;
i
++
)
_state_table
.
push_back
(
StateTable
[
i
]);
}
void
dsI2c
::
get_subsampled_states
(
std
::
vector
<
struct
ds_view_state
>
&
states
,
uint64_t
start
,
uint64_t
end
,
float
min_length
)
{
ds_view_state
view_state
;
const
deque
<
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
>
&
snapshots
=
_data
->
get_snapshots
();
if
(
snapshots
.
empty
())
return
;
const
boost
::
shared_ptr
<
pv
::
data
::
LogicSnapshot
>
&
snapshot
=
snapshots
.
front
();
assert
(
end
<=
snapshot
->
get_sample_count
());
assert
(
start
<=
end
);
assert
(
min_length
>
0
);
if
(
!
states
.
empty
())
states
.
clear
();
if
(
_state_index
.
empty
())
return
;
if
(
start
>
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
first
)
return
;
if
(
end
<
_state_index
.
at
(
0
).
first
.
first
)
return
;
if
(
min_length
*
_view_scale
>
_max_width
)
{
view_state
.
index
=
_state_index
.
at
(
0
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
first
+
_state_index
.
at
(
_state_index
.
size
()
-
1
).
first
.
second
-
_state_index
.
at
(
0
).
first
.
first
;
view_state
.
type
=
DEC_NODETAIL
;
view_state
.
state
=
0
;
view_state
.
data
=
0
;
states
.
push_back
(
view_state
);
return
;
}
uint64_t
view_start
=
0
;
uint64_t
view_end
=
0
;
uint64_t
minIndex
=
0
;
uint64_t
maxIndex
=
_state_index
.
size
()
-
1
;
uint64_t
i
=
start
*
1.0
f
/
snapshot
->
get_sample_count
()
*
maxIndex
;
bool
check_flag
=
false
;
int
times
=
0
;
while
(
times
<=
32
)
{
if
(
_state_index
.
at
(
i
).
first
.
first
+
_state_index
.
at
(
i
).
first
.
second
>=
start
)
{
check_flag
=
true
;
}
else
{
minIndex
=
i
;
i
=
ceil
((
i
+
maxIndex
)
/
2.0
f
);
}
if
(
check_flag
)
{
if
(
i
==
0
)
{
view_start
=
i
;
break
;
}
else
if
(
_state_index
.
at
(
i
-
1
).
first
.
first
+
_state_index
.
at
(
i
-
1
).
first
.
second
<
start
)
{
view_start
=
i
;
break
;
}
else
{
maxIndex
=
i
;
i
=
(
i
+
minIndex
)
/
2
;
}
check_flag
=
false
;
}
times
++
;
}
i
=
view_start
;
check_flag
=
false
;
times
=
0
;
minIndex
=
view_start
;
//maxIndex = _state_index.size() - 1;
maxIndex
=
min
(
_state_index
.
size
()
-
1
,
(
size_t
)
end
);
view_end
=
view_start
;
while
(
times
<=
32
)
{
if
(
_state_index
.
at
(
i
).
first
.
first
<=
end
)
{
check_flag
=
true
;
}
else
{
maxIndex
=
i
;
i
=
(
i
+
minIndex
)
/
2
;
}
if
(
check_flag
)
{
if
(
i
==
maxIndex
)
{
view_end
=
i
;
break
;
}
else
if
(
_state_index
.
at
(
i
+
1
).
first
.
first
>
end
)
{
view_end
=
i
;
break
;
}
else
{
minIndex
=
i
;
i
=
ceil
((
i
+
maxIndex
)
/
2.0
f
);
}
check_flag
=
false
;
}
times
++
;
}
assert
(
view_end
>=
view_start
);
for
(
uint64_t
i
=
view_start
;
i
<=
view_end
;
i
++
)
{
if
(
_state_index
.
at
(
i
).
first
.
second
>=
min_length
*
_view_scale
)
{
view_state
.
index
=
_state_index
.
at
(
i
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
i
).
first
.
second
;
view_state
.
type
=
(
_state_index
.
at
(
i
).
second
.
first
==
Read
||
_state_index
.
at
(
i
).
second
.
first
==
Write
||
_state_index
.
at
(
i
).
second
.
first
==
Data
)
?
DEC_DATA
:
DEC_CMD
;
view_state
.
state
=
_state_index
.
at
(
i
).
second
.
first
;
view_state
.
data
=
_state_index
.
at
(
i
).
second
.
second
;
states
.
push_back
(
view_state
);
}
else
{
view_state
.
index
=
_state_index
.
at
(
i
).
first
.
first
;
view_state
.
samples
=
_state_index
.
at
(
i
).
first
.
second
;
view_state
.
type
=
DEC_NODETAIL
;
view_state
.
state
=
0
;
view_state
.
data
=
0
;
states
.
push_back
(
view_state
);
}
}
}
}
// namespace decoder
}
// namespace pv
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
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