Skip to content
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ca8d4c3
Add a note and todo to the Saleae based sniffer
peternewman Feb 25, 2021
9f868ac
Add some more debugging to the DMXSignalProcessor
peternewman Feb 25, 2021
b8e4500
Check for libsigrok and build the sigrok based sniffer
peternewman Feb 25, 2021
ea599ca
Initial version of sigok based sniffer. Still rather rough around the…
peternewman Feb 25, 2021
dda170d
Add sigrok packages to Travis
peternewman Feb 25, 2021
ead9174
Remove incorrect ifdef wrapper
peternewman Feb 25, 2021
c0c042a
Fix a failed attempt at commenting out an option
peternewman Mar 2, 2021
3c57743
Check for whether libsigrok supports sessions
peternewman Mar 2, 2021
bd689c1
Rename the sigrok context define, add some additional defines
peternewman Mar 2, 2021
f2520b9
First go at handling newer sigrok behaviour
peternewman Mar 2, 2021
26dca5c
Start tidying up some redundant code
peternewman Mar 3, 2021
d048f88
Add a little bit more debug to the DMXSignalProcessor
peternewman Mar 3, 2021
dd3517e
More tidying up of Sigrok code
peternewman Mar 9, 2021
19ccd00
Handle both samples and time based captures
peternewman Mar 9, 2021
3a898b1
Capture continuously by default
peternewman Mar 9, 2021
abf1b5b
Support sigrok's unitsize in the logic packets for LAs with more than…
peternewman Mar 15, 2021
7ac19eb
Make the sigrok device to connect to mandatory
peternewman Mar 15, 2021
6467ca9
Add an initial man file for sigrok-rdm-sniffer
peternewman Mar 15, 2021
8b3fdd0
Fix the case of the sigrok name
peternewman Mar 16, 2021
877f28d
Fix some lint issues
peternewman Mar 16, 2021
b0efa4d
Fix more lint issues
peternewman Mar 16, 2021
2e25f9a
Fix some comments
peternewman Mar 16, 2021
293be8f
Switch sigrok_rdm_sniffer to use our new BaseSnifferReader
peternewman Apr 1, 2021
f7e0099
Fix some lint issues
peternewman Apr 15, 2021
7db2ef2
Switch the original Logic sniffer code to the new common base
peternewman May 20, 2021
1e6b40a
Extract the BaseSnifferReader and DMXSignalProcessor into their own s…
peternewman May 20, 2021
9e9b004
Merge branch 'master' into sigrok
peternewman May 20, 2021
29f3ac2
Fix some lint errors
peternewman May 20, 2021
5f388f3
Update the sniffer READMEs
peternewman May 20, 2021
90e9abf
Merge branch 'OpenLightingProject:master' into sigrok
peternewman Jun 19, 2021
bc94fd4
Merge branch 'master' into sigrok
peternewman Jan 20, 2022
2d01961
Merge branch 'OpenLightingProject:master' into sigrok
peternewman Mar 3, 2023
a725321
Improve an error message
peternewman Mar 5, 2023
363e594
Merge branch 'master' of https://github.com/openlightingproject/ola i…
peternewman Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ tools/e133/slp_sa_test
tools/e133/slp_sa_test.exe
tools/logic/logic_rdm_sniffer
tools/logic/logic_rdm_sniffer.exe
tools/logic/sigrok_rdm_sniffer
tools/logic/sigrok_rdm_sniffer.exe
tools/ola_trigger/config.tab.cpp
tools/ola_trigger/config.tab.h
tools/ola_trigger/lex.yy.cpp
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ addons:
- libavahi-glib1
- libncurses5-dev
- libmicrohttpd-dev
- libsigrok-dev
packages: &core_build_gpp_latest
- *core_build
- g++-10
Expand Down Expand Up @@ -68,6 +69,7 @@ addons:
# Looks like this is Python 3 only, so install via pip
# - numpy
- libusb
# Sigrok
packages: &mac_cppunit_113
# Installing via the addon isn't currently working so do it the old fashioned way below
# - https://raw.githubusercontent.com/Homebrew/homebrew-core/e6e43cf6a3^/Formula/cppunit.rb # install a slightly older cppunit, as latest needs C++11 support
Expand Down
22 changes: 21 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,29 @@ AS_IF([test "x$have_avahi" = xyes],
[AC_DEFINE([HAVE_AVAHI], [1], [Defined to use Avahi])])
AM_CONDITIONAL([HAVE_AVAHI], [test "x$have_avahi" = xyes])

# Look for -lSaleaeDevice, if we have it we build the logic sniffer.
# Look for -lSaleaeDevice, if we have it we build the Saleae logic sniffer.
SALEAE_DEVICE

# Look for -lsigrok, if we have it we build the sigrok logic sniffer.
PKG_CHECK_MODULES([libsigrok], [libsigrok], [have_libsigrok="yes"], [have_libsigrok="no"])
AM_CONDITIONAL([HAVE_LIBSIGROK],
[test "x$have_libsigrok" = xyes])

have_libsigrok_context="no"
AS_IF([test "x$have_libsigrok" != xno],
[PKG_CHECK_MODULES([libsigrok_context], [libsigrok >= 0.4.0],
[have_libsigrok_context="yes"], [true])])
AS_IF([test "x$have_libsigrok_context" = xyes],
[AC_DEFINE([HAVE_LIBSIGROK_CONTEXT], [1],
[define if libsigrok is installed and uses it's context])])

have_libsigrok_dev_inst_opaque="no"
AS_IF([test "x$have_libsigrok" != xno],
[PKG_CHECK_MODULES([libsigrok_context], [libsigrok >= 0.4.0],
[have_libsigrok_dev_inst_opaque="yes"], [true])])
AS_IF([test "x$have_libsigrok_dev_inst_opaque" = xyes],
[AC_DEFINE([HAVE_LIBSIGROK_DEV_INST_OPAQUE], [1],
[define if libsigrok is installed and the sr_dev_inst struct is opaque])])

# Features
#####################################################
Expand Down
1 change: 1 addition & 0 deletions man/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ dist_man_MANS += \
man/rdm_responder_test.py.1 \
man/rdm_test_server.py.1 \
man/rdmpro_sniffer.1 \
man/sigrok_rdm_sniffer.1 \
man/usbpro_firmware.1
48 changes: 48 additions & 0 deletions man/sigrok_rdm_sniffer.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.TH sigrok_rdm_sniffer 1 "March 2021"
.SH NAME
sigrok_rdm_sniffer \- Decode DMX/RDM data from devices supported by sigrok
.SH SYNOPSIS
.B sigrok_rdm_sniffer
[ options ]
.SH DESCRIPTION
.B sigrok_rdm_sniffer
Decode DMX/RDM data from devices supported by sigrok
.SH OPTIONS
.IP "-d, --display-dmx"
Display DMX Frames. Defaults to false.
.IP "-h, --help"
Display the help message
.IP "-l, --log-level <int8_t>"
Set the logging level 0 .. 4.
.IP "-r, --full-rdm"
Unpack RDM parameter data.
.IP "-t, --timestamp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that implemented? Doesn't seem to work with just -d -t. Maybe it's just for RDM frames?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I found out some time back it wasn't implemented on the original Logic but left is present just in case it broke people's CLIs:
https://github.com/peternewman/ola/blob/sigrok/tools/logic/logic-rdm-sniffer.cpp#L86-L87

Obviously that appeared when I duplicated this code. I've commented it out for now entirely in the sigrok based sniffer. When it all gets pulled out to some common code I'll try and finally implement it too, then they'll both get it!

Include timestamps.
.IP "-v, --version"
Print
.B sigrok_rdm_sniffer
version information.
.IP "--display-asc"
Display non-RDM alternate start code frames.
.IP "--dmx-slot-limit <uint16_t>"
Only display the first N slots of DMX data.
.IP "--no-use-epoll"
Disable the use of epoll(), revert to select()
.IP "--pid-location <string>"
The directory containing the PID definitions.
.IP "--sample-rate <uint32_t>"
Sample rate in Hz.
.IP "--scheduler-policy <string>"
The thread scheduling policy, one of {fifo, rr}.
.IP "--scheduler-priority <uint16_t>"
The thread priority, only used if --scheduler-policy is set.
.IP "--sigrok-device <string>"
Set the sigrok device to use.
.IP "--sigrok-log-level <uint32_t>"
Set the sigrok logging level from 0 .. 5.
.IP "--sigrok-samples <uint32_t>"
Limit capture to this many samples.
.IP "--sigrok-time <uint32_t>"
Limit capture to this many ms.
.IP "--syslog"
Send to syslog rather than stderr.
15 changes: 9 additions & 6 deletions tools/logic/DMXSignalProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ DMXSignalProcessor::DMXSignalProcessor(DataCallback *callback,
m_ticks(0),
m_may_be_in_break(false),
m_ticks_in_break(0) {
OLA_DEBUG << "Microseconds per tick " << m_microseconds_per_tick;
if (m_sample_rate % DMX_BITRATE) {
OLA_WARN << "Sample rate is not a multiple of " << DMX_BITRATE;
}
Expand All @@ -82,10 +83,11 @@ DMXSignalProcessor::DMXSignalProcessor(DataCallback *callback,
* @param size the number of samples in the stream
* @param mask the value to be AND'ed with each sample to determine if the
* signal is high or low.
* @param width the width (in bytes) of each sample within the stream
*/
void DMXSignalProcessor::Process(uint8_t *ptr, unsigned int size,
uint8_t mask) {
for (unsigned int i = 0 ; i < size; i++) {
uint8_t mask, unsigned int width) {
for (unsigned int i = 0 ; i < size; i += width) {
ProcessSample(ptr[i] & mask);
}
}
Expand Down Expand Up @@ -118,7 +120,7 @@ void DMXSignalProcessor::ProcessSample(bool bit) {
SetState(MAB);
} else {
OLA_WARN << "Break too short, was " << TicksAsMicroSeconds()
<< " us";
<< " us (" << m_ticks << " ticks)";
SetState(IDLE);
}
} else {
Expand All @@ -136,7 +138,8 @@ void DMXSignalProcessor::ProcessSample(bool bit) {
// OLA_INFO << "In start bit!";
SetState(START_BIT);
} else {
OLA_WARN << "Mark too short, was " << TicksAsMicroSeconds() << "us";
OLA_WARN << "Mark too short, was " << TicksAsMicroSeconds() << "us ("
<< m_ticks << " ticks)";
SetState(UNDEFINED);
}
}
Expand Down Expand Up @@ -222,7 +225,7 @@ void DMXSignalProcessor::ProcessBit(bool bit) {
SetState(static_cast<State>(m_state + 1));
} else {
OLA_WARN << "Bit " << m_state << " was too short, was "
<< TicksAsMicroSeconds() << "us";
<< TicksAsMicroSeconds() << "us (" << m_ticks << " ticks)";
SetState(UNDEFINED);
}
}
Expand Down Expand Up @@ -283,7 +286,7 @@ void DMXSignalProcessor::HandleFrame() {
*/
void DMXSignalProcessor::SetState(State state, unsigned int ticks) {
OLA_INFO << "Transition to " << state << ", prev duration was "
<< TicksAsMicroSeconds();
<< TicksAsMicroSeconds() << " us (" << m_ticks << " ticks)";
m_state = state;
m_ticks = ticks;
if (state == UNDEFINED) {
Expand Down
3 changes: 2 additions & 1 deletion tools/logic/DMXSignalProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class DMXSignalProcessor {
}

// Process more data.
void Process(uint8_t *ptr, unsigned int size, uint8_t mask = 0xff);
void Process(uint8_t *ptr, unsigned int size, uint8_t mask = 0xff,
unsigned int width = 1);

private:
enum State {
Expand Down
13 changes: 13 additions & 0 deletions tools/logic/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ if HAVE_SALEAE_LOGIC
bin_PROGRAMS += tools/logic/logic_rdm_sniffer
endif

if HAVE_LIBSIGROK
bin_PROGRAMS += tools/logic/sigrok_rdm_sniffer
endif

tools_logic_logic_rdm_sniffer_SOURCES = \
tools/logic/DMXSignalProcessor.cpp \
tools/logic/DMXSignalProcessor.h \
tools/logic/logic-rdm-sniffer.cpp
tools_logic_logic_rdm_sniffer_LDADD = common/libolacommon.la \
$(libSaleaeDevice_LIBS)

tools_logic_sigrok_rdm_sniffer_SOURCES = \
tools/logic/DMXSignalProcessor.cpp \
tools/logic/DMXSignalProcessor.h \
tools/logic/sigrok-rdm-sniffer.cpp
tools_logic_sigrok_rdm_sniffer_CXXFLAGS = $(COMMON_CXXFLAGS) \
$(libsigrok_CFLAGS)
tools_logic_sigrok_rdm_sniffer_LDADD = common/libolacommon.la \
$(libsigrok_LIBS)

EXTRA_DIST += tools/logic/README.md
4 changes: 4 additions & 0 deletions tools/logic/logic-rdm-sniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ DEFINE_s_default_bool(display_dmx, d, false,
DEFINE_uint16(dmx_slot_limit, ola::DMX_UNIVERSE_SIZE,
"Only display the first N slots of DMX data.");
DEFINE_uint32(sample_rate, 4000000, "Sample rate in HZ.");
// Set the sample rate. Must be a supported value, i.e.: 24000000, 16000000,
// 12000000, 8000000, 4000000, 2000000, 1000000, 500000, 250000, 200000,
// 100000, 50000, 25000
// TODO(Peter): Trap and report this, don't just crash
DEFINE_string(pid_location, "",
"The directory containing the PID definitions.");

Expand Down
Loading