Device...:Xmodem(3pm)
π NAME π
Device::Modem::Protocol::Xmodem β it's the XModem protocol implementation, bestie! This is a 3pm page, from the User Contributed Perl Documentation collection, and it's basically the whole XModem universe: blocks, buffers, constants, and the receiver that actually does the thing. π¦
π Xmodem::Block π
Okay so this class is the moment β it represents one single Xmodem data block. That's it, that's the whole job. π
β¨ Synopsis β¨
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();
πΈ Xmodem::Buffer πΈ
This one is the class that implements an Xmodem receive buffer of data blocks. Every single block of data is represented by an Xmodem::Block object β no exceptions, no shortcuts. π«Ά
Blocks can be pushed and popped from the buffer. You can grab the last block, or the whole list of blocks from the buffer. So many options, honestly iconic.
β¨ Synopsis β¨
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 ???
Not me pointing out the# TODO document replace() function ???comment β the original literally says that, so it stays. Thereplace()function is undocumented, and that's canon. π
π§ Xmodem::Constants π§
A package that contains all the useful Xmodem protocol constants used in handshaking and in the data-block encoding procedures. Your little toolbox of protocol vibes. π₯
β¨ Synopsis β¨
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βCASCII charXmodem::Constants::XMODEMβ basic xmodem protocolXmodem::Constants::XMODEM_1Kβ xmodem protocol with 1k blocksXmodem::Constants::XMODEM_CRCβ xmodem protocol with CRC checksXmodem::Constants::CHECKSUMβ type of block checksumXmodem::Constants::CRC16β type of block crc16Xmodem::Constants::CRC32β type of block crc32
Bestie, I kept every single spelling exactly as written βtrasmission,acknowlegdedand all. Not my typos, I promise, that's just how the constants are documented. π
π Xmodem::Receiver π
This is the control class β the main character β that initiates and completes an "X-modem" file transfer in receive mode. π
β¨ Synopsis β¨
my $recv = Xmodem::Receiver->new(
modem => {Device::Modem object},
filename => 'name of file',
XXX protocol => 'xmodem' | 'xmodem-crc', | 'xmodem-1k'
);
$recv->run();
π¦ Object methods π¦
abort_transfer()β Sends a cancel char ("can"), which signals to the sender that the transfer is aborted. This gets issued if we receive a bad block number, which usually means we got a bad line. πmodem()β Returns the underlyingDevice::Modemobject. That's the whole method, no cap.receive_message()β Retrieves a message from the modem, and if a block is detected it breaks it into the appropriate parts. Slicing and dicing, chef's kiss. πͺrun()β Starts a new transfer until the file receive is complete. The only parameter accepted is the (optional) local filename to be written.send_ack()β Sends an acknowledge ("ack") char to signal that we received and stored a correct block. Resets the count of timeouts and returns the"Xmodem::Block"object of the data block received. Slay. β¨send_timeout()β Sends a 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. It increments the count of timeouts, and at ten timeouts, it aborts the transfer. Ten strikes and you're out, periodt. π
π See also π
Device::Modem
And that's the whole page, bestie!! ππ Written from the Device...:Xmodem(3pm) page β that's the header, folded in right up top like a little bow β and the footer said perl v5.30.3 with a date of 2020-06-20, so shoutout to that version and that day for making this doc exist. Go receive some files. π¦β¨
π¦ where this page comes from
- debian bookworm: libdevice-modem-perl 1.59-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdevice-modem-perl 1.59-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libdevice-modem-perl 1.59-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdevice-modem-perl 1.59-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdevice-modem-perl 1.59-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms