Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Parallel Port Pins High/Low

Got a good idea? You can suggest new features here.
Post Reply
Chaemelion
Posts: 9
Joined: Tue Jul 28, 2009 4:53 am

Parallel Port Pins High/Low

Post by Chaemelion »

I know there have been a few discussions here about parallel port support, but as far as I can tell, they're all about actually connecting devices to them. I was wondering if it'd be possible in upcoming releases add a function to set/read parallel port pins.
NikoMitDaMacht
Posts: 2
Joined: Sun Sep 20, 2009 12:50 pm

Re: Parallel Port Pins High/Low

Post by NikoMitDaMacht »

Yeah i had the same problem so I decided to code a plugin for that.
It is very fundamental and it is my first piece of code in python after a few minutes reading the docs, so don't be supprised that i am using the bitvector class i downloaded somewhere to do the bitcalculations - quick and dirty.
As LPT "driver" I am using the Inpout32 DLL which you can find here http://logix4u.net/Legacy_Ports/Paralle ... NT/XP.html. Just put it into the folder of your EventGhost executable.

[EDIT]I think i forgot to atach the plugin[/EDIT]
Attachments
LPT.7z
(17.79 KiB) Downloaded 466 times
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Re: Parallel Port Pins High/Low

Post by sjolof »

Nice plugin!

Could you please explain how to read the pins?
(Want to see if my garagedoor is open or closed)
Prinz
Plugin Developer
Posts: 194
Joined: Mon Apr 07, 2008 4:58 am

Re: Parallel Port Pins High/Low

Post by Prinz »

Hi,
sjolof wrote:Nice plugin!
Could you please explain how to read the pins?
(Want to see if my garagedoor is open or closed)
I think, a event will be generated, if the status of a pin is changed. The event name should be something like "LPT IN CHANGED [I/O status]"


If you want to read the bit, a following command should be added to the plugin (at the end):

Code: Select all

class Read(eg.ActionBase):
    name = "Reads the Bits"
    description = "You won't guess what this action does."

    def __call__(self):
        return self.inpout.Inp32(0x379)
After the line 19 following instruction must be inserted:

Code: Select all

        self.AddAction(Read)
If haven't checked it, I have only modified the given code in the way, which should work.

Regards
Prinz
Mein HTPC:
Mainboard: Gigabyte GA-G33M-DS2R
CPU: Intel E5200
OS: WinXP SP3
Graphic card: NVIDIA GeForce 210 512MB
TV-Cards: 2 * Digital Everywhere FloppyDTV-C, Terratec Cinergy 1200 DVB-C
HTPC software: DVB Viewer / EventGhost
sjolof
Posts: 27
Joined: Tue Aug 21, 2007 11:22 am

Re: Parallel Port Pins High/Low

Post by sjolof »

Prinz wrote:Hi,

After the line 19 following instruction must be inserted:

Code: Select all

        self.AddAction(Read)
If haven't checked it, I have only modified the given code in the way, which should work.

Regards
Prinz
Thanks!

I hope I can give it a try in the weekend.
Diabl0570
Posts: 30
Joined: Sun Feb 28, 2010 6:05 pm

Re: Parallel Port Pins High/Low

Post by Diabl0570 »

i'm using the plugin now for a while,
i tryd to edit this plugin a little this is the part i want to edit:

Code: Select all

    
def ThreadLoop(self, stopThreadEvent):
   while not stopThreadEvent.isSet():
      input = self.inpout.Inp32(0x379)
      if self.oldInput != input:
         self.oldInput = input
         self.TriggerEvent("LPT IN CHANGED " + str(input))
         stopThreadEvent.wait(0.1)
i want it to change in this:

Code: Select all

    
def ThreadLoop(self, stopThreadEvent):
   while not stopThreadEvent.isSet():
      input = self.inpout.Inp32(0x379)
      if self.oldInput != input:
         self.oldInput = input
         if input == 63:
           self.TriggerEvent("LPT PIN 63 is on")
        else:
          self.TriggerEvent("LPT IN CHANGED " + str(input))
         stopThreadEvent.wait(0.1)
i get this error:

Code: Select all

Traceback (most recent call last) (1462):
  File "C:\Program Files\EventGhost\eg\Classes\PluginManager.py", line 178, in LoadPluginInfo
  File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
  File "C:\Program Files\EventGhost\plugins\LPT\__init__.py", line 51
    if input == 63:
   ^
IndentationError: unexpected indent
i'm new to phyton script so excuse me if it is something stupid
thanks in advanced
Diabl0
User avatar
topix
Experienced User
Posts: 441
Joined: Sat May 05, 2007 3:43 pm
Location: Germany
Contact:

Re: Parallel Port Pins High/Low

Post by topix »

Diabl0570 wrote:i want it to change in this:

Code: Select all

    
def ThreadLoop(self, stopThreadEvent):
   while not stopThreadEvent.isSet():
      input = self.inpout.Inp32(0x379)
      if self.oldInput != input:
         self.oldInput = input
         if input == 63:
           self.TriggerEvent("LPT PIN 63 is on")
        else:
          self.TriggerEvent("LPT IN CHANGED " + str(input))
         stopThreadEvent.wait(0.1)
i get this error:

Code: Select all

Traceback (most recent call last) (1462):
  File "C:\Program Files\EventGhost\eg\Classes\PluginManager.py", line 178, in LoadPluginInfo
  File "C:\Program Files\EventGhost\eg\Classes\PluginInfo.py", line 126, in ImportPlugin
  File "C:\Program Files\EventGhost\plugins\LPT\__init__.py", line 51
    if input == 63:
   ^
IndentationError: unexpected indent
The else-statement must start in the same column as the if-statement it belongs to. In your case i think it must be

Code: Select all

    
def ThreadLoop(self, stopThreadEvent):
   while not stopThreadEvent.isSet():
      input = self.inpout.Inp32(0x379)
      if self.oldInput != input:
         self.oldInput = input
         if input == 63:
           self.TriggerEvent("LPT PIN 63 is on")
         else:
           self.TriggerEvent("LPT IN CHANGED " + str(input))
         stopThreadEvent.wait(0.1)
Diabl0570
Posts: 30
Joined: Sun Feb 28, 2010 6:05 pm

Re: Parallel Port Pins High/Low

Post by Diabl0570 »

thanks that worked!
bskchaos
Experienced User
Posts: 56
Joined: Tue Mar 25, 2008 3:04 pm

Re: Parallel Port Pins High/Low

Post by bskchaos »

can I use this plugin with a ParallelPort Relay Controller?
Tal56
Posts: 20
Joined: Tue Jun 22, 2010 6:47 pm

Re: Parallel Port Pins High/Low

Post by Tal56 »

Also interested in doing this with a parallel port relay I saw on Ebay, anyone know if this should work? Thanks
Post Reply