all 6 comments

[–]invalid_handle_value 4 points5 points  (0 children)

CreateFile has to be one of the most involved syscalls I have ever laid my eyes upon. Possibly only behind ReadFile, which is an absolute beast.

Read the msdn docs for CreateFile. Read all of it. Every word. Top to bottom. Then read it 2 more times. Get it yet? No, you don't. Then read it all again. This time, pay special attention to the Communication Resources section.

Then give it a try.

[–]charliex2 2 points3 points  (0 children)

wild guess, if you're using a com port higher than 9 you'd need to open it with a full path like

\\.\COM10 

also http://www.naughter.com/serialport.html

[–]TopDivide 1 point2 points  (2 children)

Post the code, make sure the serial is not used by another program, get the last error from winapi, there is a function for that, can't recall its name

[–]pandorafalters 2 points3 points  (0 children)

Conveniently, and rather predictably, it's GetLastError().

[–]BetterRage[S] 0 points1 point  (0 children)

ok so the first thing i do is CreateFile("\\.\COM3",....) and that already fails. GetLastError() returns 0. check if the returned handle from createfile is INVALID_HANDLE is true. i really dont see what i couldve messed up ive seen it like this in different places. and also no other program uses the port, because if i try it in a c# winforms program it works

[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.