Menu

Parallel port access using Dev c++ in Windows

Shailbond
2007-08-16
2012-09-26
  • Shailbond

    Shailbond - 2007-08-16
    1. I am writing a program to access parallel port in Windows XP.
    2. taking help from net i found a program called UserPort which opens ports.
    3. Using a small program in C using stdio and conio include files i could access the port.
    4. However the problem is i have to write code in C++ and when i try to compile the same code in C++ as a .cpp file the compiler gives an error saying "_outp undeclared " and " sleep undeclared". the same code compiles properly in c using same IDE.
    5. I am using Dev-C++ 4.9.9.2. I cant use any other compiler.
    6. My code is given below as a c file

    /******
    binary counter : This will count from 0 to 255 This takes printer port address as 0x378 and pauses for 250 mS between every count
    *******/

    include <stdio.h>

    include <conio.h> /required for _outp/

    int main()
    {
    int x;
    for(x = 0;x<=255;x++)
    {
    _outp(0x378,x);
    sleep(250);
    }
    return 0;
    }

    1. Pl help. Its urgent as same code doesnt work when compiled as C++ file.

    Shaleen Singh

     
    • Anonymous

      Anonymous - 2007-08-17

      The _outp() function is declared in Microsoft's conio.h - however if you have a conio.h file at all, it is likely to be a clone of the Borland library header (which is very different). Moreover direct hardware I/O will not work at all in NT/2K/XP because they are kernel protected resources, you will need a port I/O driver.

      Clifford

       
    • Osito

      Osito - 2007-08-16

      I've always just used window.h and Sleep(), which works with C and C++. I checked my header files and I don't even have "sleep" defined anywhere, so you must be doing something different if that worked for you in C. I do have _sleep, and I stuck it into a C++ prog and it did compile with stdlib.h included. Hope that helps.

       
    • Osito

      Osito - 2007-08-16

      Sorry that should be windows.h, duh. Too early in the morning.

       
    • Shailbond

      Shailbond - 2007-08-17

      Thanks guys windows.h and stdlib.h both solved my problem of Sleep function. both Sleep and _sleep are working, but what about _outp function. Is there any other function to output data to a parallel port in Dev c++.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.