[-] emirmrkaljevic@programming.dev 1 points 21 hours ago

Fair point, autoexpect does take the typing out of it. It still records one session that you drive yourself though. What I wanted was the step before that: read the tool's --help, try lots of flag combinations and odd inputs on its own, and keep hundreds of cases without me deciding each one. Then replay them against the rewrite. For a few interactive flows, autoexpect is probably the better tool.

[-] emirmrkaljevic@programming.dev 2 points 22 hours ago

Not automatically, which is part of the problem. The 30-day rule (Article 6a of the Price Indication Directive, added by the Omnibus directive) covers announced price reductions: if a shop says the price went down, the "before" price has to be its lowest price of the last 30 days. The Court of Justice confirmed in the Aldi Sued case (C-330/23, 2024) that a percentage like -30% also has to be calculated from that 30-day low.

A comparison with an RRP is treated as a different thing. The Commission guidance says it is not a price reduction in that sense, so it is allowed as long as it is clearly labelled as the manufacturer's recommended price and not presented as the shop's own earlier price. If it gives the impression of a reduction, it can still be misleading under the unfair commercial practices rules, but that is judged case by case and enforcement varies a lot by country.

In practice a lot of shops sit right in that grey zone: big crossed-out RRP, discount badge, and the 30-day low in small print. That is exactly the case the add-on flags as "inflated".

4

The little 3.5" and 5" USB screens people put in PC cases (and on desks as stat displays) are fun to hack on, but most of them only ship a Windows app. If you capture what that app sends, 99% of the bytes are picture data, and the handful of real commands (brightness, orientation, "start frame") are easy to miss in between.

I wrote up what helped me separate them: JPEG frames give themselves away with FF D8 at the start and FF D9 at the end, raw RGB565 frames are exactly width x height x 2 bytes and look like slowly changing 16-bit values, and the commands are the short transfers that sit right before each frame or show up when you move a slider. Once you know the frame size, the short header in front of it (size, coordinates, a counter) usually falls out quickly.

The write-up uses examples from usb-rea, an open-source tool I made that does this split on a capture automatically and drafts a small Python driver, but the checks work just as well by hand in Wireshark.

If you have one of these screens that nothing on Linux supports yet, I am curious which ones, there are a lot of rebadged variants out there.

True, for a handful of hand-written cases expect works fine. The part I wanted to automate is before that: generating a few hundred cases from the tool's --help, recording what the original binary does on each, and then grouping the diffs when the same cases run against another binary. Writing that many cases by hand is where I always gave up. For interactive prompts expect is still the right tool, behave only covers non-interactive runs (arguments, stdin and files).

8

When someone rewrites a command line tool in another language, the hard question is not "does it pass its tests" but "does it still do what the old one did" in all the small corners nobody wrote a test for.

I built a small open source tool for that, behave (Go, MIT): https://github.com/emirmrkaljevic/behave . It reads a tool's --help, generates a few hundred cases (every flag, a few values each, some stdin and file inputs), records stdout, stderr, exit code and touched files from the original binary, then replays the same cases against the rewrite and groups the diffs. The recording is plain YAML you can read and commit.

I pointed it at the Rust rewrites of GNU coreutils, findutils, sed and procps. So far that turned into 44 upstream bug reports and 51 fix PRs, 34 of them merged. The linked post is about the second rewrite (findutils and sed) and which kinds of differences kept showing up: error wording, exit codes and option parsing corners rather than crashes.

Happy to hear where this approach falls short.

54

Since 2022 the Omnibus rule says that when a shop in the EU advertises a price reduction, it has to show the lowest price of the last 30 days. Many shops still put a big crossed-out RRP next to the price and hide the 30-day low in small print, so a -50% badge can be closer to -5% in reality.

I got tired of scrolling for that line, so I wrote truediscount. On a product page it finds the 30-day lowest price label (German, French, Italian, Spanish, Dutch, Polish and a few more languages), compares it with the claimed discount and shows a small badge: real discount, inflated, or it was cheaper recently. It also keeps a local price graph for pages you visit.

It is made in Europe, free and MIT licensed. No account, no server, no tracking, all data stays in your browser. It works out of the box on Zalando, MediaMarkt/Saturn, Lidl, Alternate, Notino, About You, Komputronik and others, and you can enable it for any other shop with one click.

Firefox: https://addons.mozilla.org/en-US/firefox/addon/truediscount/ Source and userscript: https://github.com/emirmrkaljevic/truediscount

Disclaimer: I am the developer of this add-on.

11

I wrote this for hardware that only ships a Windows app (case LCDs, RGB controllers, AIO coolers, mice). You record USB traffic while clicking through the vendor app (usbmon on Linux, USBPcap on Windows), note what each click did, and usb-rea infers the command layout: constant bytes, counters, value fields with their scaling, lookup tables, checksums and CRCs, handshakes and image streams. Output is a Markdown report where every claim points at Wireshark frame numbers, plus a standalone pyusb driver.

A few Python-side details that might interest people here:

  • The pcap and pcapng parsing is plain standard library, so the only runtime dependency besides the optional MCP server is pyusb.
  • Linear field fits have to survive leave-one-out cross-checks before they are reported, so it says "unknown" rather than guessing.
  • usb-rea demo --device fan generates a synthetic capture and runs the whole pipeline, so you can try it with no hardware.

It is MIT licensed and on PyPI (pip install usb-rea). On known protocols, for example the NZXT Kraken X fan command from liquidctl, it recovers the packet format byte for byte. Feedback on the code or the inference approach is welcome.

12

I have been sending small fixes to uutils, the Rust rewrites of coreutils, findutils, sed and procps. The way I find the bugs is simple: record how the GNU tool behaves on a few hundred cases (stdout, stderr, exit code, files it touches), then replay the same cases against the uutils build and read the diffs.

The write-up is about what that turned up. Almost nothing was a crash. It was error message wording, option parsing edge cases like a bare - being eaten as an option value, exit codes, and a few GNU version differences that look like bugs but are really version pins.

So far that is 44 bug reports and 51 fix PRs upstream, 34 of them merged. The recorder is a small open source tool I wrote: https://github.com/emirmrkaljevic/behave

Happy to hear how others test rewrites for compatibility.

9

A lot of cheap hardware (case LCD screens, RGB controllers, macro pads, some mice) only ships with a Windows app, but the USB protocol behind it is usually simple: a fixed header, a command byte, a few value bytes, sometimes a checksum.

The workflow that has worked for me:

  1. Run the vendor app on Windows (or in a VM with USB passthrough) and capture with USBPcap, or with usbmon on the Linux host if it's a VM.
  2. Change exactly one thing at a time (color red, wait, color blue, wait, brightness down) and write down when.
  3. Diff the packets between those actions. The bytes that change with your action are the parameters, the ones that never change are the header.
  4. Replay the packets from Linux with pyusb or hidapi, then turn that into a small driver or a udev + script setup.

I built usb-rea to automate steps 3 and 4: it reads the pcapng, groups the packets by action, infers the command layout (headers, counters, length fields, checksums) and writes a Markdown report (every claim linked to Wireshark frame numbers) plus a standalone pyusb driver. It's a CLI and also an MCP server, so an AI assistant can drive the analysis. I check it in CI against devices that are already documented: from NZXT Kraken X captures it recovers the fan command byte for byte as liquidctl sends it, and the same for the SteelSeries Rival 100 tables from rivalcfg.

https://github.com/emirmrkaljevic/usb-rea

Before reversing anything, check OpenRGB, liquidctl and the device's GitHub issues first, someone has often done it already. Happy to look at a capture if anyone has a device stuck on Windows.

Thanks. If you go for one of the cheaper decks, check DeckBridge and python-elgato-streamdeck first, a lot of the MiraBox/Ajazz style clones are already covered there, so you might not need to reverse anything.

Partly. The capture side is USB specific (it reads usbmon/USBPcap pcapng, endpoints and control setup packets), but the inference part is not: it diffs payloads between labelled actions and looks for constant headers, counters, length fields, checksums and value fields. Network protocols would mostly need a different front end that feeds it TCP/UDP payloads. That isn't built in today. For network protocols Netzob is worth a look, it has been doing that kind of inference for years. File formats are harder because you rarely get clean "I changed exactly one thing" pairs, but the same diffing trick works if you save the file twice with one setting changed.

[-] emirmrkaljevic@programming.dev -3 points 4 days ago

Yes, I used AI coding tools a lot while building it, both for the Go code and for working through the uutils differences. The part I care about is that everything is checkable: the specs are plain files recorded from the real GNU binaries, every reported difference is a command plus expected and actual output you can rerun yourself, and the upstream fixes went through normal review by the uutils maintainers before they were merged.

83

A lot of small hardware (AIO cooler screens, RGB hubs, stream decks, case LCDs) only ships a Windows app, and the usual route to Linux support is someone staring at Wireshark for an evening. I built usb-rea to do the step after Wireshark.

You capture with usbmon on Linux or USBPcap on Windows, label what you clicked in the vendor app (brightness 0, 50, 100, fan 30%, and so on), and it infers the command layout: constant headers, which byte follows which setting, counters, checksums like CRC16, lookup tables and image streams. It then writes a Markdown report where every claim points to Wireshark frame numbers, plus a standalone pyusb driver.

On public captures of the NZXT Kraken X it recovers the fan command byte for byte as liquidctl sends it, and the generated driver produces identical packets for values it never saw. It is alpha, MIT, pip install usb-rea, and usb-rea demo --device fan runs without any hardware.

If you have a device that only works on Windows, I am happy to run a capture through it and post the result.

-3

I made a small tool for a problem I kept hitting when looking at rewrites of classic command line tools (uutils coreutils, gojq, ripgrep style replacements): how do you know the new binary really behaves like the old one?

behave runs the original tool as a black box with a lot of generated inputs and flags, records stdout, stderr, exit code and file changes into plain spec files, and then replays those specs against the rewrite. Every difference shows up as a small diff.

Running it on uutils coreutils against GNU coreutils turned up 44 differences so far, which led to 51 upstream pull requests, 34 of them merged.

It is a single Go binary (MIT), installable with go install or Homebrew. It also ships example specs for a few dozen GNU tools and jq. I would like to hear where it breaks for your tools, or which CLI you would want covered next.

emirmrkaljevic

0 post score
0 comment score
joined 4 days ago