[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Making UPS smart with Pygame and Joystick input socket



I was assuming that you were talking about a USB joystick or gamepad. 
Are you talking about the old midi-port style joysticks? the ones where 
the port is usually on the sound card?

I have no idea if pygame supports those at all... I am not sure if they 
even show up as joystick devices in the linux /dev tree. I suspect that 
they probably do not (not unless you are using a really ancient kernel)

The reason I assumed that you were going to disasemble a joystick is 
because I was thinking of a USB joystick. You need the joystick to 
identify itself as a joystick on the USB bus. You could probably still 
connect your UPS to the joystick as you planned, although now I am 
thinking you might have an easier time connecting to one of the analog 
inputs instead of the buttons.

(Also, that file you attached was an inkscape SVG file, renamed to have 
a PNG extension, in case anybody tried to look at it and wondered why it 
seemed to be a broken PNG)

---
James Paige

On Wed, Apr 13, 2011 at 06:49:47PM +0200, SlawKo.skrzynka@xxxxxxxxx wrote:
> No, I do not want to disassemble a Joystick.
> I simply want to add a relay that would be connected to existing relay in UPS that switches battery ON.
> See a picture with connections in enclosed file.
> 
> 
> SlawKo
> 
> 
> 
> 
> 
> 
> UÅytkownik "James Paige" <Bob@xxxxxxxxxxxxxxxxxxx> napisaÅ(a): 
> > Temat: Re: [pygame] Making UPS smart with Pygame and Joystick input socket
> > Data: 2011-04-13 17:24
> > Nadawca: "James Paige" <Bob@xxxxxxxxxxxxxxxxxxx>
> > Adresat: pygame-users@xxxxxxxx; 
> > 
> > Oh! I understand now! You are going to take a joystick, disassemble it, 
> > and splice it together with your UPS so the buttons get pushed as you 
> > describe.
> > 
> > Pygame's joystick support is nice and simple and easy to use-- the only 
> > problem I could forsee is that AKAIK you have to initialize a pygame 
> > window before you can read joystick events. You said this was a server, 
> > so if it is not running a graphical environment, initializing that 
> > window could possibly be a problem.
> > 
> > Otherwise, sounds like fun :)
> > 
> > ---
> > James Paige
> > 
> > On Wed, Apr 13, 2011 at 04:55:53PM +0200, SlawKo.skrzynka@xxxxxxxxx wrote:
> > > 1) I am sure my UPS is neither being read as a Joystick nor any other device. It is because it has only 2 connections: AC-input and AC-output. 
> > > 2) This UPS is made by "Ever" type "MP300".
> > > 3) It is connected to the computer by AC-output socket on the UPS and AC-input of the PSU in my PC. It has no data connections that "smart UPS" usually have that connect to the COM port of a computer and can be monitored by special software.
> > > That is the point.
> > > I would like to make use of existing gameport (that is not used by the server at this moment) and perform basic communication, like this:
> > > Button_1 OFF , Buton_2 OFF -> state A
> > > Button_1 ON , Buton_2 OFF -> state B
> > > Button_1 ON , Buton_2 ON -> state C
> > > The other actions described already before.
> > > For this task some piece of software is needed that reads the Joystick port.
> > > Therefore my interest in Pygame's Joystick module.
> > > The necessary hardware upgrade to the UPS is very simple and requires just 2 additional relays an some cabling. It will electrically be equivalent to a joystick hardware that simply connect 2 pairs of wires by the button. In this application the human finger and the button switch is replaced by a relay.
> > > 
> > > 
> > > SlawKo
> > > 
> > > UÅytkownik "James Paige"  napisaÅ(a): 
> > > > Temat: Re: [pygame] Making UPS smart with Pygame and Joystick input socket
> > > > Data: 2011-04-13 1:16
> > > > Nadawca: "James Paige" 
> > > > Adresat: pygame-users@xxxxxxxx; 
> > > > 
> > > > Are you sure your UPS device is actually being read as a Joystick? 
> > > > Exactly what kind of UPS do you have, and how is it connected to the 
> > > > computer?
> > > > 
> > > > There are probably better tools for doing what you want to do than 
> > > > pygame.
> > > > 
> > > > ---
> > > > James Paige
> > > > 
> > > > On Wed, Apr 13, 2011 at 12:42:18AM +0200, SlawKo.skrzynka@xxxxxxxxx wrote:
> > > > > Hello,
> > > > > 
> > > > > I would like to get some information whether it would be possible to use Pygame's Joystick package to process simple signal from UPS to trigger clean shutdown of the Linux machine.
> > > > > 
> > > > > I would like to use 2 buttons from Joystick interface to sense 3 states from UPS:
> > > > > A) AC power OK
> > > > > B) no AC power - using battery
> > > > > C) battery low - shutdown now
> > > > > 
> > > > > The program should run as a demon and check every 10 second if the UPS entered B state. Then would monitor every second if UPS reached C state. At this moment daemon should copy files stored in RAMdisk onto HDD and request runging programs to close and finally invoke system shutdown.
> > > > > 
> > > > > This architecture would improve my Linux net_router/web_proxy/home_automation/etc. server with simple solution using existing gameport, 2 relays and some cabling, upgrading it to a "smart system".  :)
> > > > > 
> > > > > 
> > > > > Is it difficult to create this piece of software ?
> > > > > 
> > > > > 
> > > > > Kind Regards,
> > > > > 
> > > > > SlawKo
> > > > > 
> > > > > ----------------------------------------------------------------
> > > > > Najlepsze oferty na domy i mieszkania w Polsce!
> > > > > Szutkaj tutaj >> http://linkint.pl/f2974
> > > > > 
> > > > > 
> > > > 
> > > 
> > > ---------------------------------------------
> > > Ksiegowa radzi: Jak zaÅozyc firme w 15 minut?
> > > http://linkint.pl/f2968
> > > 
> > > 
> > 
> 
> 
> ----------------------------------------------------------------
> Chcesz lepszej pracy i placy? Mozesz ja miec!
> Szukaj ofert >> http://linkint.pl/f2972