Skip to content

Conversation

@peternewman
Copy link
Member

@peternewman peternewman commented Mar 9, 2021

This supports a far wider range of devices than just Saleae devices.

  • Extract common LogicReader code into another class so sigrok and Saleae just deal with getting data in
  • Separate folder
  • Separate packaging
  • Connected check for sigrok
  • Readme
  • Non eight-channel LAs
  • Proper connection strings as well as string types

Future extensions:

  • Actually implement --timestamp
  • Decode RDM DUB responses
  • DMX input client from sniffer
  • Alternative input port selection
  • Multi-port simultaneous sniffing (e.g. for testing an RDM splitter)
  • Scopes/analogue inputs

@peternewman peternewman added this to the 0.11.0 milestone Mar 9, 2021
@peternewman
Copy link
Member Author

@kripton I noticed a sigrok related thing in your repos, I don't know if you fancy giving this a little test with whichever logic analyser you have? You might find it really useful for https://github.com/OpenLightingProject/rp2040-dongle/ too!

@kripton
Copy link
Member

kripton commented Mar 10, 2021

Sure, I will give this a try the coming days. I have multiple fx2la devices here, one Open Bench Logic Sniffer and a scope that can be theoretically hooked up to sigrok as well :)

Since I already saw that yesterday:

@peternewman
Copy link
Member Author

Sure, I will give this a try the coming days. I have multiple fx2la devices here, one Open Bench Logic Sniffer and a scope that can be theoretically hooked up to sigrok as well :)

Cool, the logic sniffer should just work (it needs to be on pin 1 currently). In theory the scope should be possible although I haven't tried analogue signals yet, as I can't generate them unless the dummy device does. Happy to have a go at it though and it should be fairly simple too. If you try connecting the scope up can you share some -l 4 and --sigrok-log-level 5 captures of the setup.

* Do you think this could make it as a multi-port input-only OLA-plugin? ;)

I'd never even considered that. Yeah it should be possible and in theory each pin would be an input port with some minimal code changes. Obviously DMX only as it couldn't reply. Perhaps I'll try and mock it up as a client first as I'm not sure what the delay might be like from a signal arriving on the pin to getting into OLA, depending on the blocks of samples being transferred. Do you think people want multi-universe DMX only capture? I guess for a recording setup maybe.

* Are you aware of the "official" DMX512 decoder? https://github.com/sigrokproject/libsigrokdecode/blob/master/decoders/dmx512/pd.py Maybe some RDM decoding capabilities could be included there as well?

I am, I think I submitted some DMX and RDM samples in the past to try and help get it extended.

The main challenge with RDM is it's a lot more complicated. To get something high level you could just decode the command type and list the PID name, but depending on what exactly you're trying to do, you probably want to know the contents of the different PIDs, particularly the discovery stuff which is where things often go wrong, but possibly some other basic initial traffic, at which point you need to implement large chunks of:
https://github.com/OpenLightingProject/ola/blob/master/python/ola/PidStore.py
As well as the UID stuff:
https://github.com/OpenLightingProject/ola/blob/master/python/ola/UID.py

Plus our protobuf stuff to support that. At which point you've reimplemented large chunks of OLA. I guess we could just include OLA's library but I'm not sure if they're really interested in that sort of approach. Finally from my brief playing with PulseView/sigrok this time around, I wasn't really sure how suitable it actually was for that purpose. When you're doing discovery of a few fixtures you're quickly into tens of messages which just seemed to result in a lot of scrolling from my brief experience. Compared to something like Wireshark which seems better suited to that type of messaging.

All I've done in comparison in this PR is connected a different source of samples into the existing DMXSignalProcessor code, I've written very little new or novel code here.

I do mean to get in touch with the sigrok team about it, perhaps they'll be able to signpost to this or maybe they'll want to write a full decoder themselves.

@kripton
Copy link
Member

kripton commented Mar 12, 2021

Okay, first results. I tried the scope in pulseview first. I was able to see my DMX frames but I was unable to do continuously capturing. And reading from the scope's memory (over LAN, didn't yet try USB) was about 64kByte/s. Don't know why but I stopped there.

Then I hooked up my FX2LAFW device. With pulseview no problems, continuous capture at 1MHz, 1 channel and DMX data was clearly visible. The internal decoder did lots of mis-interpretations but attached fixtures took the signal all well.

Finally, I tried the sigrok_rdm_sniffer but it didn't take the signal all that well:

kripton@momo / $ sigrok-cli --scan
The following devices were found:
demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4
fx2lafw:conn=1.8 - sigrok FX2 LA (16ch) with 16 channels: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15

Results:

kripton@momo ~ $ sigrok_rdm_sniffer --sigrok-log-level 2 --sigrok-device "fx2lafw" -d -l 3
tools/logic/sigrok-rdm-sniffer.cpp:722: Running...
common/thread/Thread.cpp:200: Thread , policy SCHED_OTHER, priority 0
tools/logic/sigrok-rdm-sniffer.cpp:285: Got driver: fx2lafw - fx2lafw (generic driver for FX2 based LAs)
tools/logic/sigrok-rdm-sniffer.cpp:307: Found 1 devices
tools/logic/sigrok-rdm-sniffer.cpp:314: Found device (using first):
tools/logic/sigrok-rdm-sniffer.cpp:316:         Vendor: sigrok
tools/logic/sigrok-rdm-sniffer.cpp:318:         Model: FX2 LA (16ch)
tools/logic/sigrok-rdm-sniffer.cpp:320:         Version: 
tools/logic/sigrok-rdm-sniffer.cpp:347: Initial sample rate is 20000Hz
tools/logic/sigrok-rdm-sniffer.cpp:360: New sample rate is 4000000Hz
tools/logic/sigrok-rdm-sniffer.cpp:403: Sigrok will capture continuously
tools/logic/sigrok-rdm-sniffer.cpp:182: Sigrok header for fx2lafw got header
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 0 us (0 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 0.25 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 0.25 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 0.25 us (1 ticks)
(continues with lots of those messages, no valid DMX data seen)

I then changed the sample rate to 1MHz but results were similar:

kripton@momo ~ $ sigrok_rdm_sniffer --sigrok-log-level 2 --sigrok-device "fx2lafw" -d -l 3 --sample-rate 1000000
tools/logic/sigrok-rdm-sniffer.cpp:722: Running...
common/thread/Thread.cpp:200: Thread , policy SCHED_OTHER, priority 0
tools/logic/sigrok-rdm-sniffer.cpp:285: Got driver: fx2lafw - fx2lafw (generic driver for FX2 based LAs)
tools/logic/sigrok-rdm-sniffer.cpp:307: Found 1 devices
tools/logic/sigrok-rdm-sniffer.cpp:314: Found device (using first):
tools/logic/sigrok-rdm-sniffer.cpp:316:         Vendor: sigrok
tools/logic/sigrok-rdm-sniffer.cpp:318:         Model: FX2 LA (16ch)
tools/logic/sigrok-rdm-sniffer.cpp:320:         Version: 
tools/logic/sigrok-rdm-sniffer.cpp:347: Initial sample rate is 20000Hz
tools/logic/sigrok-rdm-sniffer.cpp:360: New sample rate is 1000000Hz
tools/logic/sigrok-rdm-sniffer.cpp:403: Sigrok will capture continuously
tools/logic/sigrok-rdm-sniffer.cpp:182: Sigrok header for fx2lafw got header
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 0 us (0 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 17 us (17 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)

The DMX line is directly (= TTL level, no RS-485 bus drivers and receivers involved) hooked up D0 (= PB0 on my board). And pulseview is happy as well (picture uploading fails due to a CORS error?)

@kripton
Copy link
Member

kripton commented Mar 12, 2021

And something about the cli parameters seems wrong. The FX2LA-device is shown in sigrok-cli --scan as fx2lafw:conn=1.8. However, when I specify this as value for --sigrok-device at the sigrok_rdm_sniffer, it tells me: tools/logic/sigrok-rdm-sniffer.cpp:291: Failed to find driver fx2lafw:conn=1.8. When I only specify the driver without giving a specific device, it will pick the first device offered by that driver.

With the scope (driver rigol-ds) it's different. The driver supports USB or LAN. USB might work with autodetect, LAN needs the IP address. sigrok-cli -d rigol-ds:conn=tcp-raw/192.168.3.16/5555 -l 5 --scan gives:

sr: [00:00.000001] log: libsigrok loglevel set to 5.
sr: [00:00.000060] backend: libsigrok 0.5.2/5:1:1.
sr: [00:00.000139] backend: Libs: glib 2.66.4 (rt: 2.66.7/6607:7), libzip 1.7.3, libserialport 0.1.1/1:0:1 (rt: 0.1.1/1:0:1), libusb-1.0 1.0.24.11586 API 0x01000108, hidapi 0.8.0-rc1, bluez 5.55, libftdi 1.5.
sr: [00:00.000160] backend: Host: x86_64-pc-linux-gnu, little-endian.
sr: [00:00.000172] backend: SCPI backends: TCP, serial, USBTMC.
sr: [00:00.000180] backend: Firmware search paths:
sr: [00:00.000252] backend:  - /home/kripton/.local/share/sigrok-firmware
sr: [00:00.000265] backend:  - /usr/share/sigrok-firmware
sr: [00:00.000273] backend:  - /usr/local/share/sigrok-firmware
sr: [00:00.000286] backend:  - /usr/share/sigrok-firmware
sr: [00:00.000325] backend: Sanity-checking all drivers.
sr: [00:00.000341] backend: Sanity-checking all input modules.
sr: [00:00.000355] backend: Sanity-checking all output modules.
sr: [00:00.000375] backend: Sanity-checking all transform modules.
srd: libsigrokdecode loglevel set to 5.
sr: [00:00.003782] hwdriver: sr_config_list(): key 2147418112 (NULL) sdi (nil) cg NULL -> [uint32 20000, 20001]
sr: [00:00.003817] scpi: Opening RAW TCP device tcp-raw/192.168.2.82/5555.
sr: [00:00.022901] scpi_tcp: Successfully sent SCPI command: '*IDN?'.
sr: [00:00.026305] scpi: Got response: 'RIGOL TECHNOLOGIES,DS1104Z,DS1ZA194820861,00.04.04.SP3', length 54.
sr: [00:00.026443] hwdriver: Scan found 1 devices (rigol-ds).
The following devices were found:
rigol-ds - Rigol DS1104Z 00.04.04.SP3 with 4 channels: CH1 CH2 CH3 CH4
sr: [00:00.026537] hwdriver: Cleaning up all drivers.

So the correct "sigrok device string" including driver and device would be rigol-ds:conn=tcp-raw/192.168.3.16/5555. This value fails with the rdm sniffer:

kripton@momo ~ $ sigrok_rdm_sniffer --sigrok-device "rigol-ds:conn=tcp-raw/192.168.2.82/5555" --sigrok-log-level 5
sr: [00:00.000000] log: libsigrok loglevel set to 5.
sr: [00:00.000089] backend: libsigrok 0.5.2/5:1:1.
sr: [00:00.000152] backend: Libs: glib 2.66.4 (rt: 2.66.7/6607:7), libzip 1.7.3, libserialport 0.1.1/1:0:1 (rt: 0.1.1/1:0:1), libusb-1.0 1.0.24.11586 API 0x01000108, hidapi 0.8.0-rc1, bluez 5.55, libftdi 1.5.
sr: [00:00.000169] backend: Host: x86_64-pc-linux-gnu, little-endian.
sr: [00:00.000179] backend: SCPI backends: TCP, serial, USBTMC.
sr: [00:00.000187] backend: Firmware search paths:
sr: [00:00.000221] backend:  - /home/kripton/.local/share/sigrok-firmware
sr: [00:00.000229] backend:  - /usr/share/sigrok-firmware
sr: [00:00.000235] backend:  - /usr/local/share/sigrok-firmware
sr: [00:00.000240] backend:  - /usr/share/sigrok-firmware
sr: [00:00.000265] backend: Sanity-checking all drivers.
sr: [00:00.000275] backend: Sanity-checking all input modules.
sr: [00:00.000282] backend: Sanity-checking all output modules.
sr: [00:00.000291] backend: Sanity-checking all transform modules.
tools/logic/sigrok-rdm-sniffer.cpp:291: Failed to find driver rigol-ds:conn=tcp-raw/192.168.2.82/5555

When only naming the driver "rigol-ds", without specifying a device, the driver is poked for a device but doesn't find one.

@kripton
Copy link
Member

kripton commented Mar 12, 2021

Okay, the thing with the scope in pulseview is a bug in the current sigfox release. Fixed in git but no release since then:
sigrokproject/libsigrok@704910e and sigrokproject/libsigrok@1cbb3b1

@peternewman
Copy link
Member Author

Okay, first results. I tried the scope in pulseview first. I was able to see my DMX frames but I was unable to do continuously capturing. And reading from the scope's memory (over LAN, didn't yet try USB) was about 64kByte/s. Don't know why but I stopped there.

I had issues with continuous capturing with a FX2LAFW in older releases. I assume your scope channels are listed as analogue, in which case they won't work until I write more code.

Then I hooked up my FX2LAFW device. With pulseview no problems, continuous capture at 1MHz, 1 channel and DMX data was clearly visible. The internal decoder did lots of mis-interpretations but attached fixtures took the signal all well.

It probably doesn't bode too well if the built in decoder didn't like it. Was it just bit length issues?

Finally, I tried the sigrok_rdm_sniffer but it didn't take the signal all that well:

kripton@momo / $ sigrok-cli --scan
The following devices were found:
demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4
fx2lafw:conn=1.8 - sigrok FX2 LA (16ch) with 16 channels: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15

Ah, I think I know what's happening, my naive implementation is ignore the channel and capture width so effectively is alternating between D0 and D9 values. I think you could prove this by either adding some printing to DMXSignalProcessor::ProcessSample, perhaps tying one high and one low, or electrically coupling D0 and D9 to the same input. I think I removed all the useful debug from those bits of code.

This would tie up with it changing nearly every tick regardless of the frequency.

The DMX line is directly (= TTL level, no RS-485 bus drivers and receivers involved) hooked up D0 (= PB0 on my board). And pulseview is happy as well

Yeah that makes sense, and should work I think.

picture uploading fails due to a CORS error?

GitHub does seem to have got a little flaky recently.

@peternewman
Copy link
Member Author

And something about the cli parameters seems wrong. The FX2LA-device is shown in sigrok-cli --scan as fx2lafw:conn=1.8. However, when I specify this as value for --sigrok-device at the sigrok_rdm_sniffer, it tells me: tools/logic/sigrok-rdm-sniffer.cpp:291: Failed to find driver fx2lafw:conn=1.8. When I only specify the driver without giving a specific device, it will pick the first device offered by that driver.

The code for that bit was inspired by the collectd plugin:
https://collectd.org/wiki/index.php/Plugin:sigrok

I might try and offer both options, as the existing means you can juse use fx2lafw and not worry about which port it's connected to, but as you say you can't pass more options or potentially control which LA if you've got two.

With the scope (driver rigol-ds) it's different. The driver supports USB or LAN. USB might work with autodetect, LAN needs the IP address. sigrok-cli -d rigol-ds:conn=tcp-raw/192.168.3.16/5555 -l 5 --scan gives:

Yeah I hadn't even considered those sort of settings.

@kripton
Copy link
Member

kripton commented Mar 12, 2021

I had issues with continuous capturing with a FX2LAFW in older releases. I assume your scope channels are listed as analogue, in which case they won't work until I write more code.

True, the DMX decoder only works on binary data. Pulseview can convert the analog channel to a digital one, that's not the issue. I've built libsigrok from git master by now and the capture is much more stable now. The DMX decoder is still flaky: The two STOP bits of the START CODE are detected properly. The, the START bit of channel 1 follows but the decoder interprets it as "INTERFRAME". Thus, every byte shifts the decoder by one bit.... Trying to attach a picture: (Failed again ...)

It probably doesn't bode too well if the built in decoder didn't like it. Was it just bit length issues?

Nope, actually same as above. The built-in DMX decoder behaves the same, no matter if the data is captured via scope of FX2 device.
I'll open and decode the DMX samples from the sigrok homepage tomorrow.

Ah, I think I know what's happening, my naive implementation is ignore the channel and capture width so effectively is alternating between D0 and D9 values. I think you could prove this by either adding some printing to DMXSignalProcessor::ProcessSample, perhaps tying one high and one low, or electrically coupling D0 and D9 to the same input. I think I removed all the useful debug from those bits of code.

Ah, you're saying that your LA has 8 channels, mine has 16 and your code is hard-coded for 8 channels?

Bridging PB0 (D0) to PD0 (D8) or PD1 (D9) doesn't change much, still lots of errors and no useful data.

However, the output is different:

DB0 bridged to PD0:

tools/logic/sigrok-rdm-sniffer.cpp:360: New sample rate is 1000000Hz
tools/logic/sigrok-rdm-sniffer.cpp:403: Sigrok will capture continuously
tools/logic/sigrok-rdm-sniffer.cpp:182: Sigrok header for fx2lafw got header
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 0 us (0 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 58 us (58 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 58 us (58 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 16 us (16 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 72 us (72 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 72 us (72 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 16 us (16 ticks)

DB0 bridged to PD1:

tools/logic/sigrok-rdm-sniffer.cpp:360: New sample rate is 1000000Hz
tools/logic/sigrok-rdm-sniffer.cpp:403: Sigrok will capture continuously
tools/logic/sigrok-rdm-sniffer.cpp:182: Sigrok header for fx2lafw got header
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 0 us (0 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 1 us (1 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 1 us (1 ticks

GitHub does seem to have got a little flaky recently.

Yep, also experienced other issues the last two week :(

@kripton
Copy link
Member

kripton commented Mar 12, 2021

Regarding the incorrect decoding of obviously valid DMX in pulseview: As with my scope: "Fixed in git, no release since then":
https://sigrok.org/bugzilla/show_bug.cgi?id=1442 and sigrokproject/libsigrokdecode@dca19fb
Exactly what I have been experiencing. Looks like I also need to build libsigrokdecode from git HEAD ;)

@kripton
Copy link
Member

kripton commented Mar 12, 2021

I might try and offer both options, as the existing means you can juse use fx2lafw and not worry about which port it's connected to, but as you say you can't pass more options or potentially control which LA if you've got two.

With the scope (driver rigol-ds) it's different. The driver supports USB or LAN. USB might work with autodetect, LAN needs the IP address. sigrok-cli -d rigol-ds:conn=tcp-raw/192.168.3.16/5555 -l 5 --scan gives:

Yeah I hadn't even considered those sort of settings.

So what about this: When only a driver is specified (as with --sigrok-device fx2la), it chooses the first device, just as now. If parameters (separated from the driver name by a colon) are present, they are passed to the driver.

I had to use the --sigrok-device parameter in any case. If it was missing, it used the demo device: demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4. That of course might never produce valid DMX data.

@peternewman
Copy link
Member Author

True, the DMX decoder only works on binary data. Pulseview can convert the analog channel to a digital one, that's not the issue.

No, but it will be an issue with this code, which rejects any non-logic packets.

I've built libsigrok from git master by now and the capture is much more stable now.

That's good to hear.

The DMX decoder is still flaky: The two STOP bits of the START CODE are detected properly. The, the START bit of channel 1 follows but the decoder interprets it as "INTERFRAME". Thus, every byte shifts the decoder by one bit.... Trying to attach a picture: (Failed again ...)

I wonder if that's our bug too?

Ah, I think I know what's happening, my naive implementation is ignore the channel and capture width so effectively is alternating between D0 and D9 values. I think you could prove this by either adding some printing to DMXSignalProcessor::ProcessSample, perhaps tying one high and one low, or electrically coupling D0 and D9 to the same input. I think I removed all the useful debug from those bits of code.

Ah, you're saying that your LA has 8 channels, mine has 16 and your code is hard-coded for 8 channels?

Yeah, it tries to process the first bit of every byte of sampled logic data, there's a flag present which I'm currently ignoring which would deal with that.

Bridging PB0 (D0) to PD0 (D8) or PD1 (D9) doesn't change much, still lots of errors and no useful data.

However, the output is different:

DB0 bridged to PD0:

tools/logic/sigrok-rdm-sniffer.cpp:360: New sample rate is 1000000Hz
tools/logic/sigrok-rdm-sniffer.cpp:403: Sigrok will capture continuously
tools/logic/sigrok-rdm-sniffer.cpp:182: Sigrok header for fx2lafw got header
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 0 us (0 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 58 us (58 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 58 us (58 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 16 us (16 ticks)
tools/logic/DMXSignalProcessor.cpp:121: Break too short, was 72 us (72 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 1, prev duration was 72 us (72 ticks)
tools/logic/DMXSignalProcessor.cpp:287: Transition to 2, prev duration was 16 us (16 ticks)

That does look more promising. It might be worth trying at 4Mhz (which is all we've really tested at). Did you wait a while for data to run through, and what channel data are you using (all full, all off, or real random data)? Come to think of it, I think my tests are still only sending 20 channels which probably isn't great either, but I think should work. In your case worst case it may have to process an entire frame before it finds the break and locks on. If you run it with -d and possibly lower the log levels, it should just output DMX lines every good frame.

@peternewman
Copy link
Member Author

So what about this: When only a driver is specified (as with --sigrok-device fx2la), it chooses the first device, just as now. If parameters (separated from the driver name by a colon) are present, they are passed to the driver.

I'll have a look at their code and see how guaranteed that is, or just offer two flags.

I had to use the --sigrok-device parameter in any case. If it was missing, it used the demo device: demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4. That of course might never produce valid DMX data.

Oops, yeah I should remove that test code! I didn't get it to decode but I didn't try for too long (I think it has a restricted pattern of data).

@peternewman
Copy link
Member Author

That does look more promising. It might be worth trying at 4Mhz (which is all we've really tested at). Did you wait a while for data to run through, and what channel data are you using (all full, all off, or real random data)? Come to think of it, I think my tests are still only sending 20 channels which probably isn't great either, but I think should work. In your case worst case it may have to process an entire frame before it finds the break and locks on. If you run it with -d and possibly lower the log levels, it should just output DMX lines every good frame.

I realised by paralleling workaround was unlikely to work properly @kripton as the frequency of the signal would be halved because it would get two samples where it should only be getting one. Anyway I know honour the unit width field. If it doesn't just burst into life with the logic analyser, can you share up to the first couple of transition/break to short with at least -l 4 and ideally --sigrok-log-level 5 so I can try and work out what's going on. But maybe it will just work. 🤞

I've not done anything on proper driver config strings yet, or the analogue reading of your scope (which given they are linked won't have much impact as far as I'm aware so I might push that into a future PR.

@kripton
Copy link
Member

kripton commented Mar 16, 2021

I had to use the --sigrok-device parameter in any case. If it was missing, it used the demo device: demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4. That of course might never produce valid DMX data.

Oops, yeah I should remove that test code! I didn't get it to decode but I didn't try for too long (I think it has a restricted pattern of data).

Are you sure that this is in your code? I can also see that demo device when I run sigrok-cli --scan. So it seems to be provided by libsigrok.

@kripton
Copy link
Member

kripton commented Mar 16, 2021

I realised by paralleling workaround was unlikely to work properly @kripton as the frequency of the signal would be halved because it would get two samples where it should only be getting one. Anyway I know honour the unit width field. If it doesn't just burst into life with the logic analyser, can you share up to the first couple of transition/break to short with at least -l 4 and ideally --sigrok-log-level 5 so I can try and work out what's going on. But maybe it will just work. crossed_fingers

Oh, great. You're right, the frequency would be halved. However, with 1MHz sample rate configured, I'd expect to sample with 500kHz, which should be okay to sample DMX data.
I'll re-test your code the following days, today if I can make it.
Besides the FX2-based devices, I also have one HydraBus here that I would like to test sometime. It should work fine with sigrok (hydrabus/hydrafw#82) but I didn't yet try that.

I've not done anything on proper driver config strings yet, or the analogue reading of your scope (which given they are linked won't have much impact as far as I'm aware so I might push that into a future PR.

Don't worry so much about the scope. The configuration is already so difficult in pulseview and/or the data rate for the analog values is too low. It helps a lot to see the actual signal in pulseview but I would be really surprised if it can be managed to get this working reliably and easy from the command line.

@peternewman
Copy link
Member Author

Oops, yeah I should remove that test code! I didn't get it to decode but I didn't try for too long (I think it has a restricted pattern of data).

Are you sure that this is in your code? I can also see that demo device when I run sigrok-cli --scan. So it seems to be provided by libsigrok.

Yes, well sort of, my code no longer defaults to demo and instead complains if you've omitted the --sigrok-device argument:
7ac19eb

Oh, great. You're right, the frequency would be halved. However, with 1MHz sample rate configured, I'd expect to sample with 500kHz, which should be okay to sample DMX data.

Yes, but the code doesn't actually do timing in the traditional sense (i.e. end-start), it just counts samples, so if you give it a 1MHz sample rate, it works out each sample will last 1 microsecond. If you consider something lasting for four sampling periods on an eight channel LA, i.e. 4 microseconds, because you've paralleled them, it counts it twice and gets a duration of 8 microseconds. Whether this is acceptable or not I'd need to check the docs and would depend on your source DMX refresh rate too I'd imagine.

I'll re-test your code the following days, today if I can make it.

Excellent thanks!

Besides the FX2-based devices, I also have one HydraBus here that I would like to test sometime. It should work fine with sigrok (hydrabus/hydrafw#82) but I didn't yet try that.

Cool, in theory it shouldn't care at all, as long as it (currently has logic outputs) and a sufficient sample rate, it should just work regardless.

Don't worry so much about the scope. The configuration is already so difficult in pulseview and/or the data rate for the analog values is too low. It helps a lot to see the actual signal in pulseview but I would be really surprised if it can be managed to get this working reliably and easy from the command line.

Ah that's interesting, I assumed it would sample okay, but I guess the data rate has to be much higher to get the analogue level of detail. Perhaps I will park that for now. I guess I'd be curious if you can get the scope to decode DMX in PulseView in which case it might be worthwhile investigating in future.

@kripton
Copy link
Member

kripton commented Mar 16, 2021

Yes, well sort of, my code no longer defaults to demo and instead complains if you've omitted the --sigrok-device argument:
7ac19eb

Yes, I can confirm that and I agree that it makes sense.

Excellent thanks!

Re-tested, working :)
DMX 512:17 36 64 9f e0 00 ff 00 00 00 .... Just the values I would've expected. Nice 👍
Unfortunately, no RDM capable Interface here, yet. And right now, the Arduino is configured as RDM responder, not controller.

Cool, in theory it shouldn't care at all, as long as it (currently has logic outputs) and a sufficient sample rate, it should just work regardless.

Yes. The big advantage of the FX2-based boards is that they can do continuous sampling. Most other devices I have here, including the HydraBus and the "original" OpenLogicSniffer allocate some memory and can hold a limited amount of samples. Depending on channel count and sample rate, this ranges from a few µs to several ms.

I didn't try the HydraBus in PulseView since the number of samples at the sample rate we need is way too low. I did try the original OpenLogicSniffer and it displays the correct bits in PulseView. However the number of samples at 500kHz is limited to about 2 DMX frames. For it to work with the sigrok_rdm_sniffer, I need to pass the path of the serial port device to the ols driver (--sigrok-device ols:conn=/dev/ttyACM1) and that doesn't yet seem to work. FX2LA is all good :)

Ah that's interesting, I assumed it would sample okay, but I guess the data rate has to be much higher to get the analogue level of detail. Perhaps I will park that for now. I guess I'd be curious if you can get the scope to decode DMX in PulseView in which case it might be worthwhile investigating in future.

Yes, I managed to decode DMX512 with pulseview. But not in realtime. Capture (triggered on the TXEN line), tranfser to pulseview, decode. Interesting to see rise and fall times but not actually interesting to capture any live DMX or RDM data with it.

Copy link
Member

@kripton kripton left a comment

Choose a reason for hiding this comment

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

Minor inline comments

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!

@peternewman
Copy link
Member Author

Re-tested, working :)
DMX 512:17 36 64 9f e0 00 ff 00 00 00 .... Just the values I would've expected. Nice +1

🥳 🎉

I've also still not tested recent code with a full size frame, so glad to see that works too!

Unfortunately, no RDM capable Interface here, yet. And right now, the Arduino is configured as RDM responder, not controller.

Yeah no worries, I accidentally tested it when I started the sniffer before my olad generator and it did a universe discovery. It should all just work though given it's just different start codes and that worked fine in the original Logic sniffer. I think the only outstanding thing here would be to analyse and decode the DUB response.

Yes. The big advantage of the FX2-based boards is that they can do continuous sampling. Most other devices I have here, including the HydraBus and the "original" OpenLogicSniffer allocate some memory and can hold a limited amount of samples. Depending on channel count and sample rate, this ranges from a few µs to several ms.

Ah I didn't realise the FX2 ones were somewhat unique in that regard. Yeah not being able to do continuous would be a real pain with all my past experience of using these.

I did try the original OpenLogicSniffer and it displays the correct bits in PulseView. However the number of samples at 500kHz is limited to about 2 DMX frames.

Personally I think that would just be hugely frustrating debugging RDM stuff, even if you got a couple more frames of RDM out, due to smaller packet sizes.

Yes, I managed to decode DMX512 with pulseview. But not in realtime. Capture (triggered on the TXEN line), tranfser to pulseview, decode. Interesting to see rise and fall times but not actually interesting to capture any live DMX or RDM data with it.

Okay, perhaps I'll park that for now then.

@kripton
Copy link
Member

kripton commented May 20, 2021

Hey Peter, great to see code updates in this PR! I'd love to test them right away but unfortunately, we are relocating and most stuff (including the logic analyzers) is already packed. Just wanted to inform you that I'm monitoring this here but can't give solid feedback right now :)

@peternewman
Copy link
Member Author

Hey Peter, great to see code updates in this PR!

I'm impressed to see you're watching it at the commit level!

I'd love to test them right away but unfortunately, we are relocating and most stuff (including the logic analyzers) is already packed.

Damn, you were potentially on my list at some point to ping, although realistically since you last tried it I've only been doing some refactoring so shouldn't have broken anything! 🤞

I suspect I might get the main bits done then merge this PR, then possibly park the enhancements for the future. I was also toying with implementing some other decoders for some of the other standardised ASCs, probably mostly just for the fun of it, I'm not sure how much they exist in the wild.

I assume that's also why there's not been much activity on the RP2040 is it?

@kripton
Copy link
Member

kripton commented May 20, 2021

Well, I subscribed to this PR, so I got an email ;)
Oh yes, rp2040-dongle is doing very well: https://github.com/kripton/rp2040-dongle/tree/rewrite. Don't want to cross-post much, but it has a webserver running, it can detect an nrf24 module and use it for channel scanning, it detects the IO modules and could read a config from them or the internal flash as fallback. Individual channels can be set via HTTP (not realtime capable) and dmx buffers can be fetched via HTTP in a compressed form (to prove compression and base64 are working). Lots of things still missing, though. And not much progress on hardware things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants