ksandy
Messages postés11Date d'inscriptionjeudi 8 juin 2006StatutMembreDernière intervention 7 août 2006
-
7 août 2006 à 17:13
ksandy
Messages postés11Date d'inscriptionjeudi 8 juin 2006StatutMembreDernière intervention 7 août 2006
-
7 août 2006 à 18:38
Bonjour,
Je suis désespérée car j'ai une erreur d'exécution lorsque j'ouvre ma boîtede dialogue en mode débug sous VC++.
Programmation MFC.
L'erreur affichée est "access violation" dans la boîte de dialogue de débug de Microsoft.
L'erreur survient même pour une simple dialog box non modifiée (dialog box par défaut avec boutons "OK" et "Cancel" fournis par Microsoft)
Merci pour vos suggestions
ksandy
Messages postés11Date d'inscriptionjeudi 8 juin 2006StatutMembreDernière intervention 7 août 2006 7 août 2006 à 17:38
Merci pour l'info. Mais, je dois avouer que je ne comprends pas trop.
Voici le conteni de "Error Report Contents)
Exception information:
Code 0xc0000005
Flags 0x00000000
Record 0x000000000000000000
Adress 0x000000000000000000
Ce qui m'embête le plus c'est que le projet s'exécute bien avant mais une fois qu'on fait un clean, l'exécutable ne marche plus... ou alors quand on modifie la dialog box.
ksandy
Messages postés11Date d'inscriptionjeudi 8 juin 2006StatutMembreDernière intervention 7 août 2006 7 août 2006 à 18:38
Voici quelques fonctions. C'est la OnChangeMode() qui ne marche pas. Il s'agit de l'envoi d'une trame particulière qui permet de changer de mode de fonctionnement. Cest le même principe que le send command plus bas qui utilise la fonction WritePort....
Et c'est cette fonction qui est mal gérée lors de l'exécution
Merci pour l'aide
// Command to send for changing the communication mode. Switch from UCRS to MP50 mode
if ((m_ucrs.GetState() & 0x0003)==1){
EndFrame = ('3'-'0');
czTrame += EndFrame;
// Sending command on the serial port.(Writting)
BytesTransferred = PortSerie.WritePort(TrameMode,10,BytesTransferred).nBytes;
//PortSerie est définie en public dans une autre classe. Mais la présente fonction OnChangeMode qui a été rajoutée n'est pas bien gérée par le compilateur et génère une erreur lors de l'exécution.
longRX = 0;
if (PortSerie.WriteChar(EndFrame)) //return 0 if writting of EOF is incorrect.
BytesTransferred ++;
if (BytesTransferred != 11)
GetDlgItem(IDC_EDIT8)->SetWindowText("Error when switching mode. Please try again");
else{
PortSerie.SetTimeouts(100,100);
result = 0;
i=0;j=0;
// reception of command on the serial port. (Reading)
do{
if((result = PortSerie.ReadCharbyChar(&character,1).answer)==1){
czTrameRX[longRX] = character;
longRX ++;
}
}while (character != EndFrame);
}
}
else if ((m_mp.GetState() & 0x0003)==1)
EndFrame = ('D'-'0');// '\r';
else
GetDlgItem(IDC_EDIT8)->SetWindowText("Select a mode before changing it");
/******************************************************************************************************
Sending and reception of frame start here when COM1
******************************************************************************************************/
PortSerie.SetTimeouts(1,1);
// Sending command on the serial port.
// result = PortSerie.WritePort(czTrame,commandsent.GetLength(),BytesTransferred).answer;
BytesTransferred = PortSerie.WritePort(czTrame,commandsent.GetLength(),BytesTransferred).nBytes;
if (BytesTransferred != (DWORD)commandsent.GetLength())
GetDlgItem(IDC_EDIT8)->SetWindowText("Error when writting on the serial port");
else
result = PortSerie.ReadCharbyChar(czTrameRX,BytesTransferred).answer;
if(!result)
GetDlgItem(IDC_EDIT8)->SetWindowText("Error when reading on the serial port");
else {
if(BytesTransferred != (DWORD)commandsent.GetLength())
GetDlgItem(IDC_EDIT8)->SetWindowText("Error when reading on the serial port");
}
}
typedef struct
{ //to return answer and nBytes of the operation (writting or reading)
DWORD answer; //return the values of operation
DWORD nBytes; // BYTES transferred when writting/reading
CString data;
} comout;