Click here to Skip to main content
15,922,533 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVC6 -> .NET Pin
mcsherry2-Sep-05 2:12
mcsherry2-Sep-05 2:12 
AnswerRe: VC6 -> .NET Pin
toxcct2-Sep-05 2:40
toxcct2-Sep-05 2:40 
GeneralRe: VC6 -> .NET Pin
mcsherry2-Sep-05 2:54
mcsherry2-Sep-05 2:54 
GeneralRe: VC6 -> .NET Pin
toxcct2-Sep-05 2:59
toxcct2-Sep-05 2:59 
GeneralRe: VC6 -> .NET Pin
mcsherry2-Sep-05 3:18
mcsherry2-Sep-05 3:18 
QuestionUDP Pin
Eytukan2-Sep-05 1:58
Eytukan2-Sep-05 1:58 
GeneralRe: UDP Pin
sunit52-Sep-05 2:33
sunit52-Sep-05 2:33 
Questionexe disappears in 5-10 minutes automatically Pin
rajeevktripathi2-Sep-05 1:27
rajeevktripathi2-Sep-05 1:27 
AnswerRe: exe disappears in 5-10 minutes automatically Pin
Marc Soleda2-Sep-05 1:37
Marc Soleda2-Sep-05 1:37 
GeneralRe: exe disappears in 5-10 minutes automatically Pin
rajeevktripathi2-Sep-05 3:51
rajeevktripathi2-Sep-05 3:51 
GeneralRe: exe disappears in 5-10 minutes automatically Pin
Marc Soleda4-Sep-05 20:31
Marc Soleda4-Sep-05 20:31 
AnswerRe: exe disappears in 5-10 minutes automatically Pin
CWinThread2-Sep-05 8:59
CWinThread2-Sep-05 8:59 
AnswerRe: exe disappears in 5-10 minutes automatically Pin
ThatsAlok2-Sep-05 20:45
ThatsAlok2-Sep-05 20:45 
QuestionRezide dialog based application window Pin
johnnyXP2-Sep-05 0:55
johnnyXP2-Sep-05 0:55 
AnswerRe: Rezide dialog based application window Pin
toxcct2-Sep-05 1:11
toxcct2-Sep-05 1:11 
AnswerRe: Rezide dialog based application window Pin
Marc Soleda2-Sep-05 1:16
Marc Soleda2-Sep-05 1:16 
AnswerRe: Rezide dialog based application window Pin
namaskaaram2-Sep-05 1:16
namaskaaram2-Sep-05 1:16 
GeneralRe: Rezide dialog based application window Pin
johnnyXP2-Sep-05 5:30
johnnyXP2-Sep-05 5:30 
QuestionC Run-Time Library compilation problem Pin
Grant MacDonald2-Sep-05 0:48
Grant MacDonald2-Sep-05 0:48 
QuestionHow to call an Umanaged static library from Managed VC++ DLL?? Pin
smilerays2-Sep-05 0:41
smilerays2-Sep-05 0:41 
QuestionDownload WebBrowser Control?! Pin
bosfan2-Sep-05 0:32
bosfan2-Sep-05 0:32 
AnswerRe: Download WebBrowser Control?! Pin
Marc Soleda2-Sep-05 1:13
Marc Soleda2-Sep-05 1:13 
GeneralRe: Download WebBrowser Control?! Pin
bosfan2-Sep-05 2:29
bosfan2-Sep-05 2:29 
QuestionSerial Port Asynchronous Reading Pin
sergin801-Sep-05 23:52
sergin801-Sep-05 23:52 
Hi,

I want to read data from serial port asynchronously. I developed a program and I am sending the reading part of that program. When I build this code, I have not met any error. But, when I run the program and read data from serial port, my program gives unhandled exception error and I can not see any data on my edit box. Anybody else that helps me about this problem?

Thank you,

Semih


The reading part of my program:

#define MAX_BUFF 128
#define TEN_K 10240
#define STRMAX 1024

HANDLE Open_Com;

HANDLE SPEvent;

DCB dcb;
COMMTIMEOUTS CommTimeouts;
OVERLAPPED overlapped;

CWinThread* pComPort;
CSP_AsyncRead_2Dlg *pWnd = ((CSP_AsyncRead_2Dlg*) pComPort);

UINT ReadPort(LPVOID pComPort)
{
BYTE counter=0;

char sMsg[512];
BOOL fSuccess = 0;
DWORD dwEvtMask = 0;
BYTE tmp[16];
int ReadConstant = 1;

Open_Com = CreateFile("COM3",
GENERIC_READ | GENERIC_WRITE, //access (read and write)
0, // 0: cannot share the com port
NULL, // security (None)
OPEN_EXISTING, // creation : open existing
FILE_ATTRIBUTE_NORMAL, // overlapped I/O
NULL); // no templates file for COM port

if (Open_Com == INVALID_HANDLE_VALUE) //check whether the COM port is opened or not
{
AfxMessageBox("Port Acildi");
} // end if (m_hCom == INVALID_HANDLE_VALUE)

if (Open_Com)
{
memset(&dcb,0,sizeof(dcb));
dcb.DCBlength = sizeof ( DCB ) ;
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;

SetCommState(Open_Com, &dcb); // guncel dcb sutructure degerlerini yerlestir
SetupComm(Open_Com, MAX_BUFF, MAX_BUFF); // set input and output buffer sizes
fSuccess = SetCommMask (Open_Com, EV_RXCHAR | EV_RXFLAG); // Set the mask for the events you want to listen for

} // end if (Open_Com)
if(fSuccess)
{
while(Open_Com != INVALID_HANDLE_VALUE)
{
int iBytesRead = 0;
DWORD iBytesReadThisTime = 0;
char szData[MAX_BUFF];
BOOL bRead;

WaitCommEvent(Open_Com, &dwEvtMask, 0);

SetCommMask (Open_Com, EV_RXCHAR);
if (dwEvtMask & EV_RXCHAR){
bRead = ReadFile(Open_Com, &tmp, ReadConstant, &iBytesReadThisTime, 0);
iBytesRead += iBytesReadThisTime;
}
tmp[iBytesRead] = '\0';
if(tmp[0] != '\0'){

try
{
pWnd->m_Vreaddata.SetAt(counter++,*tmp);;//
}
catch(CException* e)
{
AfxMessageBox("Error Occurs!");
e->Delete();
}

} // if(szData[0] != '\0')
}
} //if(fSuccess)

return 0;
}
AnswerRe: Serial Port Asynchronous Reading Pin
Cedric Moonen1-Sep-05 23:54
Cedric Moonen1-Sep-05 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.