selphy.go - Linux client for Canon Selphy CP-900 photo printer
Last month I ran into a Canon Selphy CP-900 photo printer. It's a pretty neat device, prints pictures with pretty good quality. It even worked out of the box in Linux, but only via USB, and by it pretending to be an ordinary printer. This can have pretty ugly results.
The CP-900, as the first one in the Selphy series, can also take print jobs over WiFi. The nice thing is, other than it being wireless, that the WiFi protocol is just a pretty simple JPEG file transfer mechanism. Just giving the printer a JPEG and have it figure out layout/crop/etc seems to give somewhat nicer results. But of course, only Windows/OSX/smartphone clients are available. Fortunately, after some staring at wireshark, I managed to create a new client for it.
For extra fun, it's written in Go. My first time using the language, and I quite like it. It means the tool is very easy to build, and there are no special dependencies at all, as the Go base libraries already have everything I need.
To try it:
The CP-900, as the first one in the Selphy series, can also take print jobs over WiFi. The nice thing is, other than it being wireless, that the WiFi protocol is just a pretty simple JPEG file transfer mechanism. Just giving the printer a JPEG and have it figure out layout/crop/etc seems to give somewhat nicer results. But of course, only Windows/OSX/smartphone clients are available. Fortunately, after some staring at wireshark, I managed to create a new client for it.
For extra fun, it's written in Go. My first time using the language, and I quite like it. It means the tool is very easy to build, and there are no special dependencies at all, as the Go base libraries already have everything I need.
To try it:
bzr branch http://wilmer.gaa.st/selphy/And yes, I'm still using bzr. Deal with it. :-)
Comments
Display comments as Linear | Threaded
Giorgos on :
Thanks!
Wilmer on :
It mostly works, but annoyingly the printer seems to choke on subsequent jobs, you need to powercycle it before it picks up a new one. I need to find out where that's going wrong. :-(
Still, print quality this way is already so much better than when using the device as a normal printer.
Giorgos on :
Wilmer on :
The problem is, I think, a document ID which is sent when the job is accepted, which should be echoed in messages through the rest of the connection. I thought I was doing that now, but apparently not.
Valentin on :
Here are the errors.
go build selphy.go
# command-line-arguments
./selphy.go:197: method c.discover_reply is not an expression, must be called
./selphy.go:221: method c.id_reply is not an expression, must be called
./selphy.go:234: method c.status_reply is not an expression, must be called
./selphy.go:255: method c.start_tcp is not an expression, must be called
./selphy.go:284: method c.print_data_request is not an expression, must be called
./selphy.go:298: method c.send_flags_cb is not an expression, must be called
./selphy.go:312: method c.send_chunk_cb is not an expression, must be called
./selphy.go:372: method c.job_done is not an expression, must be called
./selphy.go:463: method p.start_job is not an expression, must be called
make: *** [selphy] Error 2
if you can point out what I miss that would be great.
Wilmer on :
Valentin on :
Thanks again.
Wilmer on :
Chris on :
thanks for your code, works great for me except for the powercylce issue...
I even wrote a litte script to use it directly from KDE (through "open with").
I only wonder if it was possible to somewhat powercycle your printer from remote?
Thanks!
Wilmer on :
I'll see if I can find it back, with a bit of luck it's even somewhere in the source code already!
Peter on :
Did you find it?
Wilmer on :
(And it took me a year to approve that comment because I'm mostly neglecting this spam-attacked blog, powered with such shitty software that even I as the only author need to do captchas and moderate my own comments using those same credentials. :< )
Chris on :
You should maybe have a look in your wireshark logs again.
When comparing android-selphy-app logs with selphy.go logs I just recognized that the Android app sends a "standard query response (0x0000, "QM")" first to which the printer replies with a cache flush. Selphy.go doesn't seem to send this command. I'm currently trying to understand your source though I never used go before. Maybe the powercycle issue could be overcome if selphy.go would send 0x0000 before sending data as well...
Wilmer on :
Sadly I don't own the device myself so there's not much I can do to fix this. :-(
Roland on :
Managed to compile and use it on a Raspberry Pi, and on a slow device like that it's evenmore faster than the other methods that I've found for printing to the Selphy (and this one sounds much more straightforward :-) )
It does not seem to handle error conditions like paper out / ribbon depleted smoothly yet (well, they gave me some "interesting" additional errors), but it's definitely nice to see how it's basically working, and great job! and many kudos! for finding out about the protocol!