ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well i'm having trouble using ioperm and outb for some reason, my code looks fine but it just doesnt work. I sorta lost my test circuit in the process so i'm interfacing it directly to an LCD HD44780 module, which i have coded already and it has worked under w32, now i'm working on porting this to linux and i'm basically stuck in the converting my OutPort function from windows to linux, i don't get the expected output.
Basically my PORT_init function is like this:
Code:
int PORT_init(unsigned long nPort)
{
int err;
/* Get parallel port access permissions */
err = ioperm(nPort,3,1);
if(err){
perror("ioperm");
return -1;
}
OutPort(LPTD_DATA,SIG_D_LOW);
return 0;
}
short OutPort(unsigned short nPort, unsigned char cByte)
{
outb(cByte, nPort);
return 0;
}
where LPTD_DATA is 0x378 and SIG_D_LOW is 0
Yet when i try to initialize my LCD using this i get no output using the same code that worked. I'm running this as root and get no seg faults. I was wondering if it might be easier to use /dev/lp0? since then i wouldnt have to hardcode the port addresses. I've been reading about this and it goes somewhat like this from what i've read:
Code:
fd = open("/dev/lp0", O_RDRW | O_NDELAY);
then i would have to seek and write/read bytes. Could anyone help me out trying this? I think it'd be a better idea since it's much more compatible and gives you the chance to run as non-root if you set the permissions ahead of time. Thanks.
still need a response, or some link. Been searching online and i only find the same damn guide everywhere that just says something about using open and then using fseek (no idea how to use that) to get to the place you want to go (maybe 0x378 in my case?) and then you use read() and write() to manipulate the parallel port, of course the guide barely talks about this. Upon searching i find this same guide at five million different sites, so i don't really get anywhere, maybe trying a more specific search. Anyway if someone could just give me a quick example (maybe just how to write/read a byte to the data lines on the parallel port, using open + read/write no ioperm) i'de be extremely grateful. Thanks.
basically i only need to be able to send bytes through the parallel power which i believe can be done in user space. It's pretty simple, i'd be surprised if i cant access it without resorting to ioperm and stuff. All i have to do is send through the data lines a byte and through the status lines. not too complicated.
The programming is beyond me. I just do PHP not C or C++, but have you confirmed that your parallel port is actually working. Do you have any parallel hardware that you can test on (printer, scanner)?
I say that because I have a parallel scanner that is very picky about it's port. It will not work with my onboard parallel port, but does through a Netmos serial/parallel card. I needed to get a kernel patch to get that piece of hardware working properly, so that it correctly identified the parport.
Once you know the port is working, then you can look further into whether your signals are being detected.
Yeah it works. I'm mainly trying to port some old code i did for windows, in which it also worked. So unless for some reason it has broken on me recently, it should be working fine.
Originally posted by bobbens Yeah it works. I'm mainly trying to port some old code i did for windows, in which it also worked. So unless for some reason it has broken on me recently, it should be working fine.
No I don't mean "does your hardware work", I mean "does your hardware work IN LINUX".
I had a Joystick that worked in Windows but did not work in Linux. It took a lot or research and trial and error and eventually hacking of joystick module file to get that working. So confirm that your port works in Linux for something basic and then test your code on it.
Originally posted by Kerrysl No I don't mean "does your hardware work", I mean "does your hardware work IN LINUX".
I had a Joystick that worked in Windows but did not work in Linux. It took a lot or research and trial and error and eventually hacking of joystick module file to get that working. So confirm that your port works in Linux for something basic and then test your code on it.
well i remember getting a parallel port printer working in linux a while back, i was testing it because i was printing funny with usb, so i hooked it up via parallel port and it kept on printing funny, so i trashed it. So about it working, i'm pretty sure it is.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.