[Gambas-user] Parallel Port - Kadaitcha Man

Doriano Blengino doriano.blengino at ...1909...
Sun Apr 4 09:49:50 CEST 2010


Bjorn Macintosh ha scritto:
> Hiya,
>   
> My Gambas version is Gambas2.13
> I am running Linux Mint 8
> I do have a parallel port on my PC. It is '0378' - '037a' and '0778' -
> '077a'
> The error code I am getting is "System error. illegal seek"
>   

> I had already found and gone through the link you sent,  it is what part of
> my code was based on.  If you have read it and can fully understand it can
> you tell me what
> iPortNumber should be in order for me to access the parallel port.  I was
> thinking it would be 888 as a integer (378 in hex is 888 in dec) however I
> don't appear to have got a result from this.
>
> I tryed 378 aswell without result.  I would try polling each and every port
> however I understand this would potentially break my pc. not my favourite
> option.
>   
On a standard PC the parallel ports should be on 0x378 (first), 0x278 
(second), ox3bc (alternate address). Your address 0x778 sounds strange, 
even if possible (everything is possible...). Every PC parallel port 
takes three consecutive I/O address, namely BASE+0, BASE+1 and BASE+2. 
So the standard first port should be at address 0x378 (to write the 
eight data bit pins); 0x379 (to read the printer status) and 0x37A (to 
write some addition I/O).

Anyway, this should be of little importance to you, because the linux 
kernel abstract these addresses, and maps a device which should hide 
those details.

You can take some more info with the command "cat /proc/ioports": if you 
don't see the addresses you expect, then you should insert some module 
in the kernel (modprobe parport, modprobe lp, or similar).

Once verified that your machine has a parallel port, and that the kernel 
sees it, you can start to program. I really don't know if the gambas 
sources you have are correct, at first sight they seem ok, but a seek 
operation on a character devices is impossible... is your /dev/parport0 
a character device?
Another thing, may be that to access a device in similar manner you need 
some privileges - try to run the program as root.

Another way would be to use the I/O kernel space directly: in /dev you 
could find a device (/dev/port?) which gives you access to all the IO space.

A third way is to use the IN and OUT instructions, bypassing the kernel 
completely (but you need to ask permission before, and perhaps gambas 
does not have IN and OUT instructions).

Unfortunately, right now, I am on a machine which lacks a parallel port, 
so I can't experiment. But you can google for these three methods to 
access hardware.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list