Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

Since more newer PC´s have no Parallel Port and Serial Port anymore, i need to rewrite a 10 year old MS Visual-C++ program for USB access.

First problem: Visual C++ 6.0 doesn´t support serial ports greater than 5.
On all laptops we cannot use serial ports 3 to 10 ( already occupied ).
How can I gain access to at least ports 3 , 4 or 5 ?
Second problem: On my desktops I can use either COM3: or COM4: depending on PC and Operating System (WIN XP or WIN7), however using CreateFile and WriteFile the Program freezes after approx. 50 seconds. Parallel port operation is still functioning.

I can send Code snippets, if necessary.

regards, René

EDIT - Update From OP ================
I have tried using those 8 $ USB to parallel port adapters, but they only work with real printers.
Since my control box is a write only device it cannot simulate a printer and create the respective feedback signals.
So i bought a 70 $ device USB8-I/O HB628 from H-Tronic, but when using serialport 3 or 4 (only ones available, higher ones show "already occupied" ) on my desktops my timer freezes after appr. 50 seconds. On Laptops only COM1 and COM2 are free, which cannot be used for virtual ports.

Now to the timer freeze. relevant code pieces are:

rcsp = CreateFile(portname,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,NULL,NULL);
. . . . . .
if (interf == 0) 
{ 
    // Parallel Port , this code works since 10 years
    if (abcd) 
    { 
        pdat |= 16; 
    } 
    else 
    {
        pdat &= 0xFFEF; 
    }
    if (redjustset==1) 
    { 
        // this will reset the clock
        pdat |= 64; 
        Out32(0x378,pdat);
        // wait for signal to perform clock function
        Sleep(100); 
        pdat &= 0xFF9F; 
        Out32(0x378, pdat); 
    }
    if (red) 
    {
        pdat |= 8; 
        redjustset = 0; 
    } 
    else 
    {
        pdat &= 0xFFF7;
    }
    ………….
} 
else 
{ 
    // Code for USB Port ,if interf > 0 ( 0 means Parallel Port ) 
    // ( > 0 means Serial Port ). Following code stops timer after 
    // approximately 50 to 60 seconds and program freezes.
    ………….
    if (red) 
    {
        bWriteRC = WriteFile (rcsp,"c141",4,&iBytesWritten, NULL);
        // sets ampel to red on
        redjustset = 0; 
    }
    else 
    {
        bWriteRC = WriteFile (rcsp,"c140",4,&iBytesWritten, NULL);
    } // sets ampel to red off


this program is used in archery contests and controls traffic lights and clocks to inform archers about when and how long they can shoot.

Posted
Updated 1-Jan-11 4:39am
v3

You can get USB parallel and serial port adapters (hardware). They're typically less than $10. There shouldn't be any reason to change your obsolete code.

 
Share this answer
 
Comments
LloydA111 31-Dec-10 18:38pm    
The only problem with this is if the external device dosen't work with USB to serial.
You can't possibly expect 10-year-old code to remain relevant. Technology marches on, and that in turn makes software obsolete. My advice is to rewrite your code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900