开发者

serial communication in visual studio using windows.h

I m new to the v开发者_StackOverflow中文版isual studio I want to trnsfer and receive some data from LPC2148 kit for thisI want to do the serial communication in Visual studio.

I have used dos.h in turboC Bios.h is also used for the same purpose but those are for Turbo.C compiler

In visual studio I have found a header files Windows in api are writen but I don't know how to use it please help


There are many articles in CodeProject with libraries for handling Serial Communication. You can start from here and here.

May I also suggest that it will be easier to use C# for this task. You will be able to build the GUI faster and a serial port control is already provided (no need to fight with the API or find a library).


Serial comms in Win32 is not particularly well catered for, the API is somewhat cumbersome to use but is dealt with fairly comprehensively in this article on MSDN.

The .Net 2.0 (and later) Framework includes an excellent and easy to use serial communications class that makes the whole process much simpler, but you'll need to use C++/CLI or C# or some other .NET language to access that.

For very simple serial I/O you can always use stdio and simply open the COM*n* device where n is the port number you wish to open. Stdio provides no means to set baud rate and framing etc., but this can easily be achieved by invoking the mode command via a system call. It is crude and lacks the flexibility of the API level interface, but may be adequate for your needs for a quick-and-dirty solution. For example:

system( "MODE COM1: BAUD=115200 PARITY=n DATA=8 STOP=1" ) ;
FILE port = fopen( "COM1:", "wb" ) ;
fprintf( port, "hello, world!\n" ) ;
fclose( port ) ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜