-
serial port read
Hi,
I have not been able to find an answer, but I am sure it is here some where. I have tried http://www.iftools.com/ctb.en.html and http://www.codeproject.com/system/serial.asp plus I have read every thing else that I could find.
I am running WIN98 using wx-devcpp. I can not even get the above code samples to compile. Found the above links at the wx-devcpp discussion board.
Problem: I have a pic chip sending data to the pc via serial port, this works as I can recieve with hyper-terminal. How do I set up a C++ program to recieve this data ?? I would like to have the data display into a text box so it can be saved to a database.
Thank you.
-
check msdn:
http://msdn.microsoft.com/library/de...nfunctions.asp
it has all the functions
Use createFile to get a handle to the serial port and then treat it like a file with read and write.
Amish
-
Thank you, now it looks like I am getting somewhere. If I can figure out what
"544 C:\DEV-CPP\include\Winbase.h `DWORD' does not name a type " means. :confused:
-
I think it comes from windows.h. Try to include that. Not too sure though
Amish
-
Changed <Winbase.h> to <windows.h> and now this will compile---
Code:
#include <windows.h>
#include <stdio.h>
HANDLE pic;
main()
{
pic = CreateFile( "COM1", // address of name of the communications device
GENERIC_READ | GENERIC_WRITE, // access (read-write) mode
0, // share mode
NULL, // address of security descriptor
OPEN_EXISTING, // how to create
0, // file attributes
NULL // handle of file with attributes to copy
);
}
Have not had time to try in full program yet, but now I have a starting point.
Thank you for your help!!!
-
Don't forget that when you call ReadFile on a serial port to always check the number of bytes that were actually read as this can be less then the number requested.
-
I am taking notes.
Thank you