Click here to Skip to main content
15,895,256 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to fix the cursor Pin
Rajkumar R6-Mar-08 1:26
Rajkumar R6-Mar-08 1:26 
AnswerRe: How to fix the cursor Pin
El Corazon6-Mar-08 5:52
El Corazon6-Mar-08 5:52 
GeneralRe: How to fix the cursor Pin
Mark Salsbery6-Mar-08 6:24
Mark Salsbery6-Mar-08 6:24 
GeneralRe: How to fix the cursor Pin
El Corazon6-Mar-08 11:58
El Corazon6-Mar-08 11:58 
GeneralRe: How to fix the cursor Pin
Rajesh R Subramanian6-Mar-08 20:27
professionalRajesh R Subramanian6-Mar-08 20:27 
GeneralRe: How to fix the cursor Pin
Rajesh R Subramanian6-Mar-08 8:04
professionalRajesh R Subramanian6-Mar-08 8:04 
GeneralRe: How to fix the cursor Pin
savitri7-Mar-08 23:21
savitri7-Mar-08 23:21 
GeneralCom Port Read [modified] Pin
shakumar_225-Mar-08 23:21
shakumar_225-Mar-08 23:21 
Hi
In my programme VC++6.0 ATL COM, i used Com port Writing(output) through Com Port is done .But Reading(input) through Com port was not working Proberly.

Com Port Reading Function

OVERLAPPED comReader = { 0 };
BOOL fWaitingOnRead = FALSE;
char * lpBuf = "";
DWORD dwRead = 0; // bytes actually read
BOOL Success;
FILE* FilePtr;
DCB dcb = {0};
DWORD dwCommEvent;
COMMTIMEOUTS CommTimeOuts;
HANDLE hCommPort;

printf(" Inside CommThreadProc \n" );
//Opening the COM port
hCommPort = CreateFile( "COM1",GENERIC_READ,0,0,
OPEN_EXISTING,FILE_FLAG_OVERLAPPED, 0 );

if( hCommPort == INVALID_HANDLE_VALUE )
{ printf( "Error while Opening COM Port \n" );
return ;
}
//Getting COMM settings
GetCommState( hCommPort, &dcb );
dcb.BaudRate = CBR_9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState( hCommPort, &dcb );
//Creating overlapped event handle
comReader.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
SetCommMask( hCommPort, EV_RXCHAR );
BOOL repeat = true;

while( 1 )
{ WaitCommEvent( hCommPort, &dwCommEvent, &comReader );
if( WaitForSingleObject( comReader.hEvent, INFINITE ) == WAIT_OBJECT_0 )
{ do
{ Success = ReadFile( hCommPort,&lpBuf,512,&dwRead,&comReader );
if( !Success )
if (GetLastError() == ERROR_IO_PENDING)
printf( "Error in reading the file \n");
else
{ // writing the data into a file
FilePtr = fopen( "comport.txt", "a+" );
if( FilePtr != NULL )
fwrite( &lpBuf, dwRead, 512, FilePtr );
else
printf( "Error while opening file" );

fclose( FilePtr );
}
}while( dwRead > 0 );

}
}

CloseHandle( comReader.hEvent );
CloseHandle( hCommPort );

In message box i receive something but mesage was blank.
i try to write the received data in to "comport.txt" file but it is not working.

I want to write the receving data in txt file,receving data was an character eg:"ff fe ".

thanks

by
shakumar

shakumar

modified on Friday, March 7, 2008 1:07 AM

GeneralRe: Com Port Read Pin
CPallini5-Mar-08 23:29
mveCPallini5-Mar-08 23:29 
GeneralRe: Com Port Read Pin
shakumar_225-Mar-08 23:42
shakumar_225-Mar-08 23:42 
QuestionRe: Com Port Read Pin
Rajkumar R5-Mar-08 23:46
Rajkumar R5-Mar-08 23:46 
QuestionRe: Com Port Read Pin
CPallini5-Mar-08 23:51
mveCPallini5-Mar-08 23:51 
GeneralRe: Com Port Read Pin
shakumar_226-Mar-08 19:13
shakumar_226-Mar-08 19:13 
GeneralRe: Com Port Read Pin
CPallini6-Mar-08 21:25
mveCPallini6-Mar-08 21:25 
GeneralRe: Com Port Read Pin
shakumar_226-Mar-08 22:00
shakumar_226-Mar-08 22:00 
GeneralRe: Com Port Read Pin
Rajkumar R6-Mar-08 22:30
Rajkumar R6-Mar-08 22:30 
QuestionCreateDesktop and 3DFlip State while using WINDOW-KEY + TAB keys Pin
Jayapal Chandran5-Mar-08 23:13
Jayapal Chandran5-Mar-08 23:13 
GeneralI port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
vicky000005-Mar-08 22:54
vicky000005-Mar-08 22:54 
QuestionRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
Rajesh R Subramanian5-Mar-08 22:56
professionalRajesh R Subramanian5-Mar-08 22:56 
GeneralRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
vicky000005-Mar-08 23:05
vicky000005-Mar-08 23:05 
QuestionRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
Rajesh R Subramanian5-Mar-08 23:12
professionalRajesh R Subramanian5-Mar-08 23:12 
GeneralRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
vicky000005-Mar-08 23:28
vicky000005-Mar-08 23:28 
QuestionRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
Rajesh R Subramanian5-Mar-08 23:34
professionalRajesh R Subramanian5-Mar-08 23:34 
GeneralRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
vicky000006-Mar-08 0:28
vicky000006-Mar-08 0:28 
AnswerRe: I port my application in vc++ 2005 to vc++ 2008 -registry entry code could not work properly. Pin
Rajesh R Subramanian6-Mar-08 0:39
professionalRajesh R Subramanian6-Mar-08 0:39 

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.