I like programming with robots and stuff. For this approach, I'm using the LPT port for output and the Gameport for input.
For younger guys: Just some old fashioned USB Ports ;-)
Game Port http://img44.imageshack.us/img44/3650/da15dsubm.png Parallel Port http://img44.imageshack.us/img44/1369/800pxparallelport.jpgWith Python (and the fabulous module pyParallel
) the output works 开发者_如何学Govery, very well.
Now I'd really like to get data from the Game Port (like photo tubes, temperatur sensors etc.). How can I accomplish this?
Ah, by the way: I'm using Ubuntu for all that stuff.I cannot really help you much. I don't work with joy/parallel port anymore and I forgot almost everything. What I can tell you is that under linux, there's a specific driver and device for the joystick port. You find information about it here (google cache, the main doc is down)
http://74.125.153.132/search?q=cache:oKDIwlR1TvYJ:www.infiscape.com/~patrick/vrjuggler-config/2.0/configuring_vr_juggler/apcs05.html+joystick+device&cd=1&hl=en&ct=clnk&client=firefox-a
I am pretty confident the kernel module still exists. Once you modprobe it, you will get access to the /dev/js0 device. You will have to read from that, raw, unless you find a better library solution.
By the way, remember that you can read digital from the parallel port, if I am not mistaken. It's just unusual and hacky, and for your sensors the game port makes more sense (since you have analog input) but if you want to go digital, remember you have the choice to go parallel 100 %.
If your just looking for controller input (USB Joystick, Gamepad, etc) PyGame has an input module that works nicely.
Have you looked at pygame's joystick package: http://www.pygame.org/docs/ref/joystick.html ?
精彩评论