增加手动机测试

This commit is contained in:
TAO Cheng
2013-06-13 17:13:05 +08:00
parent 82cde2138f
commit 6f04c5fda4
17 changed files with 471 additions and 204 deletions
@@ -21,7 +21,7 @@ static char Codes[][6] =
*/
/////////////////////////////////////////////////////////////////////////////
// CSerial() : Constructor
// CPSerial() : Constructor
/////////////////////////////////////////////////////////////////////////////
// CSerialTask() : Function to run ReceiveTask() method as a task
@@ -31,7 +31,7 @@ unsigned int WINAPI CSerialTask(LPVOID CSerialPtr)
{
TRACE( TEXT("Serial task has started \n") );
// Call the ControlTask function in the specified plugin
((CSerial *)CSerialPtr)->ReceiveTask();
((CPSerial *)CSerialPtr)->ReceiveTask();
TRACE( TEXT("Serial task has completed \n") );
@@ -40,7 +40,7 @@ unsigned int WINAPI CSerialTask(LPVOID CSerialPtr)
return(0);
}
CSerial::CSerial()
CPSerial::CPSerial()
{
// Serial port is not open
m_PortHandle = INVALID_HANDLE_VALUE;
@@ -93,9 +93,9 @@ CSerial::CSerial()
/////////////////////////////////////////////////////////////////////////////
// ~CSerial() : Destructor - Close the port and free up the CriticalSection
// ~CPSerial() : Destructor - Close the port and free up the CriticalSection
CSerial::~CSerial()
CPSerial::~CPSerial()
{
if( IsOpen( ) )
{
@@ -122,7 +122,7 @@ CSerial::~CSerial()
// OpenPort() : Opens the serial port using the parameters set by default
// or a call to SetPort
DWORD CSerial::Open()
DWORD CPSerial::Open()
{
CString PortName;
COMMTIMEOUTS CommTimeOut;
@@ -201,7 +201,7 @@ DWORD CSerial::Open()
// IsOpen() : returns true if the serial port is open
//
int CSerial::IsOpen( )
int CPSerial::IsOpen( )
{
return( m_PortHandle != INVALID_HANDLE_VALUE );
}
@@ -211,7 +211,7 @@ int CSerial::IsOpen( )
// SetPort() : Store the serial settings. If the port is open then these
// settings are applied now
int CSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
int CPSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
{
// Use the current settings if the value has the default of 0
m_Port = Port;
@@ -243,7 +243,7 @@ int CSerial::SetPort(int Port,int Baud,char Parity,int Bits,int StopBits,int Han
// GetPortData() : return the current settings
//
void CSerial::GetPortData(int *Port,int *Baud,char *Parity,int *Bits,int *StopBits,int *HandShake)
void CPSerial::GetPortData(int *Port,int *Baud,char *Parity,int *Bits,int *StopBits,int *HandShake)
{
// return the requested settings
if( Port )
@@ -265,7 +265,7 @@ void CSerial::GetPortData(int *Port,int *Baud,char *Parity,int *Bits,int *StopBi
// ClosePort() : Close the port and shut down the monitoring thread
//
DWORD CSerial::Close()
DWORD CPSerial::Close()
{
//struct SerialList *Free;
HANDLE Port;
@@ -319,13 +319,13 @@ DWORD CSerial::Close()
// Send functions // [8/11/2004]
//
DWORD CSerial::Send(LPCSTR buffer, int l, BOOL /*needsResponse=FALSE*/)
DWORD CPSerial::Send(LPCSTR buffer, int l, BOOL /*needsResponse=FALSE*/)
{
return ( WritePort ((const char*) buffer, (DWORD) l));
}
/*
DWORD CSerial::Send(CString buffer)
DWORD CPSerial::Send(CString buffer)
{
char LocBuffer[MAX_OUTPUT_BUFFER_SIZE];
int length = buffer.GetLength ();
@@ -347,7 +347,7 @@ return res;
// WritePort() : Writes the specifed bytes to the serial port
//
DWORD CSerial::WritePort(const char *Buffer,DWORD Bytes)
DWORD CPSerial::WritePort(const char *Buffer,DWORD Bytes)
{
DWORD BytesWritten, TotalWritten, Error;
BOOL WriteState;
@@ -413,7 +413,7 @@ DWORD CSerial::WritePort(const char *Buffer,DWORD Bytes)
// ReceiveTask() : Internal function, this runs as a thread and provides the
// OnRecieve and OnTransmit events
void CSerial::ReceiveTask( void )
void CPSerial::ReceiveTask( void )
{
//DWORD BytesWritten;
DWORD Events;
@@ -478,7 +478,7 @@ void CSerial::ReceiveTask( void )
// OnReceive() : Default OnReceive()
// V114
void CSerial::OnReceive()
void CPSerial::OnReceive()
{
// Dummy OnReceieve if not used
char s[255]={0};
@@ -510,7 +510,7 @@ void CSerial::OnReceive()
// ReadPort() : Read the specifed number of bytes.
//
DWORD CSerial::ReadPort(char *Buffer,DWORD Bytes)
DWORD CPSerial::ReadPort(char *Buffer,DWORD Bytes)
{
DWORD BytesRead,Error;
BOOL ReadState;
@@ -564,7 +564,7 @@ DWORD CSerial::ReadPort(char *Buffer,DWORD Bytes)
// ReadPort() : Read the specifed number of bytes into a CString class.
//
#if 0
DWORD CSerial::ReadPort(CString &Buffer,DWORD Bytes)
DWORD CPSerial::ReadPort(CString &Buffer,DWORD Bytes)
{
DWORD BytesRead;
@@ -581,7 +581,7 @@ DWORD CSerial::ReadPort(CString &Buffer,DWORD Bytes)
// ProgramPort() : Internal function to setup the serial port
//
int CSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
int CPSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,int HandShake)
{
CString Param,Params;
DCB SerialDCB;
@@ -728,7 +728,7 @@ int CSerial::ProgramPort(int Port,int Baud,char Parity,int Bits,int StopBits,int
// OnTransmit() : Default OnTransmit()
//
void CSerial::OnTransmit(int /*Item*/, DWORD /*Error*/)
void CPSerial::OnTransmit(int /*Item*/, DWORD /*Error*/)
{
// Dummy OnTransmit if not used
}
@@ -738,7 +738,7 @@ void CSerial::OnTransmit(int /*Item*/, DWORD /*Error*/)
// SetTimeouts() : Sets the rx and tx timeouts
//
void CSerial::SetTimeouts( int RXTimeout, int TXTimeout )
void CPSerial::SetTimeouts( int RXTimeout, int TXTimeout )
{
COMMTIMEOUTS CommTimeOut;
@@ -764,7 +764,7 @@ void CSerial::SetTimeouts( int RXTimeout, int TXTimeout )
// AddToDebug() : Add the data to the debug output. State is 1 = rx 2 = tx
// 3 = user
void CSerial::AddToDebug( const char * /*Ptr*/, DWORD /*BytesToCopy*/, int /*State*/ )
void CPSerial::AddToDebug( const char * /*Ptr*/, DWORD /*BytesToCopy*/, int /*State*/ )
{
//ZH
#if 0
@@ -831,7 +831,7 @@ void CSerial::AddToDebug( const char * /*Ptr*/, DWORD /*BytesToCopy*/, int /*Sta
// FlushPort() : Removes all characters in the serial buffer
//
/*
int CSerial::FlushPort(void)
int CPSerial::FlushPort(void)
{
int TXTimeout,RXTimeout;
char FlushBuffer[256];
@@ -879,7 +879,7 @@ return(BytesTotal);
// MaxPort() :
//
int CSerial::MaxPort()
int CPSerial::MaxPort()
{
// return the max port, :-)
return(8);
@@ -892,7 +892,7 @@ int CSerial::MaxPort()
// data sent.
//
int CSerial::Transmit(const char * /*Buffer*/,DWORD /*Bytes*/)
int CPSerial::Transmit(const char * /*Buffer*/,DWORD /*Bytes*/)
{
/*
struct SerialList *Ptr;
@@ -952,7 +952,7 @@ int CSerial::Transmit(const char * /*Buffer*/,DWORD /*Bytes*/)
//
/*
int CSerial::AddReceived( const char *Buffer,DWORD Bytes)
int CPSerial::AddReceived( const char *Buffer,DWORD Bytes)
{
DWORD index = 0; //primary buffer index
struct SerialList *Ptr;
@@ -1081,7 +1081,7 @@ return(TRUE);
//
//ZH
/*
char *CSerial::GetNextReceived(void)
char *CPSerial::GetNextReceived(void)
{
struct SerialList *Free;
@@ -1120,7 +1120,7 @@ return( m_RXTempPtr );
// ascii hex
//
int CSerial::HexToInt(char *Data, int Bytes)
int CPSerial::HexToInt(char *Data, int Bytes)
{
int Byte;
int HexChar, Value;
@@ -1150,7 +1150,7 @@ int CSerial::HexToInt(char *Data, int Bytes)
//
//ZH
/*
void CSerial::RegisterDebugWindow()
void CPSerial::RegisterDebugWindow()
{
// Register the CSerialRaw window for future use
WNDCLASS wndcls;
@@ -1160,7 +1160,7 @@ wndcls.hInstance = AfxGetInstanceHandle( );
wndcls.hCursor = LoadCursor( NULL, IDC_ARROW );
wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpszClassName = TEXT("CSerial");
wndcls.lpszClassName = TEXT("CPSerial");
AfxRegisterClass( &wndcls );
}
*/
@@ -1172,7 +1172,7 @@ AfxRegisterClass( &wndcls );
// SendBuffer() : Internal function, this writes the next block of data
// queued to the serial port.
void CSerial::SendBuffer(int Next)
void CPSerial::SendBuffer(int Next)
{
struct SerialList *Free;
// DWORD BytesWritten;