LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

unable to set ECP parallel port in byte mode

I'm trying to set the control bit 5 of the control register of the parallel port of my PC running windows XP . But the bit doesn't set at all and remains at logic 0....but the other bits of control register can be set or reset...I'm trying to do this using a C program.....

The program runs fine but My ECP parallel port doesnt set itself in byte mode/bidirectional mode...
******************
    #include <stdio.h>
#include <windows.h>
#include <conio.h>
/* Definitions in the build of inpout32.dll are:            */
/*   short _stdcall Inp32(short PortAddress);               */
/*   void _stdcall Out32(short PortAddress, short data);    */


/* prototype (function typedef) for DLL function Inp32: */
      #define PPORT_BASE  (0x378)
#define PPORT_CTRL  (PPORT_BASE+2)

     typedef short _stdcall (*inpfuncPtr)(short portaddr);
     typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);

int  main()
{
     HINSTANCE hLib;
     inpfuncPtr inp32;
     oupfuncPtr oup32;

     short x,y;
     int i,pinput;

     /* Load the library */
     hLib = LoadLibrary("inpout32.dll");

     if (hLib == NULL) {
          printf("LoadLibrary Failed.\n");
          return -1;
     }

     /* get the address of the function */

     inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");

     if (inp32 == NULL) {
          printf("GetProcAddress for Inp32 Failed.\n");
          return -1;
     }


     oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");

     if (oup32 == NULL) {
          printf("GetProcAddress for Oup32 Failed.\n");
          return -1;
     }


/***************************************************************/
/* now test the functions */

          /*****  One more time, different value */

    i=0x37A;

                     /***** And read back to verify  */
    
            (oup32)(PPORT_CTRL,  0xEF);
             x = (inp32)(i);
              printf("port read (%04X)= %04X\n",i,x);

     FreeLibrary(hLib);
     getch();
                         return(0);
}
0 Kudos
Message 1 of 4
(3,372 Views)
And you posted this question on a LabVIEW forum because.....

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 4
(3,368 Views)
Hey Himanjim,
 
I remember doing something similar to this a long time ago, and I just followed the following article to make it succeed. Custom Project: Controlling LED's with a Parallel Port
 
Regards,
 
Nick Delbar
Message 3 of 4
(3,345 Views)
Thanks a lot mr. Nick....
I actually solved the problem by changing the BIOS settings of my || port from ECP to bidirectional
0 Kudos
Message 4 of 4
(3,334 Views)