[Gambas-devel] C/C++ Component

Ken Schrock schrockk at ...26...
Tue Jun 10 02:27:07 CEST 2003


To do this in Gambas you would have to build a component (in C)
It is doubtful you would go all through that for this simple test
As this code would be worthless in any real world application

In the real world you would have to test the status register first
Otherwise, if the port is busy or the other end hasn't acked
You would only accomplish getting errors or sending garbage
(depending on hardware, bios, configuration, etc)

Also, you are not going to ioperm every time you send a bite
Which is exactly what this piece of code does

If you wanted something permanent
The class should probably be dynamic (multi-port)
The port number would be passed as part of _new
You would do the ioperm test seperate (once)
And you would write the byte seperatly
(or make test static var in the write)
And a read method for the st register
Plus one or more properties for you
(internal status, count, etc)

Then you have speed considerations (particulaly in basic)
Handshaking, is buffering needed, etc., etc., etc.

Then I really don't understand the asyncronous thing
Done right, this ISN'T asyncronous, you have to wait or return
Only asyncronous way would be to have two seperate pieces
The Gambas part writing into a buffer, c pulling it out
And I am not even sure if that is possible here

Do you have hardware to test on (other than printer)?


DA Corp. wrote:
> Excuse me.
>  
> I didn't know that file is for DOS. I want to write asynchronously, I 
> don't want use /dev/lp0, because it is for printing synchronously. I am 
> trying make a file in Linux.
> under Linux the file portp.c is:
>  
> #include <asm/io.h>
>  
> int main()
> {
> if (ioperm(0x378,3,1))
>   {
>     fprintf(stderr,"I can´t acced to parallel port.\n");
>     return 0;
>   }
> outb(0xFF,0x378);
> }
>  
> This file send 0xFF to parallel port. It is compiled:
>  
> gcc -O -I /usr/include port.c
>  
>  
>  
> 
> ____________________________________________________
> <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>  IncrediMail - 
> Email has finally evolved - Click Here 
> <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>


-- 
Using Lindows





More information about the Devel mailing list