Parallel port access

Hi all

I need to write code in VC++ 6.0 on Win2K to send a string to a multiplexer connected to the parallel port LPT1. I could not figure out how to do this as the basic C functions outp and inp work for bytes, not strings! I am lost here! Can anyone help?

Thanks a heap!
:)

Comments

  • : Hi all
    :
    : I need to write code in VC++ 6.0 on Win2K to send a string to a multiplexer connected to the parallel port LPT1. I could not figure out how to do this as the basic C functions outp and inp work for bytes, not strings! I am lost here! Can anyone help?
    :
    : Thanks a heap!
    : :)
    :


    Hi!

    Why can't you loop and send the string one byte at a time? In reality, this is what's hapenning anyway. I mean, you don't send a string to a port, you send a "string" of bytes.

    Melissa

  • : : Hi all
    : :
    : : I need to write code in VC++ 6.0 on Win2K to send a string to a multiplexer connected to the parallel port LPT1. I could not figure out how to do this as the basic C functions outp and inp work for bytes, not strings! I am lost here! Can anyone help?
    : :
    : : Thanks a heap!
    : : :)
    : :
    :
    :
    : Hi!
    :
    : Why can't you loop and send the string one byte at a time? In reality, this is what's hapenning anyway. I mean, you don't send a string to a port, you send a "string" of bytes.
    :
    : Melissa
    :

    You've got some somewhat larger problems than that I'm afraid. inp and outp are old DOS type calls. VC is a 32 bit compiler, you cannot create DOS code with VC. The later versions of Windows, (I think 2000 is among these), will not allow direct access to a port. You need to talk to the port through the OS. You must get a handle to the port, (look up CreateFile() with particular reference to the Communcations Resources sections), and then use the handle based I/O system calls.



    Med venlig hilsen,

    Adrian...

  • Try this chunk of code. Works well for me.

    void PortCommunicate( HWND hwnd )
    {
    File *stream;
    char buffer[MAX_SIZE];

    for (int i = 0; i<MAX_SIZE; i++)
    buffer[i] = 1;

    stream = fopen("LPT1", "wb");
    fprintf(stream, buffer);
    fprintf(stream, "
    ");
    fclose(stream);
    }

    substitute where needed.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories