Serial port trouble

Kevin Decker

New Member
I am using Progress V9.1C18, Procedure Editor, Win 2000.

I have written an application to ouput data to an Elton Orion tag printer. My application uses sample code submitted by Chris Schriber which used Kernel32.dll to output data to serial ports. This has worked without fail for Win 95 & 98, but fails when used with Win 2000. I have narrowed it down to Kernel32's GETCOMMSTATE. On Win 2000, GETCOMMSTATE is always returning a 0. I have researched this function on the MS web page, but found nothing helpful. I suspect the DCB Structure is different for Win 2000 than it is for Win 95.

I would appreciate any ideas which might help.

Thanks,
Kevin
 
K

Kevin Decker

Guest
Gabor,

Upon calling GetCommState there is no structure, it is defined only as a Memptr with a Size of 29. The structure is then modified after calling GetCommState. The modified structure is then updated with SetCommState (see code below).

SET-SIZE(DCBStructurePointer) = 29.
RUN GetCommState (CommHandle,
INPUT-OUTPUT DCBStructurePointer,
OUTPUT nRC).

IF nRC <>0 THEN DO:
ASSIGN DCBStructure = GET-STRING(DCBStructurePointer,1).
PUT-LONG(DCBStructurePointer,5)=9600.
bit-flags=EXP(2,9) + EXP(2,10).
PUT-LONG(DCBStructurePointer,9)=bit-flags.
PUT-BYTE(DCBStructurePointer,19)=8.
PUT-BYTE(DCBStructurePointer,20)=0.
RUN SetCommState (CommHandle,
INPUT-OUTPUT DCBStructurePointer,
OUTPUT nRC).
IF nRC=0 THEN
MESSAGE
"error setting new parameters"
VIEW-AS ALERT-BOX.
END.



Thanks,
Kevin
 
Kevin,

I have the following questions:

1. Have you checked CommHandle before GetCommState() call?
Checking not null is not enough it can be INVALID_HANDLE_VALUE also (defined as -1).

2. Have you checked the event log?

Regards,
Gabor
 
Top