[Gambas-user] Parallel Port
Les Hardy
les at ...2337...
Thu Apr 8 18:04:36 CEST 2010
Hi there, I don't have a program to offer you. All my old code is in
other languages.
I did however write a little working example for you.
You will need to use port, not parport0.
For some reason that is unknown to me, I too, am unable to get parport
to work correctly from gambas.
I tested the code below, and it does work. I ran it a few times on a
system with Ubuntu 9.04, gambas 2.20, and a little parallel port tester
I made 20 years ago.
Unless you have already sorted out permission to access 'port', you will
need to be root to run it, either start gambas as root, or compile it
and then run the executable as root.
PUBLIC SUB Main()
' Gambas module file
DIM pport AS File
DIM bi, bo AS Byte
pport = OPEN "/dev/port" FOR READ WRITE
FOR bo = 32 TO 122
SEEK #pport, 888
WRITE #pport, bo
SEEK #pport, 888
READ #pport, bi
PRINT Chr(bi) & " "
WAIT 0.05
NEXT
CLOSE #pport
END
Just a quick mention about seek on ports.
Seek simply takes you to the port address. Notice I used a seek before
each read or write.
888 (0x378): Data
889 (0x379): Status
890 0x37A) : Control
Hope this helps
Regards
Les Hardy
Bjorn Macintosh wrote:
> Hi all,
>
> Does anyone have a program that interfaces with the parallel port, one
> written in Gambas. If you do would you be willing to share this program
> with me as I am trying to write a parallel port interface and am struggling
> to get my head around a few concepts. mainly how to write to the port and
> how to select pin's base 0 base1 and base2.
>
> Any help would be greatly appreciated. I sent a post two days ago holding
> the full details on my program and what I am trying to do if you need any
> clarification.
>
> Thanks
> Bjorn Macintosh
>
>
More information about the User
mailing list