Click here to Skip to main content
15,923,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralQuestion about a edit box! Help! Pin
dxhdxh20-Apr-03 14:09
dxhdxh20-Apr-03 14:09 
GeneralRe: Question about a edit box! Help! Pin
Nick Parker20-Apr-03 16:57
protectorNick Parker20-Apr-03 16:57 
GeneralRe: Question about a edit box! Help! Pin
DuFF21-Apr-03 7:08
DuFF21-Apr-03 7:08 
GeneralI need help with MATLAB questions Pin
nxz420-Apr-03 11:17
nxz420-Apr-03 11:17 
GeneralRe: I need help with MATLAB questions Pin
Nick Parker20-Apr-03 16:51
protectorNick Parker20-Apr-03 16:51 
GeneralRe: I need help with MATLAB questions Pin
Anonymous20-Apr-03 21:52
Anonymous20-Apr-03 21:52 
GeneralRe: I need help with MATLAB questions Pin
Toni7821-Apr-03 11:58
Toni7821-Apr-03 11:58 
GeneralUsing the serial com port Pin
Q15002220-Apr-03 10:05
Q15002220-Apr-03 10:05 
Hi,
I am using the following code to talk to the 'Com1':

int CommPort::CreatePort(_Port port , HANDLE *hCom)
{
DCB dcb;
bool fSuccess;
char *pcCommPort;
CString buffer;

buffer.Format("\\\\.\\%s", port.com);
pcCommPort = new char[buffer.GetLength() + 1];
for(int i = 0; i <= buffer.GetLength(); i++)
*(pcCommPort + i) = buffer.GetAt(i);
*hCom = CreateFile(pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
delete[] pcCommPort;

if(*hCom == INVALID_HANDLE_VALUE)
return -1;

fSuccess = GetCommState(*hCom, &dcb); //Portkonfiguration mit GetCommState
if(!fSuccess)
return -1;

dcb.BaudRate = port.dcb.BaudRate;//Konfigurationswerte des Ports
dcb.ByteSize = port.dcb.ByteSize;
dcb.Parity = port.dcb.Parity;
dcb.StopBits = port.dcb.StopBits;
dcb.fAbortOnError = true;
dcb.fTXContinueOnXoff = true;

fSuccess = SetCommState(*hCom, &dcb);//Portkonfiguration mit SetCommState
if(!fSuccess)
return -1;

return 1;
}

So far so good. But if I try to read the port by using :

bool CommPort::ReadPort(HANDLE hCom, CString *ScannText)
{

char buf[128];
DWORD lpNumberOfBytesRead;
bool bReturn;

bReturn = ReadFile(hCom, &buf, 128, &lpNumberOfBytesRead, NULL);

buf[lpNumberOfBytesRead] = '\0';
*ScannText = buf;

return bReturn;
}

I don't get the information of the port. I am able to read the port only if I connect to COM1 with hyperterminal. After connecting with hyperterminal the program runs without problems. But if I shut down my PC and start it again I will not be able to run my program. I must always start hyperterminal first.

Is there anybody who can help?
GeneralRe: Using the serial com port Pin
anju20-Apr-03 17:38
anju20-Apr-03 17:38 
GeneralRe: Using the serial com port Pin
Toni7821-Apr-03 11:53
Toni7821-Apr-03 11:53 
GeneralWorker-Thread In Win32 Application Pin
ZarrinPour20-Apr-03 5:27
ZarrinPour20-Apr-03 5:27 
GeneralRe: Worker-Thread In Win32 Application Pin
Ravi Bhavnani20-Apr-03 6:34
professionalRavi Bhavnani20-Apr-03 6:34 
GeneralRe: Worker-Thread In Win32 Application Pin
Johann Gerell20-Apr-03 6:48
Johann Gerell20-Apr-03 6:48 
GeneralRe: Worker-Thread In Win32 Application Pin
Ravi Bhavnani20-Apr-03 12:09
professionalRavi Bhavnani20-Apr-03 12:09 
GeneralAdding controls to a ListView based app Pin
TelMonks20-Apr-03 4:01
TelMonks20-Apr-03 4:01 
GeneralRe: Adding controls to a ListView based app Pin
Ravi Bhavnani20-Apr-03 6:35
professionalRavi Bhavnani20-Apr-03 6:35 
GeneralRe: Adding controls to a ListView based app Pin
TelMonks20-Apr-03 7:59
TelMonks20-Apr-03 7:59 
GeneralMeeting troubles when reading two integers from a file. Pin
George220-Apr-03 2:41
George220-Apr-03 2:41 
GeneralRe: Meeting troubles when reading two integers from a file. Pin
Nick Parker20-Apr-03 3:15
protectorNick Parker20-Apr-03 3:15 
GeneralRe: Meeting troubles when reading two integers from a file. Pin
George220-Apr-03 3:23
George220-Apr-03 3:23 
QuestionHow to let vector store reference? Pin
George220-Apr-03 2:31
George220-Apr-03 2:31 
AnswerRe: How to let vector store reference? Pin
Nick Parker20-Apr-03 3:22
protectorNick Parker20-Apr-03 3:22 
GeneralRe: How to let vector store reference? Pin
George220-Apr-03 3:27
George220-Apr-03 3:27 
GeneralRe: How to let vector store reference? Pin
Nitron21-Apr-03 3:09
Nitron21-Apr-03 3:09 
GeneralRe: How to let vector store reference? Pin
George221-Apr-03 19:52
George221-Apr-03 19:52 

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.