Hello People!!,
i'm trying to establish a serial communication on WinNT.
The routines are running on a Win98 system but
on a WinNT the SetCommState fails with errorcode 57.
Could someone please help. ?
Regards,
Robert
Hello People!!,
i'm trying to establish a serial communication on WinNT.
The routines are running on a Win98 system but
on a WinNT the SetCommState fails with errorcode 57.
Could someone please help. ?
Regards,
Robert
57 indicates a hardware error, however, that may not mean ther is a hardware error!
Is the NT machine set up the same way? What I mean is, does your program get a handle to the COM2: port on the 98 machine but COM2: does not exist on the NT for example. Without knowing a lot more about the setup and the software it is difficult to be overly constructive.
Things to check are the handle you pass, is it valid; what you have set in the control block, is it valid/complete; the basic configuration, are you doing something illegal, be aware, that 9x systems let you "get away" with a lot of things that are not technically correct, but work anyway. NT cored systems are much more vigorous in protecting themselves. Your code may simply be exploiting one of these holes.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Hi!
On both systems i get a valid handle.Is the NT machine set up the same way? What I mean is, does your program get a handle to the COM2: port on the 98 machine but COM2: does not exist on the NT for example. Without knowing a lot more about the setup and the software it is difficult to be overly constructive.
I've checked the Ports if the correct one are used etc.
Thanks anyway, it's my fault not to tell more about my setup
I'vechecked another thread in this forum
and saw that first a GetCommState function was used, then
parameter were set by hand and finally the SetCommState function is applied. I've did it the same way and there is no
ERROR code.
I suggest that the DCB wasn't initialised correctly.
Here a fragment of my code.
[code]
tComm = CreateFile( "COM1",
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0, //FILE_FLAG_OVERLAPPED,
0);
if (tComm == INVALID_HANDLE_VALUE)
{
status = FALSE;
printf ("<CreateFile> Errorcode: %lx\n",GetLastError());
}
else
{
hComm = tComm;
GetCommState(hComm, &dcb);
// Fill in the DCB: baud=9600, 8 data bits, no parity, 1 stop bit.
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
/*~T*/
// BuildCommDCB((WCHAR *)"9600,n,8,1,x", &dcb);
/*~T*/
dcbStatus = SetCommState(hComm, &dcb);
if (!dcbStatus)
{
printf ("<SetCommState> Errorcode: %lx\n",GetLastError());
}
/*~T*/
status = TRUE;
Thanks for reply
Is that the code where you got the error number from, (i.e. is the error code 0x57, or 57 decimal)? 0x57 is a parameter error. In winerror.h the codes are decimal normally.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Hello,
you are completly right, somehow i forgot about the %lx, but
this code works on the WinNT now.
The routine only failts if the line
GetCommState(hComm, &dcb);
is not included.
Regards,
Robert