📄 testzm.cpp
字号:
// ********************* START OF TESTZM.CPP *********************
//
// This is the test program for the Zmodem file transfer class.
// It is a simple terminal emulator that has a menu accessed via
// the Escape key. The Send function just sends a couple of
// predefined files. The Receive function will accept whatever
// the remote end sends.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "rs232.h"
#include "pc8250.h"
#include "zmodem.h"
#include "ascii.h"
int main()
{
int c;
char *files[] = { "TESTZM.EXE", "ZMODEM.H", 0 };
PC8250 port( COM1, 38400L, 'N', 8, 1 );
Zmodem *zmodem;
port.XonXoffHandshaking( 1 );
zmodem = new Zmodem( &port );
setbuf( stdout, 0 );
for ( ; ; ) {
if ( kbhit() ) {
c = getch();
if ( c == 27 ) {
printf( "\n(Escape Receive Send) Command: " );
c = getch();
printf( "\n" );
switch( toupper( c ) ) {
case 'R' :
printf( "Starting to receive...\n" );
zmodem->Receive( 0 );
printf( "\nReceive complete\n" );
break;
case 'S' :
printf( "Starting to send...\n" );
zmodem->Send( files );
printf( "\nSend complete\n" );
break;
}
if ( c == 27 || toupper( c ) == 'E' )
break;
} else
port.Write( c );
}
c = port.Read();
if ( c == CAN ) {
char buf[ 21 ];
port.Read( buf, 20, 500 );
if ( strnicmp( buf, "B00000000000000\r\n", 17 ) == 0 )
zmodem->Receive( 0 );
else {
putc( CAN, stdout );
for ( int i = 0 ; buf[ i ] ; i++ )
putc( buf[ i ], stdout );
}
} else if ( c > 0 )
putc( c, stdout );
}
return 0;
}
// ********************** END OF TESTZM.CPP **********************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -