# Dingtian QR reader – Linux configuration tool Replacement for the Windows-only `QRCode_v1_6_5.exe` shipped in the Dingtian QR code reader SDK. Lets you find readers on the LAN, read their configuration and change network, output-format and behaviour settings from Linux (or any OS with Python 3). | file | purpose | |------|---------| | `PROTOCOL.md` | the reverse engineered UDP protocol: frame format, command list, field tables, 720 byte parameter struct, verification status | | `dingtian_qr.py` | reference implementation and CLI (`discover`, `info`, `get`, `set`, `set-network`); importable as a module | ## Requirements * Python 3.6 or newer, standard library only. * The PC must be on the same layer 2 network as the readers for `discover` and `set-network` (they use UDP broadcast). `info`, `get` and `set` are unicast and work across routers. * Host firewall: allow inbound UDP replies to the tool's socket. Readers reply from arbitrary source ports, so do not filter on the reader's source port. ## Usage ``` python3 dingtian_qr.py discover --broadcast 192.168.1.255 # list readers (serial, ip, server...) python3 dingtian_qr.py info 192.168.1.99 # model / firmware / serial python3 dingtian_qr.py get 192.168.1.99 # full configuration (add --raw for numeric codes) python3 dingtian_qr.py set 192.168.1.99 --output-type 3 --buzzer 1 --qr-suffix "hex:0d" python3 dingtian_qr.py set-network --serial HC002721 --ip 192.168.1.50 --netmask 255.255.255.0 \ --gateway 192.168.1.1 --dns1 8.8.8.8 --dns2 8.8.4.4 --server 192.168.1.10 \ --server-port 8080 --http-language 0 --broadcast 192.168.1.255 python3 dingtian_qr.py set --help # every field with its numeric codes ``` `set` reads the current configuration first and only changes the fields you pass; it then sends the same command sequence as the exe's Set button that owns those fields (Format group and/or External group). `set-network` broadcasts and the reader whose serial matches applies the new values, so it also works for a reader whose current IP is in the wrong subnet. A factory reset (pin in the RESET hole on the back) returns the reader to 192.168.1.99. ## Using it from your own code ```python import dingtian_qr as dq for ip, info in dq.discover(broadcast='192.168.1.255'): print(info['serial'], ip) params = dq.get_params('192.168.1.99') # dict, keys documented in parse_params() params['output_type'] = 3 # HTTP params['buzzer'] = 1 dq.set_format('192.168.1.99', params) # commands 6,8,10,38,12,14,44,28 dq.set_external('192.168.1.99', params) # commands 40,18,16,22 ``` ## Caveats * The DHCP setting cannot be written: the original exe never transmits it (see PROTOCOL.md), so the reader's behaviour for it is unknown. * The External commands (buzzer, work mode, fill light, restart interval) were verified on a real reader. The Format commands and set-network were validated only against the exe's own packets and a simulated reader. Test on one reader before rolling out. * Parameter struct words 0x1f4 and the area 0x050–0x197 are not understood (the exe does not use them either).