修改RS232通信
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
#define MAX_OUTPUT_BUFFER_SIZE 2048
|
||||
#define MAX_RECIEVE_BUFFER_SIZE 30000
|
||||
|
||||
// TCP, serial style routines
|
||||
struct SerialList
|
||||
{
|
||||
|
||||
@@ -222,6 +222,9 @@ int CPSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int Ha
|
||||
Bits = m_Bits;
|
||||
if(StopBits == 0)
|
||||
StopBits = m_StopBits;
|
||||
if (HandShake==0)
|
||||
HandShake=m_HandShake;
|
||||
|
||||
|
||||
// If the values are ok then store them
|
||||
if( ProgramPort( Port, Baud, Parity, Bits, StopBits, HandShake ) )
|
||||
@@ -481,21 +484,16 @@ void CPSerial::OnReceive()
|
||||
{
|
||||
// Dummy OnReceieve if not used
|
||||
char s[MAX_RECIEVE_BUFFER_SIZE]={0};
|
||||
|
||||
s[1]='\0';
|
||||
CurrentPointer = 0;
|
||||
int num=0;
|
||||
num = ReadPort(s, MAX_RECIEVE_BUFFER_SIZE);
|
||||
|
||||
if (num>0)
|
||||
int num = ReadPort(s, MAX_RECIEVE_BUFFER_SIZE);
|
||||
if ((num>0) && (num<MAX_RECIEVE_BUFFER_SIZE))
|
||||
{
|
||||
memset(m_RecvData,0,MAX_RECIEVE_BUFFER_SIZE);
|
||||
memcpy(m_RecvData,s, num);
|
||||
m_iRecvBytes=num;
|
||||
|
||||
m_iRecvState=TRUE;
|
||||
m_iRecvBytes=num;
|
||||
m_iRecvState=TRUE;
|
||||
}
|
||||
|
||||
//LineReceive(s, num);
|
||||
}
|
||||
|
||||
@@ -629,14 +627,18 @@ int CPSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,in
|
||||
SerialDCB.fDtrControl = DTR_CONTROL_ENABLE;
|
||||
break;
|
||||
case CS_HANDSHAKE_FOR_SO7:
|
||||
SerialDCB.XonChar = 17;
|
||||
SerialDCB.XoffChar = 19;
|
||||
SerialDCB.fRtsControl = RTS_CONTROL_DISABLE;
|
||||
SerialDCB.fDtrControl = DTR_CONTROL_DISABLE;
|
||||
SerialDCB.fDsrSensitivity=FALSE;
|
||||
SerialDCB.XonLim=512;
|
||||
SerialDCB.XoffLim=1;
|
||||
break;
|
||||
SerialDCB.fDsrSensitivity=FALSE;
|
||||
SerialDCB.XonChar = 17;
|
||||
SerialDCB.XoffChar = 19;
|
||||
SerialDCB.fOutX=FALSE;
|
||||
SerialDCB.fInX=FALSE;
|
||||
SerialDCB.fErrorChar=FALSE;
|
||||
SerialDCB.fRtsControl=RTS_CONTROL_ENABLE;
|
||||
SerialDCB.fDtrControl = DTR_CONTROL_ENABLE;
|
||||
SerialDCB.fOutxCtsFlow=FALSE;
|
||||
SerialDCB.fOutxDsrFlow=FALSE;
|
||||
SerialDCB.XonLim=2048;
|
||||
SerialDCB.XoffLim=512;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -689,13 +691,18 @@ int CPSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,in
|
||||
SerialDCB.fDtrControl = DTR_CONTROL_ENABLE;
|
||||
break;
|
||||
case CS_HANDSHAKE_FOR_SO7:
|
||||
SerialDCB.XonChar = 17;
|
||||
SerialDCB.XoffChar = 19;
|
||||
SerialDCB.fRtsControl = RTS_CONTROL_DISABLE;
|
||||
SerialDCB.fDtrControl = DTR_CONTROL_DISABLE;
|
||||
SerialDCB.fDsrSensitivity=FALSE;
|
||||
SerialDCB.XonLim=512;
|
||||
SerialDCB.XoffLim=1;
|
||||
SerialDCB.fDsrSensitivity=FALSE;
|
||||
SerialDCB.XonChar = 17;
|
||||
SerialDCB.XoffChar = 19;
|
||||
SerialDCB.fOutX=FALSE;
|
||||
SerialDCB.fInX=FALSE;
|
||||
SerialDCB.fErrorChar=FALSE;
|
||||
SerialDCB.fRtsControl=RTS_CONTROL_ENABLE;
|
||||
SerialDCB.fDtrControl = DTR_CONTROL_ENABLE;
|
||||
SerialDCB.fOutxCtsFlow=FALSE;
|
||||
SerialDCB.fOutxDsrFlow=FALSE;
|
||||
SerialDCB.XonLim=2048;
|
||||
SerialDCB.XoffLim=512;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user