Click to See Complete Forum and Search --> : Linux I/O port programming


edpuchta
01-25-2003, 11:58 PM
hello!
I am with problems to send bytes for parallel port. When sending a byte for the parallel port, it is in the pin some microseconds but when I go to read the port the byte is there therefore is reading the buffer. I know that necessary to prioritize my software, some another program is using lp0 and the byte does not leave that I sent fixture in the pin of the port, but as I make this? When I bind to only one led in the parallel port it is blinking when sending a bit, necessary that I function equal to windows when to send a byte it is in the pin of the parallel port until I change the state of the bits.
thank you very much!

I`m sorry but i don`t speek english, I am using the translator!

ChryZKoiD
01-26-2003, 10:22 AM
You have to set the terminal device to use non-canonical mode, I think
static struct termios portterm;
static struct termios oldterm;

// Get old settings
tcgetattr(PortFD, &oldterm
portterm = oldterm;

portterm.c_cc[VMIN] = 1;
portterm.c_cc[VTIME] = 1;

//apply to ports filedescriptor
tcsetattr(PortFD, TCSANOW, &portterm);


Read the documents at the Linux Documentation Project.

edpuchta
01-26-2003, 03:24 PM
hello!
I tried to find in linux documment some thing on this but I did not find! He would like a complete example of as to send a byte for the parallel port, and it I am there until to send the next byte! today I am making thus:
/*
* example.c: very simple example of port I/O
*t
*
*/

#include <stdio.h>
#include <unistd.h>
#include <asm/io.h>

#define BASEPORT 0x378 /* lp1 */

int main()
{
/* Get access to the ports */
if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);}

/* Set the data signals (D0-7) of the port to all low (0) */
outb(0, BASEPORT);

sleep(30);

/* Read from the status port (BASE+1) and display the result */
printf("status: %d\n", inb(BASEPORT + 1));

/* We don't need the ports anymore */
if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);}

exit(0);
}

/* end of example.c */

But the byte is only some microseconds in the bolts, would like that when to send a byte it is there until I to send the next one!
thank you very much!