Source code for Serial communication in VC++

B
> I am looking for sample Source code for Serial communication in VC++ for project purposes. Can somebody help me. If anyone has the source code for the same pl mail me at- [email protected]

regards
shrinivas.
 
sir,
i am working on a project to establish the communication using VC++ Sockets. if u have any such project pls do forward to me.. that would be of great help for me.

with regards,
mohan
 
F

Francisco Mendes

Have you solve your problem?? Do you found a working solution?
I need a simple solution to communicate by rs232 using a Win plattform, but I could't put a program to work. If you found a solution i would be very match obliged if you send me.

Thanks
Francisco Mendes
[email protected]
 
C

Chris Harding

Dear Mr Anand can u send me the source code about the serial comm in C. I also have Borlands C++ so if the VC++ code will work here also I would be very pleased to have a copy.
Kind regards, Chris
[email protected]
 
Hello, my name is Latrecia. I am trying to figure out how to use the setcommask(), createfile(), readfile(), writefile(), and closefile() function. I need to open my rs232(serial port) and output it's contents(info) onto a screen using VC++. I desperately need some assitance if you can help me. Please email me back at [email protected]. Thank you so very much.
 
Use of serial ports is basically orientated around configuring the serial ports for the right behaviour, and this varies with the platform more than the C language, the basic techniques are the same whatever variant you are using.

Also, platforms are **similiar**. Reading and writing to a serial port is like reading and writing from a sequential file, however, in order to modify parameters you will need to access a data structure where factors such as baud rate and handshaking characteristics are defined.

As there are a lot of parameters, many of which will not be of interest to you, the normal way is to 'create' a file, get a default data structure, and then modify the parameters that are of interest to you before opening it.

The actual details of the parameters is the platform dependent bit, as it depends on facilities offered, for example the data structure is capable of accepting values that cannot be implemented by the underlying UART, whilst the platform itself may offer more or less built in control features.

For example, just about all platforms will offer rudimentry RTS/CTS or XON/XOFF handshaking, but may offer different degrees of control over timeouts etc. Some features, such as the extensive canonical mode controls offered on 'nix platforms, simply do not exist on others.

In the case of the windows API, the data structure in question, DCB, should be documented in the online help, more extensive coverage will be found in the MSDN.

I have some example files that show some low level routines using the Windows API to control a serial port that is talking to an Omron C200. This code was run under C++ builder but the API calls will be the same under VC++, the library derives from the Windows SDK. (Contact me for a copy of these files, at <[email protected]>)

Note that these facilities are not adequate to implement many of the protocols used in industrial communications. To do that you will need code that is able to respond directly to the UART. On W9x this can be achieved by direct access to the hardware, but this is a messy non portable way of doing things.

The correct way is a device driver, but this will be different for each version of windows, and is by no means easy under NT and W2K.

If your study purpose is learning the implementation of the low end of serial interfacing protocols, may I suggest you use DOS (do what the hell you like with no interference from the OS), or you try Linux, were writing device drivers (or installable kernel modules) is much simpler. Also, you may study and/or extended the existing source code for the serial port.
 
Top