Events

new Xmodem()

Instantiate by var xmodem = require('xmodem.js');

License
http://spdx.org/licenses/BSD-2-Clause

Properties

constant

block_size  integer

how many bytes (excluding header & checksum) in each block? Don't change this
unless you have need for non-standard implementation.

Default value
128
constant

timeout_seconds  integer

default timeout period in seconds

Default value
10
constant

VERSION  string

xmodem.js package version.

constant

XMODEM_CRC_ATTEMPTS  integer

how many times should receiver attempt to use CRC?

Default value
3
constant

XMODEM_MAX_ERRORS  integer

how many errors on a single block before the receiver gives up?

Default value
10
constant

XMODEM_MAX_TIMEOUTS  integer

how many timeouts in a row before the sender gives up?

Default value
5
constant

XMODEM_OP_MODE  string

Try to use XMODEM-CRC extension or not? Valid options: 'crc' or 'normal'

Default value
crc
constant

XMODEM_START_BLOCK  integer

First block number. Don't change this unless you have need for non-standard
implementation.

Default value
1

Methods

receive(socket, filename)

Receive a file using XMODEM protocol

Parameters

Name Type Optional Description

socket

socket

 

net.Socket() or Serialport socket for transport

filename

string

 

pathname where to save the transferred file

send(socket, dataBuffer)

Send a file using XMODEM protocol

Parameters

Name Type Optional Description

socket

socket

 

net.Socket() or Serialport socket for transport

dataBuffer

buffer

 

Buffer() to be sent

Events

ready

Ready to send event, buffer has been broken into individual blocks to be sent.

Property

Name Type Optional Description

integer

 

Indicates how many blocks are ready for transmission

start

Transmission Start event. A successful start of transmission.

Property

Name Type Optional Description

string

 

Indicates transmission mode 'crc' or 'normal'