Ik heb de volgende code gebruikt om de seriele poort in te stellen met Visual C++ 5.0 onder Windows XP.
De code lijkt foutloos, maar toch krijg ik de error dat de poort niet kon geconfigureerd worden.
Met GetLAstError krijg ik las error 1244808, een mij niet bekende error.
Weet iemand wat het probleem hier kan zijn? Ik heb echt geen gedacht van waar ik moet beginnen zoeken. Misschien hebben de meer ervaren VC++ gebruikers hier wel een antwoord op??
{
DWORD dwError;
DCB PortDCB;
PortDCB.DCBlength = sizeof (DCB);
GetCommState (hPort, &PortDCB);
PortDCB.BaudRate = 9600;
PortDCB.fBinary = TRUE;
PortDCB.fParity = TRUE;
PortDCB.fOutxCtsFlow = FALSE;
PortDCB.fOutxDsrFlow = FALSE;
PortDCB.fDtrControl =DTR_CONTROL_ENABLE;
PortDCB.fDsrSensitivity = FALSE;
PortDCB.fTXContinueOnXoff = TRUE;
PortDCB.fOutX = FALSE;
PortDCB.fInX = FALSE;
PortDCB.fErrorChar = FALSE;
PortDCB.fNull =FALSE;
PortDCB.fRtsControl = RTS_CONTROL_ENABLE;
PortDCB.fAbortOnError = FALSE;
PortDCB.ByteSize = 8;
PortDCB.Parity = NOPARITY;
PortDCB.StopBits = ONESTOPBIT;
SetCommState(hPort, &PortDCB);
if (!SetCommState (hPort, &PortDCB))
{
MessageBox (NULL, TEXT("Unable to configure the serial port"));
dwError = GetLastError ();
};
}
De code lijkt foutloos, maar toch krijg ik de error dat de poort niet kon geconfigureerd worden.
Met GetLAstError krijg ik las error 1244808, een mij niet bekende error.
Weet iemand wat het probleem hier kan zijn? Ik heb echt geen gedacht van waar ik moet beginnen zoeken. Misschien hebben de meer ervaren VC++ gebruikers hier wel een antwoord op??
{
DWORD dwError;
DCB PortDCB;
PortDCB.DCBlength = sizeof (DCB);
GetCommState (hPort, &PortDCB);
PortDCB.BaudRate = 9600;
PortDCB.fBinary = TRUE;
PortDCB.fParity = TRUE;
PortDCB.fOutxCtsFlow = FALSE;
PortDCB.fOutxDsrFlow = FALSE;
PortDCB.fDtrControl =DTR_CONTROL_ENABLE;
PortDCB.fDsrSensitivity = FALSE;
PortDCB.fTXContinueOnXoff = TRUE;
PortDCB.fOutX = FALSE;
PortDCB.fInX = FALSE;
PortDCB.fErrorChar = FALSE;
PortDCB.fNull =FALSE;
PortDCB.fRtsControl = RTS_CONTROL_ENABLE;
PortDCB.fAbortOnError = FALSE;
PortDCB.ByteSize = 8;
PortDCB.Parity = NOPARITY;
PortDCB.StopBits = ONESTOPBIT;
SetCommState(hPort, &PortDCB);
if (!SetCommState (hPort, &PortDCB))
{
MessageBox (NULL, TEXT("Unable to configure the serial port"));
dwError = GetLastError ();
};
}