On Mon, Mar 15, 2010 at 11:40:12AM -0600, Dave Smith wrote: > > The part arrived today and after a few minutes of hacking, it works > beautifully. I didn't have to install or configure anything for > /dev/ttyUSB0 to appear. And now I have a very simple python script that > can turn the relay on: > > f=open("/dev/ttyUSB0","wb") > for byte in [0xff, 0x01, 0x00]: > f.write(chr(byte)) > f.close() > > (Is there a one-liner to do this?)
Write that to myscript.py and your one-liner is "myscript.py". :) Python really isn't about one-liners. Fortunately, modern Linux distributions come with filesystems, so creating files is easy. :) If you really wanted to do a one liner, I'm sure there are plenty of ways that are possible, but I personally think your script is great as-is. > I wired the relay such that when the USB connection is lost, the power > stays on. It works wonderfully. Cool. Thanks for sharing your fun hack. -- Andrew McNabb http://www.mcnabbs.org/andrew/ PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868 /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */