开发者

how to transfer a binary file through serial port in vc++

开发者 https://www.devze.com 2023-01-19 11:53 出处:网络
Hi i have to read a binary file from the disk and i have to transfer the file o开发者_StackOverflow社区ver serial port, i am using mscomm in vc++ 6.0 .

Hi i have to read a binary file from the disk and i have to transfer the file o开发者_StackOverflow社区ver serial port, i am using mscomm in vc++ 6.0 .

how to transfer a binary file through serial port.

Thanks in advance.


There is a comprehensive library on CodeProject - 'Serial library for C++'.

Here is a sample use case from that.

CSerial serial;

// Attempt to open the serial port (COM1)
serial.Open(_T("COM1"));

// Setup the serial port (9600,N81) using hardware handshaking
serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
serial.SetupHandshaking(CSerial::EHandshakeHardware);

// The serial port is now ready and we can send/receive data. If
// the following call blocks, then the other side doesn't support
// hardware handshaking.
serial.Write("Hello world");

// Close the port again
serial.Close();

It includes both asynchronous and synchronous implementations.

0

精彩评论

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