Click here to Skip to main content
15,916,842 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Setup a Default Button Pin
David Crow12-Oct-05 9:55
David Crow12-Oct-05 9:55 
AnswerRe: Setup a Default Button Pin
Ian Bowler12-Oct-05 11:07
Ian Bowler12-Oct-05 11:07 
GeneralRe: Setup a Default Button Pin
David Crow13-Oct-05 2:55
David Crow13-Oct-05 2:55 
AnswerRe: Setup a Default Button Pin
vikas amin12-Oct-05 22:33
vikas amin12-Oct-05 22:33 
AnswerRe: Setup a Default Button Pin
ThatsAlok13-Oct-05 1:59
ThatsAlok13-Oct-05 1:59 
GeneralRe: Setup a Default Button Pin
Ian Bowler13-Oct-05 5:26
Ian Bowler13-Oct-05 5:26 
QuestionInvisible temporary Pin
Bob Stanneveld12-Oct-05 6:47
Bob Stanneveld12-Oct-05 6:47 
QuestionSerial Comms Help Please! Pin
Member 138216012-Oct-05 6:34
Member 138216012-Oct-05 6:34 
I can't figure this out, Please Help!!!! I would appreciate any remarks
or opinions or help about the code below.


A you can see I am writing and reading from the serial port, that is
going OK MOST of the time. My big problem is when I want to break the
while loop. I am expecting a message in HEX to come in from the serial
port. for instance "0004 600A", which I get most of the time, sometimes
I just get random ASCII chars, anyway to the point


Question #1 is the way I am storing the read return(it seems to work
alright) the best way to do it, char in[13] ?


Question #2 I need to test the response in terms of binary?
0000 0000 0000 0100 0110 0000 0000 1010


I can manage to test the bit that I am interested in but how to get to
this point I am not to sure about.


Lastly, any remarks or bug fixes on the general structure of the my
code would be great


//*************************************************************************­***********************************//


int _tmain(int argc, _TCHAR* argv[])
{
CSerial serial;
//CSyncSerialComm serial2("COM1");


char in[13];
char command[20];
DWORD bytesRead;
int value=1000;
int end;
int test;


serial.Open(1, 9600);
//serial.HomePosition(4);
while(1)
{
printf("\nEnter Command >>");
scanf("%d", &value);
sprintf(command, "4 lr %d\r4 m\r4 st\r", value);
serial.SendData(command, sizeof(command));
end = serial.ReadData(&in,20);
in[end] = '\0';
printf("value = %s",in);


if((int)in[7] > 4)
break;
}
serial.Close();
getchar();


return(0);



}


//***************************************Writing
Data**************************************//

bool CSerial::WriteCommByte( unsigned char ucByte )
{
bool bWriteStat;
DWORD dwBytesWritten;


bWriteStat = WriteFile( m_hIDComDev, (LPSTR) &ucByte, 1,
&dwBytesWritten, &m_OverlappedWrite );
if( !bWriteStat && ( GetLastError() == ERROR_IO_PENDING ) ){
if( WaitForSingleObject( m_OverlappedWrite.hEvent, 1000 ) )
dwBytesWritten = 0;
else{
GetOverlappedResult( m_hIDComDev, &m_OverlappedWrite,
&dwBytesWritten, FALSE );
m_OverlappedWrite.Offset += dwBytesWritten;
}
}


return( TRUE );



}


int CSerial::SendData( const char *buffer, int size )
{

if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );


DWORD dwBytesWritten = 0;
int i;
for( i=0; i
AnswerRe: Serial Comms Help Please! Pin
Rage12-Oct-05 7:12
professionalRage12-Oct-05 7:12 
Questionproblems with WinINet.h with visual studio 2003 Pin
brwoodru12-Oct-05 6:18
brwoodru12-Oct-05 6:18 
AnswerRe: problems with WinINet.h with visual studio 2003 Pin
prasad_som12-Oct-05 21:24
prasad_som12-Oct-05 21:24 
QuestionProblems Bringing Active X Control (.ocx) Into An Application Pin
johndavis12-Oct-05 6:06
johndavis12-Oct-05 6:06 
QuestionDo I always need a function that's executed by only one thread to initialize synchronization objetcs? Pin
Federico Milano12-Oct-05 5:55
Federico Milano12-Oct-05 5:55 
AnswerRe: Do I always need a function that's executed by only one thread to initialize synchronization objetcs? Pin
Rage12-Oct-05 7:05
professionalRage12-Oct-05 7:05 
GeneralRe: Do I always need a function that's executed by only one thread to initialize synchronization objetcs? Pin
Federico Milano12-Oct-05 7:38
Federico Milano12-Oct-05 7:38 
GeneralRe: Do I always need a function that's executed by only one thread to initialize synchronization objetcs? Pin
Blake V. Miller13-Oct-05 18:16
Blake V. Miller13-Oct-05 18:16 
GeneralRe: Do I always need a function that's executed by only one thread to initialize synchronization objetcs? Pin
Federico Milano14-Oct-05 2:20
Federico Milano14-Oct-05 2:20 
GeneralRe: Do I always need a function that's executed by only one thread to initialize synchronization objetcs? Pin
Blake V. Miller24-Nov-05 9:09
Blake V. Miller24-Nov-05 9:09 
QuestionExecute and retrieve data from console Pin
schemp9812-Oct-05 5:11
schemp9812-Oct-05 5:11 
QuestionRe: Execute and retrieve data from console Pin
David Crow12-Oct-05 6:22
David Crow12-Oct-05 6:22 
AnswerRe: Execute and retrieve data from console Pin
schemp9812-Oct-05 7:09
schemp9812-Oct-05 7:09 
GeneralRe: Execute and retrieve data from console Pin
Rage12-Oct-05 7:26
professionalRage12-Oct-05 7:26 
GeneralRe: Execute and retrieve data from console Pin
David Crow12-Oct-05 7:33
David Crow12-Oct-05 7:33 
QuestionGetting IP Address through WMI Pin
qrverona12-Oct-05 4:23
qrverona12-Oct-05 4:23 
AnswerRe: Getting IP Address through WMI Pin
David Crow12-Oct-05 6:31
David Crow12-Oct-05 6:31 

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.