I'm trying to create a little app using MFC to allow strings to be sent and recieved via the serial port. I've got something basic working and am able to test using another PC running hyperterminal.
What I've got so far uses createfile() to give a handle, setupcomm() to fill a DCB struct and then i use writefile() and readfile() to send and recieve strings; for reading I have a button on my dialog which causes readfile to execute, and I update an edit box with the contents of the buffer. OK.
Now, what I really want is for incoming characters to trigger an event which automatically causes the edit box to update with the new character (like hyperterminal does.)
I've got an event mask that looks for EV_RXCHAR and all but can't get this to work.
Also, I think I need to get a file handle with CreateFile() using the FILE_FLAG_OVERLAPPED option to allow this event driven code to work (asynchronous i/o). This type of file handle worked under WIN ME, but I just get an invalid file handle error from Writefile() according to GetLastError() when I execute under WIN NT. Any one know why this is? On both platforms VC++ compiles without errors or warnings. I presume this is to do with differences in underlying implementations of file handling between WIN ME and NT. Thing is, I need my program to work on both platforms.
Any help would be greatly appreciated. Feel free to have a look at my website if you would like to know more about the bigger picture of what I'm trying to do. www.personal.leeds.ac.uk/~een9sdh/