Hey!
I have runned into a strange problem, when trying to setup a serial port. The code I use to open the port: - // 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???
5 2104
Is your file handle hComm valid??
You don't check it after CreateFile.
yes the handle is valid.
Hi!buggex. When I looking your code.I only find that you just opened
your COM1 port ,set up DCB structure and Timeout . I guess that you
you need another function "readfile()" and "writefile()".Then,operate
hComm handle for read or write COM port.
Hi!buggex. When I looking your code.I only find that you just opened
your COM1 port ,set up DCB structure and Timeout . I guess that you
you need another function "readfile()" and "writefile()".Then,operate
hComm handle for read or write COM port.
Yes i have them to.
The write command - WriteFile(hComm, (LPVOID)&lpBuf, 1, &dwWritten, NULL);
The read command - ReadFile(hComm, lpBuf, 1, &dwRead, NULL);
Yes i have them to.
The write command - WriteFile(hComm, (LPVOID)&lpBuf, 1, &dwWritten, NULL);
The read command - ReadFile(hComm, lpBuf, 1, &dwRead, NULL);
Dear:BUGGEX
I have no ideal that your problem was already solved or not.Basically,I thought on the matter was two strange points.
First,you excused your program and it had not error?? It's just not work for I/O.
Second ,you excused your program after used PUTTY.But your program It's work??
About your first strange point,As result of your codes information are not complete enough.So I can't help you.
As for second ,I got some information from MSDN document below this URL
http://msdn2.microsoft.com/en-us/library/aa363423(VS.85).aspx
Maybe,the first paragraph is what you wanna know.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ^CeFoS^ |
last post by:
Hello to everybody,
I've done an application that draws in a frame the trajectory of a
robot. The robot position is readed through the serial port, and
several commands are wrote through the...
|
by: willie |
last post by:
Hi,
I'm writing a program which requires the use of three serial ports and
one parallel port. My application has a scanning devices on each port,
which I can access fine with pyserial. ...
|
by: Rick |
last post by:
Hi,
Sorry, I couldn't find a better title for this post. Anyway, I got a piece
of C code which only works well if I put a fprintf in it. Here's the code :
unsigned int8 Port_getPortNum( char...
|
by: collinm |
last post by:
hi
i send a command to a led display, the led display is suppose to return
me some character
i write a string on a serial port
void ledDisplayExist()
{
char msg={'\0', '\0', '\0', '\0',...
|
by: Michael Chong |
last post by:
I wrote a program that communicate with SerialComm. In every 300
milliseconds, my program continuously send & receive data via the serial
port once the program starts.
My program is once in a...
|
by: Al the programmer |
last post by:
I need to access the serial ports on my webserver from an asp.net page. I
have no problem accessing the serial ports from a windows form application,
but the code doesn't work in asp.net. I have...
|
by: Franklin M. Gauer III |
last post by:
Hi All,
I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.
The application runs fine on my development machine. The...
|
by: Rob |
last post by:
Hi all,
I am fairly new to python, but not programming and embedded. I am
having an issue which I believe is related to the hardware, triggered
by the software read I am doing in pySerial. I...
|
by: terry |
last post by:
Hi,
I am trying to send a character to '/dev/ttyS0' and expect the same
character and upon receipt I want to send another character. I tired
with Pyserial but in vain.
Test Set up:
1. Send...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |