This Time Self-Hosted
dark mode light mode Search

I should retire…

… and I mean in a small house in a small town in the alps, far away from computers, ADSL connections, and all these things.

Why? Well, if you follow my blog you know I had some health problems this summer, and the main suggestion of the doctors was trying to relax more. As it was, I really didn’t relax at all, Gentoo and xine and other Free Software projects sucking up all my time.

Now, today I was supposed to have a job interview, but in the last couple of days my blood pressure was a bit too high, and my doctor told me to just relax for some days, this included cancelling the meeting. Of course I need to keep controlled the pressure because I also have the warfarin to take, and I need to get my INR tested again, too.

So okay, after passing the morning reading, and finding out that this just make me think too many times about my problems, I decided to try my luck today by trying to learn how to write a Linux USB driver. Well, by trying again at least.

Last time I tried it was to see if I was able to implement a driver for a USB to serial adapter that I bought on eBay: out of four of them, three were PL2303 (perfectly working) and one used a W.ch chipset (a Chinese producer) that is not supported by Linux, and I failed to find any specification for it. I tried more than once to contact the producer, with no results. Sniffing the interaction between Windows and the device I was able just to find some commands. but nothing useful to actually make the device usable.

This time, I started thinking about the four buttons on my Epson scanner. The only thing I found to actually make them useful under Linux was the scanbuttond project, but I don’t really like its approach. The first problem is that the daemon polls for the status of the buttons, and this isn’t really a nice approach for the CPU. The second is that it executes commands, which aren’t really well put into context, and especially you can’t use it to provide commands to a scanning application.

The Linux kernel provides a very good way to handle buttons of any kind, the event devices. Even the ACPI buttons are now event devices, and those are easy to take into context: just make sure the application opens the correct event device, and that should take care of reading the buttons.

So I said to myself: “why can’t I try to write a driver for those buttons that shows the scanner as an event device?”. This time there was nothing to reverse, the code was written already; in userspace using libusb, but it’s there as a reference. And I started.

I almost forgot having a copy of Linux Device Drivers, it arrived not long before I ended up in the hospital, and I tried to remove most of the last weeks before that, as well as the first weeks in the hospital. I’d like to remove the whole hospital experience, but that’s near to impossible.

So I started reading the USB part, and I was able to come to something that at least loaded and identified the scanner. I did make some mistake on the disconnection function, as my kernel paniced; I restarted with the intention of using VMware to test it next time, at least then I panic just the guest OS and I can restart it without stopping my work.

But when I restarted I also read the reply to the mail I sent to Daniel (dsd) before, and he gave me the bad news: if the interface I need to read the buttons data from is the same that SANE needs to access the scanner, then it won’t work anymore. And of course, Epson didn’t use different interfaces, it’s just the same. Different endpoint, but still same interface.

So I’ll probably just rm -rf the code I wrote up to now, as it makes it useless… it can turn a scanner into a 4-buttons keyboard, but I doubt this is what users want.

Seems like this is just another failure for me…

Comments 6
  1. That’s a shame. I take it that it could be made to work but that would take a lot more effort than you had in mind.

  2. Well, it could work if I make the driver export a character device to userspace so that sane could use it. But as you said, it requires way more effort, and a special backend for SANE too.But I still have some hopes.

  3. Do you exercise? Seriously, I hate to barge in to your personal life but if you are really having health problems like that you need to start doing some strenuous physical activity. Without getting into a ton of detail, stress and hormones from the fight/flight response can wreak havoc on the insides if not used up. Google around if you want the whole story but a 20 min jog would be a lot better :O.

  4. It’s a shame it didn’t give you the result you wanted, but I wouldn’t call it a failure: you wrote a working Linux driver — well done!The experience and knowledge you gained is a real result imo.

  5. Excuse my n00bity, but couldn’t that code be merged into SANE’s Epson-driver by any means?

  6. You’d want the buttons to work even without SANE initialised at all. Think of a SANE frontend that wants to know when the scanner is asking for something.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.