a
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
// Zmodem.h: interface for the Zmodem class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_ZMODEM_H__3186313F_3A85_4CE4_B80D_D2C026ADF36E__INCLUDED_)
|
||||
#define AFX_ZMODEM_H__3186313F_3A85_4CE4_B80D_D2C026ADF36E__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "FileTransfer.h"
|
||||
|
||||
#define ZMAXHLEN 16 // Max header information length
|
||||
#define ZATTNLEN 32 // Max length of attention string
|
||||
|
||||
class Settings
|
||||
{
|
||||
public :
|
||||
long BaudRate;
|
||||
char Parity;
|
||||
int WordLength;
|
||||
int StopBits;
|
||||
int Dtr;
|
||||
int Rts;
|
||||
int XonXoff;
|
||||
int RtsCts;
|
||||
int DtrDsr;
|
||||
};
|
||||
|
||||
class Zmodem : public FileTransfer
|
||||
{
|
||||
private :
|
||||
unsigned long m_FileSize; //待 接收/发送 的文件大小
|
||||
int m_ByteTransfer; //已经 接收/发送 了多少KB
|
||||
|
||||
void SendCharToComm();
|
||||
int GetFileSize(char *buffer);
|
||||
int WakeUpSender( void );
|
||||
int ReceiveFiles( CString Path );
|
||||
int ReceiveSingleFile( CString Path );
|
||||
void SendHexHeader( int len, int type, char *hdr );
|
||||
void SendBinaryHeader( int length, int type, char * header );
|
||||
int ReadHeader( char *header );
|
||||
int ReadDataFrame( char *buf, int length );
|
||||
int ReadDataFrameCRC32( char *buf, int length );
|
||||
int ReadDataFrameCRC16( char *buf, int length );
|
||||
void SendAttentionString( void );
|
||||
void AckZFIN( void );
|
||||
int OpenInputFile( CString Path, char *data );
|
||||
void PackLongIntoHeader( long header_data );
|
||||
long UnpackHeaderIntoLong( char *header );
|
||||
void SendHexEncodedChar( int c );
|
||||
void SendEncodedChar( int c , bool b = FALSE);
|
||||
|
||||
void ReadSettings( Settings © );
|
||||
int TXSpaceUsed( void );
|
||||
|
||||
void SendChar( int c , bool b = FALSE)
|
||||
{
|
||||
/*用新函数封装
|
||||
char cWriteChar;
|
||||
cWriteChar = (c & 0377);
|
||||
port->ZmodemSendDataDirectly(&cWriteChar,1);
|
||||
*/
|
||||
|
||||
m_WriteBuff[m_WriteBuffLength] = (char)(c & 0377);
|
||||
m_WriteBuffLength++;
|
||||
}
|
||||
|
||||
void ClearReadBuf();
|
||||
|
||||
|
||||
void PrintLog(char *chPrtlog, int nLogLen);
|
||||
void PrintLogLast(CString& strLog);
|
||||
|
||||
void SendZFIN( void );
|
||||
int ReadHexHeaderCRC16( char *header );
|
||||
int ReadBinaryHeaderCRC16( char *header );
|
||||
int ReadBinaryHeaderCRC32( char *header );
|
||||
int ReadEncodedByte( void );
|
||||
int ReadUnencodedByte( void );
|
||||
int ReadHexByte( void );
|
||||
int ReadChar( long timeout );
|
||||
int GetRinitHeader( void );
|
||||
int SendSingleFile( char *name );
|
||||
int SendFileContents( void );
|
||||
void SendDataFrame( char *buffer, int length, int frameend );
|
||||
int SyncWithReceiver( int flag );
|
||||
long ReadTime( void );
|
||||
|
||||
//-----------------------------------------------------
|
||||
int ReadBuff(long timeout);
|
||||
int m_BuffCount;
|
||||
//---------------------------
|
||||
|
||||
//log-----------------------------
|
||||
FILE *zmodemLog;
|
||||
DWORD dwBegin;
|
||||
char cReadLog[2048];
|
||||
int nLogLength;
|
||||
char cReadType[2];
|
||||
int nIndex;//记录某个包发了多少次
|
||||
//log---------------------------
|
||||
|
||||
//--写串口缓冲区
|
||||
char m_WriteBuff[8192];
|
||||
int m_WriteBuffLength;
|
||||
int m_nBufReadIndex;
|
||||
//
|
||||
|
||||
int receiver_wants_crc32;
|
||||
int current_frame_uses_crc32;
|
||||
long received_file_position;
|
||||
long transmitted_file_position;
|
||||
long last_sync_position;
|
||||
long last_reported_position;
|
||||
unsigned int receiver_buffer_length;
|
||||
int file_at_eof;
|
||||
int wake_up_sender_header_type;
|
||||
int Rxcount;
|
||||
char received_header[ ZMAXHLEN ];
|
||||
char transmitted_header[ ZMAXHLEN ];
|
||||
char attention_string[ ZATTNLEN + 1 ];
|
||||
int last_char_sent;
|
||||
|
||||
char buff[BUFFSIZE];
|
||||
// char *str;
|
||||
|
||||
public :
|
||||
int GetTransferPosit();
|
||||
int GetFileSize();
|
||||
Zmodem( CSComPort *rs232_port );
|
||||
~Zmodem();
|
||||
BOOL Send( char *files[] );
|
||||
BOOL Receive( CString Path );
|
||||
BOOL SendCancelString();
|
||||
// int nTestID;
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_ZMODEM_H__3186313F_3A85_4CE4_B80D_D2C026ADF36E__INCLUDED_)
|
||||
Reference in New Issue
Block a user