Results 1 to 2 of 2
Hello,
I am trying to write data to a parallel port of PC 104 by the following code. It works perfectly on DELL PC.
On PC 104, I am not ...
- 04-16-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 6
Writing data to control pins of parallel port
Hello,
I am trying to write data to a parallel port of PC 104 by the following code. It works perfectly on DELL PC.
On PC 104, I am not able to set the control register to any desired value say 0x00, which will set the bidirectional mode. I am getting 1 on all the pins of the parallel port by default.
/* Generate pulse by parallel port with min and max exposure time.
Exposure time is controlled by the width of the pulse */
#include <stdio.h>
#include <sys/io.h>
//#include <sys/capability.h>
//#include <unistd.h>
int base=0x378;
int value,i;
int permission()
{
/* The line below gives access to the addresses else you get
'Segmentation Fault' that is accessing restricted addresses.
If success then you get 0 else -1
*/
//CAP_SYS_RAWIO;
iopl(3);
return ioperm(base,1,1);
iopl(3);
return ioperm(0x37A,1,1);
printf ("\nPermission granted if IOPERM is Zero = %d\n\n",ioperm(0x37A,1,1));
outb(0x00,0x37A);
//iopl(3);
//return ioperm(base,1,1);
}
int main( )
{
// Get permission to access
permission();
// Infinite pulses
// while(1)
// Ten pulses of equal duration , 50 % duty cycle
for (i=1;i<2;i++)
{
printf("Low\n");
int value = 0x00;
printf("outb(%02X,%04X)\n\n",value,base);
outb(value,base);
usleep(100); //Waits for micro secs
printf("High\n");
value = 0x08;
printf("outb(%02X,%04X)\n\n",value,base);
outb(value,base);
usleep(100); //Waits for micro secs*/
//outb(0x0C,0x37A);
printf("Status Pins %02X\n\n\n",inb(0x379));
printf("Control Pins %02X\n",inb(0x37A));
printf("Data Pins %02X\n\n",inb(base));
}
//sprintf("Number of pulses %d\n",i-1);
}
Please help, I am too desperate now.
- 04-17-2009 #2Just Joined!
- Join Date
- Mar 2009
- Posts
- 6
Hi everyone,
Thanks for viewing the thread and ponding over the solution. The code worked/works. The problem was with the unit attached to the parallel port.
Thanks!


Reply With Quote