I'm replying in part to several other responses at the same time...

Christopher Sawtell wrote:

> > Can you interface directly to the parallel port from such languages?
> 
> In principle you can, just set a pointer to the hardware address with
> which you wish to 'talk'. but, imho you'd be much better off using one of
> the existing drivers to do all the grunt work for you.

For my stuff (written in C) I used ioperm() to get "permission" to access 
the parallel port (requires root), then outb_p() to write data, inb() to 
read.  Once you've called ioperm() you can drop back to a non-privileged 
user.  You don't need to specifically relinquish the port at program 
exit; the kernel takes care of it for you.  I can supply sample code if 
anyone's interested.

Also see the IO-Port-Programming mini-howto.  In my distro its located in 
/usr/doc/Linux-mini-HOWTOs/ .  It is a brief but excellent reference IMO. 
 It contains excellent information about delays (the reason I used 
outb_p() was because I wanted fast data transfer, but not so fast that my 
hardware can't handle!).  Hardware-independent (on i386 anyway) delays 
made easy :)

You _might_ be able to just open /dev/lp0 and read/write data to that.  
I've never tried it, and I doubt it'll work properly as the kernel print 
driver might munge things up a bit... and I have absolutely no idea what 
it'll do with respect to the data/control/status ports.

> > Or am I going to have to get to know c?

I'm glossing over the mini-howto and it does explain that you can use 
/dev/port (character device, major 1, minor 4, just in case you need to 
create it).  Seek to a byte which corresponds to your port (eg file 
position 0x378 = port 0x378 - 0x is C's version of basic's &H 
representing hexadecimal, btw).  Then just read/write your data.  Its a 
bit slower than using C but it should work OK from any language that 
allows random file access.  That might be your best hope of an easy 
solution.

> Yes, start off here.
> 
> ftp://ftp-svr.eng.cam.ac.uk/misc/sawtell_C.shar
> 
> reported to be still one of the best "Starting out with C" tutorials on
> the 'Net. The prose is digestable.

Coincidentally, the last time I used basic I was doing 8-bit D/A through 
the parallel port... the project which eventually got me into C!

(ps - the LCD project's still going happily... more features have been 
added with still more on the way, including support for those crappy 
character modules!)

Cheers,


- Dave

http://www.digistar.com/~dmann/ (out of date)


Reply via email to