I needed to debug using a computer connected to a network having a server account management, thus I couldn't get superuser access.
I solved that by changing the direct memory access to the port for operating system calls on a file descriptor.
Your user account has to have read and write permissions to the "/dev/parport0". In my case "/dev/parport0" gives read and write permissions to the group lp and the user was registered to this group.
In linux it has been tested and is working. Also compatibility issues with impact have been solved.
How To? Includes: #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <linux/ppdev.h> #include <linux/ioctl.h> #include <linux/parport.h>
create a global variable called fd to carry the file descriptor pointing to the device.
int fd;
Initialize the device: int mode = IEEE1284_MODE_COMPAT; fd = open("/dev/parport0", O_RDWR | O_NONBLOCK); if (fd == -1) { perror("Not able to acquire the device desriptor\n"); return APP_ERR_INIT_FAILED; } if (ioctl(fd, PPCLAIM) == -1) { perror("Fail to claim the interface for itself.\n"); return APP_ERR_INIT_FAILED; } if (ioctl(fd, PPSETMODE, &mode) == -1) { perror("Setting compatibility mode failed.\n"); return APP_ERR_INIT_FAILED; }
Read from the device: ioctl(fd, PPRSTATUS, inval); Write to the device: ioctl(fd, PPWDATA, &value);
inval and value as shown here work with cable_parallel.c. Actually both should be pointers to "unsigned char".