C:\Perl_PPM\Device-Modem-1.57\blib/lib/Device/Modem/Protocol/Xmodem.pm |
Device::Modem::Protocol::Xmodem
Class that represents a single Xmodem data block.
my $b = Xmodem::Block->new( 1, 'My Data...<until-128-chars>...' ); if( defined $b ) { # Ok, block instanced, verify its checksum if( $b->verify( 'checksum', <my_chksum> ) ) { ... } else { ... } } else { # No block }
# Calculate checksum, crc16, 32, ... $crc16 = $b->crc16(); $crc32 = $b->crc32(); $chksm = $b->checksum();
Class that implements an Xmodem receive buffer of data blocks. Every block of data
is represented by a Xmodem::Block
object.
Blocks can be pushed and popped from the buffer. You can retrieve the last block, or the list of blocks from buffer.
my $buf = Xmodem::Buffer->new(); my $b1 = Xmodem::Block->new(1, 'Data...');
$buf->push($b1);
my $b2 = Xmodem::Block->new(2, 'More data...'); $buf->push($b2);
my $last_block = $buf->last();
print 'now I have ', scalar($buf->blocks()), ' in the buffer';
# TODO document replace() function ???
Package that contains all useful Xmodem protocol constants used in handshaking and data blocks encoding procedures
Xmodem::Constants::soh ........... 'start of header' Xmodem::Constants::eot ........... 'end of trasmission' Xmodem::Constants::ack ........... 'acknowlegded' Xmodem::Constants::nak ........... 'not acknowledged' Xmodem::Constants::can ........... 'cancel' Xmodem::Constants::C ........... `C' ASCII char
Xmodem::Constants::XMODEM ........ basic xmodem protocol Xmodem::Constants::XMODEM_1K ..... xmodem protocol with 1k blocks Xmodem::Constants::XMODEM_CRC .... xmodem protocol with CRC checks
Xmodem::Constants::CHECKSUM ...... type of block checksum Xmodem::Constants::CRC16 ......... type of block crc16 Xmodem::Constants::CRC32 ......... type of block crc32 =head1 Xmodem::Receiver
Control class to initiate and complete a X-modem
file transfer in receive mode
my $recv = Xmodem::Receiver->new( modem => {Device::Modem object}, filename => 'name of file', XXX protocol => 'xmodem' | 'xmodem-crc', | 'xmodem-1k' );
$recv->run();
abort_transfer()
can
), that signals to sender that transfer is aborted. This is
issued if we receive a bad block number, which usually means we got a bad line.
modem()
receive_message()
run()
send_ack()
ack
) char, to signal that we received and stored a correct block
Resets count of timeouts and returns the Xmodem::Block
object of the data block
received.
send_timeout()
nak
) char, to signal that we received a bad block header (either
a bad start char or a bad block number), or a bad data checksum. Increments count
of timeouts and at ten timeouts, aborts transfer.
C:\Perl_PPM\Device-Modem-1.57\blib/lib/Device/Modem/Protocol/Xmodem.pm |