ahartmetz 18 hours ago

> I also thought I’d message the vendor and ask them if they could share any specifications or docs regarding their protocol. To my surprise, Nanoleaf tech support responded to me within 4 hours, with a full description of the protocol that’s used both by the Desk Dock as well as their RGB strips.

How cool is that? Too many vendors still think that they have valuable intellectual property in such relative trivialities. And that handing out the specs freely helps their competitors more than themselves.

  • Teknoman117 15 hours ago

    I almost had that experience with one of the popular PC liquid cooling hardware vendors around 10 years ago.

    I emailed them saying I'd be interested in developing drivers for their hardware for Linux as I was a happy customer and was immediately put in touch with one of the managers and their engineering team.

    Made quite a bit of progress before the whole thing was shut down because one of their component vendors threatened them saying it'd be a breach of their contract with them.

    Apparently that vendor sold a "datacenter" (non consumer) version of that hardware for which they charged a hefty license fee for the management software (which was Linux compatible).

    Jokes on them, someone reverse engineered the whole thing with a USB analyzer years later and published it XD. (not me)

  • agentkilo 13 hours ago

    Yeah that part of the article put a big smile on my face.

    I did the same thing back in college, when I was in a lab. We wanted to do some research on Wi-Fi signals, and I happened to own a bunch of Wi-Fi adaptors produced by SomeSmallTech Co. Ltd., which featured relatively new Atheros chips and didn't have Linux drivers at the time.

    So I sent an email to the company's public email address, asking for some datasheets, "for science". To my disappointment, presumably a PR person replied that they "don't have a company policy to collaborate with academic research". (But they did send a quick reply, kudos to that.)

    Funnily enough, years later I ended up working for said company. Naturally, when I first logged into the company network, I searched for the datasheets I asked for. There were "classified" watermarks all over the PDFs :)

    • wiz21c 7 hours ago

      > don't have a company policy to collaborate with academic research"

      Strangely they all have a tacit policy to build their products at least partly on the results of academic research.

  • sysmax 11 hours ago

    It's not the IP, it's sadly how people react. Some folks will be appreciative of help, credit to them. Others will immediately get back how they tried it, it didn't work and now they need you to rewrite everything, or do their project for them, or redesign your product to match what they want it to be. And if you politely refuse, it quickly escalates to threats of trashing your business through every channel, and other things.

    So, the safest thing to do is not give details at all, or "leak" them like another reply in this thread mentions.

  • amelius 6 hours ago

    I wish more vendors would put "Linux support" on the package. Or maybe "Unofficially supported in Linux" or "Linux community support" if they don't want to get their fingers burned.

    Maybe this kind of thing should be enforced in the GPL (as many devices use Linux under the hood).

  • starkrights 18 hours ago

    I had the same reaction. Nano leaf is extremely cool for that.

    • baby_souffle 16 hours ago

      This has to put them in the top 0.01% of companies that make consumer electronics.

      I can think of only a few companies that bother to publish any details... And most of them are focused on industrial customers where it isn't unreasonable to need certain protocol details for integration or even just compliance with certain regulatory systems.

      Maybe things are changing?

      I have noticed that some of the LED light controllers you see on AliExpress are leaning in to open firmware standards. 5 years ago, you bought the controller and had to flash your own firmware. Now, there's an option at checkout to select an open source firmware. Some even have a USB port built in for flashing!

  • 2Gkashmiri 12 hours ago

    I have a solar inveter from a company, aparticular German brand. I wanted to use home assistant with it so I needed rs232 data.. tried the support and they asked me to sign an NDA.

    Okay, cool. I did with a fake name, address and everything and they sent a file..

    Turns out the file is available online.

    Facepalm pro Max.

    So my question is, what kind of "IP" is in a data sheet that needs protection ? And this isnt even some secret product but a generic solar product sold by millions.

    Rs-232 protocol ? Really ?

    • wiz21c 7 hours ago

      They have asked to the legal team who basically don't know shit about what us do and who will always take the most conservative approach possible. So you'll get either: no answer, a "NO" answer or an "NDA" answer.

      • tialaramex 3 hours ago

        Yup. The default from lawyers will be "No" because why help? The correct way to use lawyers, either in-house counsel or a paid lawyer if you have a specific project is to tell them what you want to happen and then they figure out what the best legal course of action is to closest achieve that. Mundanely this might mean e.g "Fill out form X1234 and then send letters to this politician suggesting they support your X1234 application" but at the extreme it could mean closer to the situation in the UK where a ferry company illegally fired crews with zero notice, and their legal advice had clearly been "Worst case they put one of your executives in prison, probably not even that, but either way you replace union workers with people on slave wages and that means $$$".

    • Mad_ad 7 hours ago

      Was it Alpha-ESS? they make it so stupidly hard to get your information outside of their smartphone app.

rkagerer 9 hours ago

This is awesome!

But it also makes me a little bit sad. The original parallel port and even ISA interface seemed so simple by comparison, with less layers of abstraction. Just run a wire, and write to a port.

I remember when I was a kid, I found a breakout board in an electronics store's random clearance parts bin, with an ISA header on an edge. On a whim I took it home and wire-wrapped a 7-segment LED onto it. Power and ground were easy. Each segment was hooked to a data line, through a simple buffer IC. I cheated and used only a minimal number of address lines to feed the enable port (guessing through a simple AND gate or something). I was amazed when I wrote to that address and it worked the first time!

I look at a protocol like USB, with hundreds of pages, and instead of that curious excitement and enablement I felt back then, I feel a bit overwhelmed.

  • znpy 2 hours ago

    > The original parallel port and even ISA interface seemed so simple by comparison, with less layers of abstraction. Just run a wire, and write to a port.

    All those layers of abstraction is likely what allows us to hook up a single wire to our laptops and get multiple very fast ports from the docking station along with power and display output.

    You get some, you lose some.

  • colechristensen 9 hours ago

    I sometimes think about this, starting from scratch with a computer hardware and software stack that disallowed all of the layers of abstraction that have built up over the decades.

    Yeah many of the abstractions help with performance but maybe there's value giving up much of that performance in exchange for simplicity.

    • rkagerer 8 hours ago

      It would be neat to design a whole new contemporary stack from scratch.

      • bzzzt 6 hours ago

        It would also be an enormous undertaking, requiring man-centuries of work and has the risk of falling into the 'second systems effect' trap...

ianlevesque 18 hours ago

It’s a userspace USB HID driver in rust, which is honestly more interesting/applicable to me than a kernel driver, which is what I thought it meant from the title.

dabedee 17 hours ago

I really enjoyed the way this post was written, i.e. it includes the code, how it was run, the false paths, etc. You almost get to live through the author's journey and how he figured out just enough to get something working.

bhasi 8 hours ago

The title was misleading because the author wrote a userspace Rust driver and not a Linux kernel driver in C.

  • amelius 6 hours ago

    Upon reading the title I thought this was going to be about how easy it is to write or modify a Linux driver when using a LLM even if you know nothing about the subject.

    • Neywiny an hour ago

      No LLM needed. Kernel driver code for simple things is usually copy-paste-modify. Find something that works with an HID interrupt based device, and modify that. If you want a /sys led, copy from that. It's only if you try to push to mainline you need to worry about understanding it, but they'd probably smell LLM trash from miles away.

kblissett 17 hours ago

I enjoyed this post, but I'm eager to hear what the next step would be for a real "production" userspace driver. Are these typically just daemons that are configured to run at start up? And then some configuration GUI communicates with it over a socket or something?

shreddit 17 hours ago

> Let’s run it again to make sure it was not a fluke!

I understood that reference

LorenDB 16 hours ago

The author should probably have implemented support in OpenRGB instead to better benefit others, but this is cool nonetheless.

  • jeroenhd 6 hours ago

    I think they wrote the code more for the challenge of it than anything else. The final code doesn't seem to do more than the bare basics (which is probably enough for the author).

    Plus, to port this to OpenRGB, you'd need to rewrite the code into C++ (ugly, old C-inspired C++, at that: https://github.com/CalcProgrammer1/OpenRGB/blob/master/CONTR...) which would take most of the joy out of it for me at least.

    • surajrmal 4 hours ago

      I don't think the style described in that doc is at all ugly. It's practical and simple. I say this as someone who spends a lot of time writing modern c++ and heavily using templates.

      I thoroughly enjoy rust, but I doubt not being able to use it should be grounds for avoiding contributing to a project. Unless you are going to write async heavy code, libusb is pretty easy to use in C.

0xbadcafebee 16 hours ago

I want to run FreeBSD on my laptop, but they don't have a [complete] driver for my wifi card. I've thought about diving into AI coding-assistant agents just to see if I could use one to finish throwing together a working driver... but figuring out the AI agents is frictiony enough that I'm leaving it be. (I'm not a VSCode user)

  • buildbot 11 hours ago

    Claude code, being a CLI interface, might be more your style? Expensive though

  • fithisux 7 hours ago

    AI can also be used to help reverse engineer blobs.

fracus 15 hours ago

I wish this was done in C so I didn't have to learn Rust. But maybe it is time to learn Rust.

  • dralley 13 hours ago

    Rust isn't that difficult really. Easier in many ways than C if you're building normal software and not, like, a library of fancy data structures.

  • jeroenhd 7 hours ago

    This is using rusb, a Rust wrapper around libusb. libusb is still written in plain old C: https://libusb.info/

    If you don't want to learn a different programming language, you can take the exact same approach in any language you prefer and play along. You may need to turn the more object oriented calls into libusb_* calls, but if you're used to programming in C you probably won't have a problem getting that to work.

dmonitor 8 hours ago

This is exactly the kind of simple tutorial I was looking for a few years ago. I forget what the project was that I wanted this for, though, haha. Thank you for the writeup!

amelius 6 hours ago

Does this provide protection against opening then device from two processes at the same time?

  • yrro 3 hours ago

    Does O_EXCL work with linux USB devices?

jonnypotty 18 hours ago

Thanks for this. Good read and also kinda inspiring.

VTimofeenko 10 hours ago

Excellent post! I have a Nanoleaf 3d thing that I was hoping to use as an ambilight-like thing for the TV, but the experience was... meh. I know about the Hyperion project and hope to set it up one day, but meanwhile I think I could try to repurpose this code to control the strip from a Linux box.

fithisux 7 hours ago

There are many innovative OSes that are killed by the lack of Device Drivers.

As a community we must find a way for tackling this issue.

Micro-Kernels are a solution where one can run different OSes but they will reuse the same device driver servers.

But it requires co-ordination and determination.

Rust can be a solution for sure.

  • jeroenhd 6 hours ago

    Any programming language can be a solution, the programming language itself isn't the problem. Convincing device driver programmers around the world to come up with a universal API that includes all the possible features and works on every OS is.

    In this case, the cross-platform libusb should make this code work on either Linux or Windows (if you install the signed Windows drivers). If other operating systems port libusb, they get this code for free.

    Most "real" drivers still run in kernel mode, though, and not even Linux can keep their ABI stable (Windows has to, between releases, with the aid of compatibility wrappers that only work for a certain amount of releases).

    It would probably be worth it more forbBespoke operating systems to implement either the Windows API (like ReactOS does) or the Linux API (pick an LTS version) to get existing drivers to work. Unless you pay them, most driver programmers aren't going to bother with anything than Windows, maybe Linux, possibly macOS.

    • sumtechguy 36 minutes ago

      On a previous project I spent a lot of time trying to figure out a 'generic device driver'. That is actually a decently hard space to crack. As each device has randomly different ways of talking. Some are serial/local bus. Some are memory space. Some have a combination. Some systems broadcast data, some you have to query it, some you have to query then wait for the next broadcast. Some systems mildly follow the spec, some strictly follow it, some strictly follow their own flavor of the spec or an outdated one, some have their totally made up spec that they may or may not give you. Even from the same company you can have two models that on the outside if you use their stuff looks the same but under the hood is sorta different enough that your driver is garbage. I basically ended up here https://xkcd.com/927/