July 15th, 2003, 12:50 PM
RS232C datatransfer software samples in C++
Hallo, am reprogramming a cnc machine formerly programmed in Pascal, i would like to get some samples of data transfer software in Visual c++, C++, or C, or anyother software that i can use for RS232C serial interface. I would like to also get some advice how to about the whole procedural programming.
July 15th, 2003, 02:19 PM
Serial I/O is very system-dependent and can be very involved. And, needless to say, not at all portable.
From your reference to Visual C++, I assume that you are doing this on a Win32 platform (Win9x, WinME, Win2k, or WinXP), which is very fortunate, because it's much easier to do.
Basically, in the Win32 API, the comm port is treated as a file, so you end up reading from and writing to that file. You load the device control block (DCB) and the timeouts struct (COMMTIMEOUTS), do a CreateFile, and set up the comm settings. Then you do ReadFile and WriteFile calls.
Do a Google search on the keywords: SetupComm ReadFile WriteFile . With those hits, you will find lots of information and examples.
July 15th, 2003, 04:50 PM
If you are indeed on a Windows platform, and your project can host ActiveX, there is also an object that makes serial programming rediculously easy. I think it's called MSCOMM, but I can't remember. Most of the documentation is written for VisualBasic, but since everything is exposed through COM, it all applies to C++ as well.