Click here to Skip to main content
16,004,887 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionStatic OnPaint question Pin
followait21-Sep-05 20:18
followait21-Sep-05 20:18 
AnswerRe: Static OnPaint question Pin
Mircea Puiu21-Sep-05 20:25
Mircea Puiu21-Sep-05 20:25 
GeneralRe: Static OnPaint question Pin
Trollslayer22-Sep-05 1:13
mentorTrollslayer22-Sep-05 1:13 
QuestionAccessing the MessageQueues??? Pin
G.Radhakrishna21-Sep-05 20:10
G.Radhakrishna21-Sep-05 20:10 
AnswerRe: Accessing the MessageQueues??? Pin
John R. Shaw21-Sep-05 21:47
John R. Shaw21-Sep-05 21:47 
AnswerRe: Accessing the MessageQueues??? Pin
David Crow22-Sep-05 3:04
David Crow22-Sep-05 3:04 
QuestionCreate DLL in C++ and Link via a Matlab DLL Pin
ntrprs21-Sep-05 19:44
ntrprs21-Sep-05 19:44 
Questionhow to send structures over tghe comm ports? Pin
Member 226824821-Sep-05 18:34
Member 226824821-Sep-05 18:34 
i am writing a code to send a packet of data in the form of structures over the comm port to hyper terminal. The code while compiling does not give any errors but at the hyper terminal i receive all junk values.
pls help me to work this out.
here is the code that i wrote
//____________________________________________________-
// to write from one port & to read on the other port using hyper terminal

#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "windows.h"
#include "dos.h"
#include "time.h"
#include "string.h"
#include "process.h"
#include "iostream.h"

struct human
{
char Name[4] ;
char grp[5] ;
int Age ;

};
char *port="COM2";
HANDLE hCom;
DCB dcb;
COMMTIMEOUTS comTimeout;
unsigned long n;
char ch;
int open_com(char * com);
void writecom(human *);

//----------------------------------------------------------------------------

void main()
{ human me = {"ajo","good",21};
human *s = &me;
open_com(port);
while(1)
{ writecom(&me);
ch = getch();
}
}
//----------------------------------------------------------------------------
int open_com(char * com){
hCom = CreateFile(com, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hCom == INVALID_HANDLE_VALUE)
{
printf("Open COM port failed!!!\n");
exit(0);
}
GetCommState(hCom, &dcb);
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(hCom, &dcb);

comTimeout.ReadIntervalTimeout = 300;
comTimeout.ReadTotalTimeoutMultiplier=300;
comTimeout.ReadTotalTimeoutConstant=300;
comTimeout.WriteTotalTimeoutMultiplier = 3;
comTimeout.WriteTotalTimeoutConstant = 2;
SetCommTimeouts(hCom, &comTimeout);
return 1;
}
//----------------------------------------------------------------------------
void writecom(human *s) {
WriteFile(hCom,s,sizeof(*s),&n,NULL);
}


AnswerRe: how to send structures over tghe comm ports? Pin
David Crow22-Sep-05 3:05
David Crow22-Sep-05 3:05 
GeneralRe: how to send structures over tghe comm ports? Pin
Member 226824822-Sep-05 18:14
Member 226824822-Sep-05 18:14 
AnswerRe: how to send structures over tghe comm ports? Pin
mikeorama1234522-Sep-05 6:19
mikeorama1234522-Sep-05 6:19 
GeneralRe: how to send structures over tghe comm ports? Pin
Member 226824822-Sep-05 19:19
Member 226824822-Sep-05 19:19 
GeneralRe: how to send structures over tghe comm ports? Pin
David Crow23-Sep-05 2:25
David Crow23-Sep-05 2:25 
GeneralRe: how to send structures over tghe comm ports? Pin
Member 226824822-Sep-05 20:02
Member 226824822-Sep-05 20:02 
GeneralRe: how to send structures over tghe comm ports? Pin
Member 226824822-Sep-05 20:25
Member 226824822-Sep-05 20:25 
GeneralRe: how to send structures over tghe comm ports? Pin
mikeorama1234523-Sep-05 4:09
mikeorama1234523-Sep-05 4:09 
QuestionCan CListBox display items for left to right, top to bottom Pin
followait21-Sep-05 18:25
followait21-Sep-05 18:25 
AnswerRe: Can CListBox display items for left to right, top to bottom Pin
David Crow22-Sep-05 3:09
David Crow22-Sep-05 3:09 
Questionsave picture (*.bmp) Pin
21-Sep-05 18:15
suss21-Sep-05 18:15 
QuestionRe: save picture (*.bmp) Pin
khan++21-Sep-05 21:21
khan++21-Sep-05 21:21 
QuestionCopy using Ctrl+C Pin
sanjay_ksk21-Sep-05 17:34
sanjay_ksk21-Sep-05 17:34 
AnswerRe: Copy using Ctrl+C Pin
Nishad S21-Sep-05 19:00
Nishad S21-Sep-05 19:00 
QuestionRe: Copy using Ctrl+C Pin
sanjay_ksk21-Sep-05 21:21
sanjay_ksk21-Sep-05 21:21 
AnswerRe: Copy using Ctrl+C Pin
Nishad S21-Sep-05 21:43
Nishad S21-Sep-05 21:43 
AnswerRe: Copy using Ctrl+C Pin
Nishad S21-Sep-05 21:55
Nishad S21-Sep-05 21:55 

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.