[visionegg] Re: parallel port 2nd

Hi Andrew

I have some problems, which gets me crazy.....

with the code: 


input_value = 0
while (input_value == 0):
       my_debug_msg.append('before<' + str(input_value) + '>lastimage <'
+ str(last_image) + '>')
       input_value = raw_lpt_module.inp(0x379) & 0x20 #I use pin 12
       my_debug_msg.append('after<' + str(input_value) + '>lastimage <'
+ str(last_image) + '>')

and nothing(!) on the LPT (open port) gives me (cycling trough the whole
two times):

before<0>lastimage <0>  
after<32>lastimage <0>  
before<0>lastimage <1>  
after<32>lastimage <1>  

-> it seems that there is a logical 1 on the pin 12! why?

thank you very much, Andrew, for a hint

cheers
christoph


On Tue, 2002-12-17 at 18:07, Andrew Straw wrote:
> Hi Christoph,
> 
> Your two questions about the parallel port are essentially the same.  
> "inp()" returns a byte (well, actually it's a Python int, but it will 
> always be 0-255).  When you've pointed it to the parallel port like 
> "inp(0x379)", 8 bits of the parallel port get stored in the return 
> value.  This happens according to the standard method for encoding 
> multi-pin digital signals.  In Python, this would be (obviously the 
> system drivers don't run Python...)
> 
> result = 0
> for n in range(8):
>      result += bit[n]*(2**n)
> 
> therefore to get bit[n], you want to do something like
> 
> for n in range(8):
>      bit[n] = result & 2**n
> 
> So, if all you care about in your code is bit 4, you can just do bit4 = 
> result & 0x10.  So, modify your code from
> >             input_value = raw_lpt_module.inp(0x379)
> 
> to
>      input_value = raw_lpt_module.inp(0x379) & 0x10
> 
> ======================================
> The Vision Egg mailing list
> Archives: http://www.freelists.org/archives/visionegg
> Website: http://www.visionegg.org/mailinglist.html
-- 
Christoph Lehmann 
Department of Psychiatric Neurophysiology 
University Hospital of Clinical Psychiatry 
Waldau 
CH-3000 Bern 60 
Switzerland 

Phone:  ++41 31 930 93 83 
Mobile: ++41 31 570 28 00
Fax:    ++41 31 930 99 61 
Email:  lehmann@xxxxxxxxxxxx 
Web:    http://www.puk.unibe.ch/cl/pn_ni_cv_cl.html

======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: