Menu

SPCOMM for MFC v2(vc++) serial port class

Ported from Delphi version supports the MFC class,file only two
Spcomm.h
Spcomm.cpp

SPCOMM is Delphi famous serial software, the use of multi-threaded message method to write. Online examples of many.

This version's SPCOMM based on the following features
1. Increase support COM10 serial
2. Increase IsOpen () function returns true is already open
3. Append additional properties tab int Tag; and void * pTag,; facilitate the dynamic establishment of multi-serial
4. Additional InBufferSize attributes, you can set the input buffer size, maximum 2048 (it can be changed to achieve greater).

include "Spcomm.h"

TComm Serial;
char rev[100];
void CALLBACK ReceiveData(void
obj,void *Buffer, WORD BufferLength)
{
memcpy_s(rev,100,Buffer,BufferLength)
}

void SPCommDlg::OnBnClickedButton1()
{
Serial = new TComm(this);
Serial->CommName = L"COM3";
Serial->BaudRate = 9600;
Serial->ByteSize = TComm::_8;
Serial->Parity = TComm::None;
Serial->StopBits = TComm::_1;
Serial->OnReceiveData = ReceiveData;
Serial->ReadIntervalTimeout = 50;
Serial->StartComm();
}

void SPCommDlg::OnBnClickedButton2()
{
char bb[8];
bb[0]= 0x02;
bb[1]= 'E';
bb[2]= '0';
bb[3]= '0';
bb[4]= '4';
bb[5]= '0';
bb[6]= '0';
bb[7]= '0';
Serial->WriteCommData(bb,8);
}

Posted by b1ackn3k0 2013-01-01

Log in to post a comment.