1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
Parametrage des parametres de timeout
ctmo.ReadIntervalTimeout = MAXWORD;
ctmo.ReadTotalTimeoutMultiplier = 0;
ctmo.ReadTotalTimeoutConstant = 10;
ctmo.WriteTotalTimeoutMultiplier= 2*CBR_9600/CBR_9600;
ctmo.WriteTotalTimeoutMultiplier= CBR_9600;
ctmo.WriteTotalTimeoutConstant = 0;
SetCommTimeouts( hcom , &ctmo );
//Récupération et paramétrage du port COM
if(GetCommState(hcom, &dcb) != TRUE)
return FALSE;
dcb.DCBlength = sizeof( DCB ) ;
GetCommState( hcom , &dcb ) ;
dcb.BaudRate = CBR_9600; // Vitesse de transmission
dcb.fBinary = TRUE;
dcb.fParity = FALSE;
dcb.fOutxCtsFlow = FALSE; // CTS output flow control
dcb.fOutxDsrFlow = FALSE; // DSR output flow control
dcb.fDtrControl = DTR_CONTROL_DISABLE; // DTR flow control type
dcb.fRtsControl = RTS_CONTROL_DISABLE; // RTS flow control
dcb.fDsrSensitivity = FALSE; // DSR sensitivity
dcb.fOutX = FALSE; // XON/XOFF out flow control
dcb.fInX = FALSE; // XON/XOFF in flow control
dcb.fNull = FALSE;
dcb.fRtsControl = RTS_CONTROL_ENABLE;
dcb.fAbortOnError = FALSE;
dcb.ByteSize = 8; // 8 bit de donnee
dcb.Parity = NOPARITY; // sans parité
dcb.StopBits = ONESTOPBIT; // 1 bit de stop
SetCommState( hcom , &dcb ); |