LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Necessity of driver when communicating with custom hardware on parallel port (https://www.linuxquestions.org/questions/linux-hardware-18/necessity-of-driver-when-communicating-with-custom-hardware-on-parallel-port-937546/)

Summer_Penguin 04-01-2012 09:47 AM

Necessity of driver when communicating with custom hardware on parallel port
 
Hello everybody out there using linux,

My aim is to send signals to simple custom curcuits using the parallel port of my PC with C programs. My question is, whether I will have to write own drivers for doing this or just use the linux parport driver.

Thanks in advance for your answers!

theNbomr 04-01-2012 10:43 AM

Depends how you want to use the parallel port. If you can do it by simply writing characters to the port (ie. to the parallel port, your custom circuits look like printers), then you can use the parallel port driver directly. Otherwise you will have to either write your own driver, or you will have to build your application(s) with userspace drivers using the /dev/port facility, or with ioperm() + inb()/outb(). The userspace driver method requires root privileges. It is possible to use a kernel driver, and also use a userspace driver concurrently. I found this useful, as libiee1284 provides a convenient way to locate where in IO-space the parallel port hardware is mapped.
--- rod.

Summer_Penguin 04-01-2012 01:24 PM

Well, I imagine a minimal example like the one Arduino uses, i.e. a blinking LED. I've found descriptions which manage to do this without any custom drivers, but I am not sure about the resulting restriction of just using the parport driver in simple programs (in C, for example).

SaintDanBert 04-02-2012 12:39 AM

Much of what you want to do, you can program from user space. I know. I did it.
The only drive you will need is a generic parallel port module.

NOTE -- On a modern linux, you will might not see your parallel ports unless the hardware thinks it is online and ready. I did this before all of the automatice
detection and such happened. If this is the case, simply use modprobe to force the install.

For user space to access the device your process must must have permission to access the "device file" -- in *nix, everything is a file. Parallel ports have a name something like /dev/lpt*.

As root, you can use chmod to alter permissions such that read-write are possible. I created a special group name, "myDevice" and ran my program as a member of that group. My permissions were such that /dev/lpt* had g=rwx permissions.

I hope that this helps.
~~~ 0;-Dan


All times are GMT -5. The time now is 11:31 PM.