读写串口的函数,我用过,没有问题
程序初始化时,使用OpenComm打开串口,退出时使用CloseComm关闭
comm.h文件
// Comm.h: interface for the CComm class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(COMM_H__)
#define COMM_H__
BOOL OpenComm(const char* pPort, int nBaudRate=57600, int nParity=NOPARITY, int nByteSize=8, int nStopBits=ONESTOPBIT);
BOOL CloseComm();
void WriteComm(void* pData, int nLength);
int ReadComm(void* pData, int nLength);