Serial Port will not open
Jan 31, 2008 at 6:40pm UTC
Hey!
I have runned into a strange problem, when trying to setup a serial port. The code I use to open the port:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Opening the Port "COM1"
hComm = CreateFile( "COM1" , GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
// DCB Settings (Baudrate, parity, numBits, stopBit)
FillMemory(&dcb, sizeof (dcb), 0);
dcb.DCBlength = sizeof (dcb);
BuildCommDCB("57600,n,8,1" , &dcb);
// Communications time-outs
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(hComm, &timeouts);
When I execute my program i can not read or write data to the port. Then I open the serial port with PUTTY and close PUTTY. Then I execute my prpgram again, and now I can both read and write to the port. Any one that can tell me whats going on???
Feb 11, 2008 at 1:06am UTC
Hay, im good with tis stuff, so if i could ask you please send me a copy of the sorce code, and note that it will be analized 9 times.
Topic archived. No new replies allowed.