ReadFile() returns false

L

Luk Vloemans

Hey,

I'm a student working on a project to get data from a GPS onto a PDA.

This is the function I use to get data from the device:

if (ReadFile(m_ihandle, buf, 1, gotbytes, uOverlapped))
{
throw new CommPortException("Can not read from port " + cs.port);
}

The function seems to work, as the buffer always gets a new (sadly,
garbage) value. However, the gotbytes (int) remains 0, which means the
device didn't read any character at all.

Does anybody know why the ReadFile function doesn't work properly ?

Thank in advance,

Luk Vloemans
 
J

Jon Skeet

Luk Vloemans said:
I'm a student working on a project to get data from a GPS onto a PDA.

This is the function I use to get data from the device:

Which class are you using? Which language?
 
L

Luk Vloemans

Hey,

I'm using the class COMReader in C#.

Hope this sounds familiar ?

-Luk
 
J

Jon Skeet

Luk Vloemans said:
I'm using the class COMReader in C#.

Hope this sounds familiar ?

Not at all, I'm afraid - but from the looks of how you were calling
ReadFile, I'm not surprised that the value of gotBytes doesn't change -
it's passed by value.

Do you have any documentation for it? A very quick Google search didn't
find it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top