COM Port data transfer
-
I need to write a function to copy data from COM Port 3 (COM3) to COM Port 1 (COM1). Then, I need to write a function to copy data from COM Port 1 (COM1) to COM Port 3 (COM3). Any help at all is welcome!!!!!
Me, wrong!?! Nah, you just need to change your thinking to make me right.
-
I need to write a function to copy data from COM Port 3 (COM3) to COM Port 1 (COM1). Then, I need to write a function to copy data from COM Port 1 (COM1) to COM Port 3 (COM3). Any help at all is welcome!!!!!
Me, wrong!?! Nah, you just need to change your thinking to make me right.
You can open a com port as a file under Win32. With minor restrictions, you can specify Read or Write attributes when opening such files to read from or write to. You can even try opening the ports as CFile using MFC. There is an example on Microsoft's site showing how to do this, including creating CArchive objects based on these files. After they are open, you can use standard file read and write routines or the << and >> operators. Look at MSDN. Here is a link to start you off. This goes through the theory, anyway, plus it is non-mfc. Can't recall the MFC link, but you can look at the VCTERM sample for specs on using the Communication control as well.. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn\_serial.asp My personal experience: Do not try to do the copy in the same thread. Gets very messy. I spun off threads to read and write to and from the files. That worked well, except you now need synchronization between the threads. Good Luck!:)