Serial port trouble

Kevin Decker

New Member
Gabor,

Opening the port seems to work correctly. I am using CreateFileA to establish the commhandle. Sorry for not including the code before.

RUN CreateFileA (vport,
READ_WRITE,
0,
0,
OPEN_EXISTING,
0,
0,
OUTPUT CommHandle).
IF CommHandle < 0 THEN DO:
MESSAGE
"Invalid comm handle:" CommHandle
VIEW-AS ALERT-BOX ERROR.
QUIT.
END.

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 Decker

New Member
Gabor,

I had not thought to check the event log previously. Great idea, but it does not contain any entries related to my problem.

Thanks,
Kevin
 
Kevin,

Unfortunatelly we have not got Windows 2000, but I could test the code on Win98 and Windows XP. It works fine.

I could not find any usefull information except one thing might help you. Many programs set timouts before calling GetCommstate. E.g.:

hCom = CreateFile(ComName.c_str(), GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0);
SetupComm(hCom, 2048, 2048);

GetCommTimeouts(hCom, &Timeouts);
Timeouts.ReadIntervalTimeout = MAXDWORD;
Timeouts.ReadTotalTimeoutMultiplier = 0;
Timeouts.ReadTotalTimeoutConstant = 0;
Timeouts.WriteTotalTimeoutMultiplier = 0;
Timeouts.WriteTotalTimeoutConstant = 0;
ierr = SetCommTimeouts(hCom, &Timeouts);

GetCommState(hCom, &dcbBuf);


It might help you also.


Best regards,
Gabor
 

Kevin Decker

New Member
Gabor,

Thank you for all your help, I will try the timeouts. Additionally, I know that Win 2000 has alot more security issues to deal with, so I will be researching if it is a 'permission' issue. However I am already logged in as Administrator. so I don't expect much.

Thanks,
Kevin
 
Top