mike ha scritto: > On 04/07/2010 02:47 PM, nando wrote: > >> Seek will not change the address. >> >> >> ---------- Original Message ----------- >> From: Doriano Blengino<doriano.bleng...@fastwebnet.it> >> To: nand...@nothingsimple.com, mailing list for gambas users >> <gambas-user@lists.sourceforge.net> >> Sent: Wed, 07 Apr 2010 11:06:42 +0200 >> Subject: Re: [Gambas-user] Parallel Port - Illegal Seek - >> >> >> >>> nando ha scritto: >>> >>> >>>> Using SEEK is not correct. >>>> If you think of the parallel port as a file, you cannot seek. >>>> It doesn't make sense. >>>> You can only read and write. >>>> What are you trying to accomplish ? >>>> -Fernando >>>> >>>> >>>> >>> He is trying to do low level access to the parallel port, which has 3 >>> hardware addresses. >>> In that respect, seek() would make sense to select which IO address to >>> read from/write to. >>> Whether this works or not, depends on how the kernel driver interprets >>> the seeks, but the following listing makes it clear that somewhere >>> (other OSes?) this behavior works. >>> The error could also arise from other problems: permissions, missing >>> modules, wrong major/minor numbers and so on... >>> >>> Regards, >>> Doriano >>> How already stated in a previous email, it is possible to access I/O ports in different manners. After a research, I discovered two viable ways - direct access (I don't know if gambas has I/O instructions), and /dev/port, which is a device. In this last case seek() is used to address a port.
From http://tldp.org/HOWTO/IO-Port-Programming-2.html : > > Another way to access I/O ports is to |open()| |/dev/port| (a > character device, major number 1, minor 4) for reading and/or writing > (the stdio |f*()| functions have internal buffering, so avoid them). > Then |lseek()| to the appropriate byte in the file (file position 0 = > port 0x00, file position 1 = port 0x01, and so on), and |read()| or > |write()| a byte or word from or to it. > > Naturally, for this to work your program needs read/write access to > |/dev/port|. This method is probably slower than the normal method > above, but does not need compiler optimisation nor |ioperm()|. It > doesn't need root access either, if you give a non-root user or group > access to |/dev/port| --- but this is a very bad thing... [about > security]... Using /dev/port can be problematic: can gambas do unbuffered I/O? Other methods would be to use some external program or library (shared object). If gambas does not have I/O (peek & poke), then an external library is the most performant way, though not the simpler. Gambas can interface with external libraries using EXTERNAL declaration. Googling about this issue, I found some interesting page: http://tldp.org/HOWTO/IO-Port-Programming-2.html http://www.epanorama.net/circuits/parallel_output.html http://www.faqs.org/docs/Linux-mini/IO-Port-Programming.html http://cyberelk.net/tim/parport/parport.html http://people.redhat.com/twaugh/parport/html/ppdev.html The best way would be to write a gambas component, having either internal I/O instructions (a C component) or relying to an external library (a gambas component calling an external library; may be there is something already done somewhere). Hey, gambas gurus out there... someone has the time? I do not. Regards, Doriano ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user