Click here to Skip to main content
15,881,852 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionFlashWindowEx Pin
Dody_DK2-Jan-06 10:55
Dody_DK2-Jan-06 10:55 
AnswerRe: FlashWindowEx Pin
PJ Arends2-Jan-06 15:15
professionalPJ Arends2-Jan-06 15:15 
GeneralRe: FlashWindowEx Pin
Dody_DK2-Jan-06 23:39
Dody_DK2-Jan-06 23:39 
GeneralRe: FlashWindowEx Pin
Gavin Taylor3-Jan-06 6:32
professionalGavin Taylor3-Jan-06 6:32 
GeneralRe: FlashWindowEx Pin
Dody_DK3-Jan-06 7:47
Dody_DK3-Jan-06 7:47 
QuestionTooltip on editbox Pin
mehrdadov2-Jan-06 6:29
mehrdadov2-Jan-06 6:29 
AnswerRe: Tooltip on editbox Pin
Ravi Bhavnani2-Jan-06 8:40
professionalRavi Bhavnani2-Jan-06 8:40 
QuestionError reading from com port Pin
nitgonz2-Jan-06 5:02
nitgonz2-Jan-06 5:02 
Hi,

I am receiving an error message CXX0030 when trying to a readfile off a com 1 port.

My code is

hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // no security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped I/O
NULL);

if (hCom == INVALID_HANDLE_VALUE)
{
// Handle the error.
printf ("CreateFile failed with error %d.\n", GetLastError());

return ;
}

// Build on the current configuration, and skip setting the size
// of the input and output buffers with SetupComm.

fSuccess = GetCommState(hCom, &dcb);
if (!fSuccess)
{
// Handle the error.
printf ("GetCommState failed with error %d.\n", GetLastError());
return ;
}

//printCommState();
// Fill in DCB: 57,600 bps, 8 data bits, no parity, and 1 stop bit.

init_settings();
fSuccess = SetCommState(hCom, &dcb);
//printf ("SetCommState...\n");

if (!fSuccess)
{
// Handle the error.
printf ("SetCommState failed with error %d.\n", GetLastError());
return ;
}

fSuccess = GetCommState(hCom, &dcb);
if (!fSuccess)
{
// Handle the error.
printf ("GetCommState failed with error %d.\n", GetLastError());
return ;
}

//printCommState();

//printf ("Serial port %s successfully reconfigured.\n", pcCommPort);
res = GetCommTimeouts(hCom, &get_com_time_outs);

//print_com_timeouts();

res = SetCommTimeouts(hCom, &com_time_outs);
//printf("SetCommTimeouts...\n");
if(!res) printf("SetCommTimeouts failed...\n");
res = GetCommTimeouts(hCom, &get_com_time_outs);
read_bytes=0;
char *reply;
DWORD dwBytesTransferred;
DWORD dwCommModemStatus;

// Specify a set of events to be monitored for the port.
SetCommMask (hCom, EV_RXCHAR | EV_CTS | EV_DSR | EV_RLSD | EV_RING);

while (hCom != INVALID_HANDLE_VALUE)
{
// Wait for an event to occur for the port.
// WaitCommEvent (hCom, &dwCommModemStatus, 0);

// Re-specify the set of events to be monitored for the port.
SetCommMask (hCom, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING);

//if (dwCommModemStatus & EV_RXCHAR)
//{
// Loop for waiting for the data.
do
{
// Read the data from the serial port.
res = ReadFile(hCom, reply, 81, &dwBytesTransferred, 0);//ReadFile (hCom, &Byte, 1, &dwBytesTransferred, 0);

// Display the data read.
if (dwBytesTransferred > 0)
printf (reply);

} while (dwBytesTransferred == 1);
//}
}


void init_settings()
{
dcb.DCBlength = sizeof(DCB);
dcb.BaudRate = CBR_9600; // set the baud rate
dcb.fBinary = TRUE;
dcb.Parity = NOPARITY; // no parity bit
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_ENABLE; //
dcb.fDsrSensitivity = FALSE;
dcb.fTXContinueOnXoff = FALSE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.ErrorChar = FALSE;
dcb.fNull = FALSE;
dcb.fRtsControl = RTS_CONTROL_ENABLE;
dcb.fAbortOnError = FALSE;
dcb.fDummy2 = 0;
dcb.wReserved = 0;
dcb.XonLim = 0;
dcb.XoffLim = 0;
dcb.ByteSize = 8;
dcb.StopBits = ONESTOPBIT; // one stop bit
dcb.XonChar = 0;
dcb.XoffChar = 0;
dcb.ErrorChar = 0;
dcb.EofChar = 0;
dcb.EvtChar = 0;
dcb.wReserved1 = 0;
}

Is there something I am missing for reading off the com port?

Thanks
AnswerRe: Error reading from com port Pin
krmed2-Jan-06 5:34
krmed2-Jan-06 5:34 
GeneralRe: Error reading from com port Pin
John R. Shaw2-Jan-06 19:26
John R. Shaw2-Jan-06 19:26 
GeneralRe: Error reading from com port Pin
nitgonz3-Jan-06 2:55
nitgonz3-Jan-06 2:55 
GeneralRe: Error reading from com port Pin
krmed3-Jan-06 4:44
krmed3-Jan-06 4:44 
GeneralRe: Error reading from com port Pin
krmed3-Jan-06 4:43
krmed3-Jan-06 4:43 
AnswerRe: Error reading from com port Pin
rajan.msmy2-Jan-06 18:09
rajan.msmy2-Jan-06 18:09 
QuestionToolBar ToolTip is blocked by whom? Pin
rajan.msmy2-Jan-06 3:36
rajan.msmy2-Jan-06 3:36 
AnswerRe: ToolBar ToolTip is blocked by whom? Pin
Owner drawn2-Jan-06 16:45
Owner drawn2-Jan-06 16:45 
GeneralRe: ToolBar ToolTip is blocked by whom? Pin
rajan.msmy2-Jan-06 17:59
rajan.msmy2-Jan-06 17:59 
GeneralRe: ToolBar ToolTip is blocked by whom? Pin
Owner drawn2-Jan-06 18:08
Owner drawn2-Jan-06 18:08 
QuestionHow to delay about 1/20 milisecond ? Pin
quangpk2-Jan-06 1:43
quangpk2-Jan-06 1:43 
AnswerRe: How to delay about 1/20 milisecond ? Pin
kakan2-Jan-06 3:18
professionalkakan2-Jan-06 3:18 
AnswerRe: How to delay about 1/20 milisecond ? Pin
babuprasath2-Jan-06 4:01
babuprasath2-Jan-06 4:01 
AnswerRe: How to delay about 1/20 milisecond ? Pin
nde_plume2-Jan-06 6:02
nde_plume2-Jan-06 6:02 
AnswerRe: How to delay about 1/20 milisecond ? Pin
Alexander M.,3-Jan-06 7:43
Alexander M.,3-Jan-06 7:43 
QuestionHow to change parents Text prperty label from child dialog box Pin
RamL2-Jan-06 0:54
RamL2-Jan-06 0:54 
AnswerRe: How to change parents Text prperty label from child dialog box Pin
Owner drawn2-Jan-06 0:57
Owner drawn2-Jan-06 0:57 

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.