Add test data and working manchester decoder
This commit is contained in:
parent
8c5c8aee51
commit
66e0f462d3
19 changed files with 2692 additions and 4 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*.wfm
|
||||
__pycache__
|
||||
.ipynb_checkpoints
|
||||
|
|
@ -53,6 +53,12 @@
|
|||
"\n",
|
||||
"downsampling = 500\n",
|
||||
"data = scipy.signal.decimate(data, downsampling, ftype='fir')\n",
|
||||
"off = 6000#wf = rigol.Wfm.from_file('barcode_test_varspeed.wfm', 'DS1054Z')\n",
|
||||
"wf = rigol.Wfm.from_file('barcode_test8.wfm', 'DS1054Z')\n",
|
||||
"data = wf.channels[0].volts\n",
|
||||
"\n",
|
||||
"downsampling = 500\n",
|
||||
"data = scipy.signal.decimate(data, downsampling, ftype='fir')\n",
|
||||
"off = 6000\n",
|
||||
"data = data[off:off+16384]\n",
|
||||
"td = wf.channels[0].seconds_per_point * downsampling\n",
|
||||
|
|
@ -61,6 +67,14 @@
|
|||
"fig, ax = plt.subplots(figsize=(28, 6))\n",
|
||||
"ax.plot(times, data)\n",
|
||||
"ax.set_xlim([times[0], times[-1]])\n",
|
||||
"len(data)\n",
|
||||
"data = data[off:off+16384]\n",
|
||||
"td = wf.channels[0].seconds_per_point * downsampling\n",
|
||||
"times = np.linspace(0, len(data)*td, len(data))\n",
|
||||
"\n",
|
||||
"fig, ax = plt.subplots(figsize=(28, 6))\n",
|
||||
"ax.plot(times, data)\n",
|
||||
"ax.set_xlim([times[0], times[-1]])\n",
|
||||
"len(data)"
|
||||
]
|
||||
},
|
||||
|
|
@ -729,7 +743,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.5"
|
||||
"version": "3.12.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
917
barcode4.ipynb
Normal file
917
barcode4.ipynb
Normal file
File diff suppressed because one or more lines are too long
686
barcode5.ipynb
Normal file
686
barcode5.ipynb
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@ import itertools
|
|||
import textwrap
|
||||
|
||||
import click
|
||||
from reedmuller import reedmuller
|
||||
from reedmuller.reedmuller import ReedMuller
|
||||
|
||||
|
||||
class Tag:
|
||||
|
|
@ -81,15 +81,19 @@ class Tag:
|
|||
@click.argument('outfile', type=click.File('w'), default='-')
|
||||
def cli(data, outfile, height, text, font, font_size, bar_width, margin, color, text_color, dpi):
|
||||
data = int(data, 16)
|
||||
data &= 0x3ffffff
|
||||
text_color = text_color or color
|
||||
|
||||
NUM_BITS = 26
|
||||
rm = ReedMuller(3, 5)
|
||||
|
||||
data_bits = [bool(data & (1<<i)) for i in range(NUM_BITS)]
|
||||
data_bits = [bool(data & (1<<i)) for i in range(rm.message_length())]
|
||||
data_bits = rm.encode(data_bits)
|
||||
print('Payload bits:', ''.join([str(int(x)) for x in data_bits]))
|
||||
data_encoded = itertools.chain(*[
|
||||
(a, not a) for a in data_bits
|
||||
])
|
||||
data_encoded = [True, False, True, False, *data_encoded, False, True, True, False, True]
|
||||
print('Encoded data:', ''.join([str(int(x)) for x in data_encoded]))
|
||||
|
||||
width = len(data_encoded) * bar_width
|
||||
# 1 px = 0.75 pt
|
||||
|
|
|
|||
29
downsample_rigol_wfm.py
Normal file
29
downsample_rigol_wfm.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import lzma
|
||||
|
||||
import click
|
||||
import RigolWFM.wfm as rigol
|
||||
import scipy
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument('infile', type=click.Path(dir_okay=False, exists=True))
|
||||
@click.argument('outfile', type=click.Path(dir_okay=False, path_type=Path), required=False)
|
||||
@click.option('-f', '--factor', type=int, default=500, help='Downsampling factor')
|
||||
def cli(infile, outfile, factor):
|
||||
if outfile is None:
|
||||
outfile = Path(infile).with_suffix('.lzjson')
|
||||
wf = rigol.Wfm.from_file(infile, 'DS1054Z')
|
||||
data = wf.channels[0].volts
|
||||
|
||||
data = scipy.signal.decimate(data, factor, ftype='fir')[::-1]
|
||||
td = wf.channels[0].seconds_per_point * factor
|
||||
|
||||
outfile.write_bytes(lzma.compress(json.dumps({'sample_interval_s': td, 'samples': list(data)}).encode()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
||||
1035
test_sheet_manchester_reed_muller.svg
Normal file
1035
test_sheet_manchester_reed_muller.svg
Normal file
File diff suppressed because it is too large
Load diff
|
After Width: | Height: | Size: 28 KiB |
BIN
waveforms/manchester/manchester_rm_1111111_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_1111111_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_1234567_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_1234567_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_1234567_02.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_1234567_02.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_1234567_03.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_1234567_03.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_1234567_04.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_1234567_04.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_1234567_05.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_1234567_05.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_6666666_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_6666666_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_89abcde_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_89abcde_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_aaaaaaa_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_aaaaaaa_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_ccccccc_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_ccccccc_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_f0f0f0f_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_f0f0f0f_01.lzjson
Normal file
Binary file not shown.
BIN
waveforms/manchester/manchester_rm_ffff000_01.lzjson
Normal file
BIN
waveforms/manchester/manchester_rm_ffff000_01.lzjson
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue