Toujours le meme probleme

vincent -  
 vincent -
j'ai toujours le meme probleme avec ma communication serie
je n'arrive pas a l'ouvrir sous windows nt
sous 98 ca marche
pour initialiser la communication j'utilise ca:
CString Config="2400,n,8,1";
BuildCommDCB(Config,&Block);
if (Port!=NULL) CloseHandle(Port);
Port=CreateFile("COM1",GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
Block.ByteSize=8;
Block.Parity=NOPARITY;
Block.StopBits=ONESTOPBIT;
Block.DCBlength;
Block.fBinary=1;
Block.fParity=0;
Block.fOutxCtsFlow=0;
Block.fOutxDsrFlow=0;
Block.fDtrControl=0;
Block.fDsrSensitivity=0;
Block.fTXContinueOnXoff=0;
Block.fRtsControl=0;
SetCommState(Port,&Block);

alors si vous faites autrement et que ca marche ben je suis preneur
merci d'avance

2 réponses

zebiloute Messages postés 105 Statut Membre 4
 
Bon deja un petit truc Pourkoi tu ouvre ton port serie en ecriture seule ?? tu reçoi jamais de réponse ??

Sinon je te file un petit bout de prog que j'ai retrouver chez moi (C'est un truc que g récupérer sur le net. Ca marche bien sous NT 4.0 avec le service pack 4, 5, 6 et visual 5.0 ou 6.0 pour info). Au boulout on fait ca avec des completions (Plus compliquer).

C'est une fonction utiliser dans une Dll donc te formalise po trop sur le dllAcces.

{
if ((hCom = CreateFile(TRIO2_COM,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL)) == INVALID_HANDLE_VALUE)

goto end;

if (GetCommState(hCom, &dcb) != TRUE)
{
goto end;
}

dcb.BaudRate = CBR_38400;
dcb.fBinary = TRUE;
dcb.fParity = FALSE;
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;

dcb.fDsrSensitivity = FALSE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.fNull = FALSE;

dcb.ByteSize = 7;
dcb.Parity = EVENPARITY;
dcb.StopBits = TWOSTOPBITS;

ctmo.ReadTotalTimeoutConstant=5;
SetCommTimeouts(hCom, &ctmo);

if ( (PurgeComm(hCom, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR) != TRUE) ||
(SetCommTimeouts(hCom, &ctmo) != TRUE))
goto end;

if (SetCommState(hCom, &dcb) != TRUE)
{
goto end;
}

end:
if (PurgeComm(hCom, PURGE_RXCLEAR) == TRUE)
{
CtxStId[0]->Ctx->Machine.hCom2 = hCom;
ControleMotionTrio(CtxStId);
return(FALSE);
}
else
return(TRUE);
}

PS : Qu'est ce qui se passes exactement avec ton prog ?? Parceque là je vois po trop ce qui déconne !

Quand ça veut Po ça veut po !!!
- Et ben y a plus qu'à attendre -
0
vincent
 
ben en fait le port serie est uniquement utilise en ecriture
je ne recoit aucune donnee
le but est d'envoyer des codes ascii choisis pour controler des servo moteur (mais ca c'est un detail)
0