digi.xbee.util.xmodem module

exception digi.xbee.util.xmodem.XModemException[source]

Bases: Exception

This exception will be thrown when any problem related with the XModem/YModem transfer occurs.

All functionality of this class is the inherited from Exception.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception digi.xbee.util.xmodem.XModemCancelException[source]

Bases: digi.xbee.util.xmodem.XModemException

This exception will be thrown when the XModem/YModem transfer is cancelled by the remote end.

All functionality of this class is the inherited from Exception.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

digi.xbee.util.xmodem.send_file_xmodem(src_path, write_cb, read_cb, progress_cb=None, log=None)[source]

Sends a file using the XModem protocol to a remote end.

Parameters:
  • src_path (String) – absolute path of the file to transfer.
  • write_cb (Function) –

    function to execute in order to write data to the remote end. Takes the following arguments:

    • The data to write as byte array.

    The function returns the following:

    Boolean: True if the write succeeded, False otherwise.
  • read_cb (Function) –

    function to execute in order to read data from the remote end. Takes the following arguments:

    • The size of the data to read.
    • The timeout to wait for data. (seconds)

    The function returns the following:

    Bytearray: the read data, None if data could not be read
  • progress_cb (Function, optional) –

    function to execute in order to receive progress information. Takes the following arguments:

    • The progress percentage as integer.
  • log (Logger, optional) – logger used to log transfer debug messages
Raises:
  • ValueError – if any input value is not valid.
  • XModemCancelException – if the transfer is cancelled by the remote end.
  • XModemException – if there is any error during the file transfer.
digi.xbee.util.xmodem.send_file_ymodem(src_path, write_cb, read_cb, progress_cb=None, log=None)[source]

Sends a file using the YModem protocol to a remote end.

Parameters:
  • src_path (String) – absolute path of the file to transfer.
  • write_cb (Function) –

    function to execute in order to write data to the remote end. Takes the following arguments:

    • The data to write as byte array.

    The function returns the following:

    Boolean: True if the write succeeded, False otherwise
  • read_cb (Function) –

    function to execute in order to read data from the remote end. Takes the following arguments:

    • The size of the data to read.
    • The timeout to wait for data. (seconds)

    The function returns the following:

    Bytearray: the read data, None if data could not be read
  • progress_cb (Function, optional) –

    function to execute in order to receive progress information. Takes the following arguments:

    • The progress percentage as integer.
  • log (Logger, optional) – logger used to log transfer debug messages
Raises:
  • ValueError – if any input value is not valid.
  • XModemCancelException – if the transfer is cancelled by the remote end.
  • XModemException – if there is any error during the file transfer.
digi.xbee.util.xmodem.get_file_ymodem(dest_path, write_cb, read_cb, crc=True, progress_cb=None, log=None)[source]

Retrieves a file using the YModem protocol from a remote end.

Parameters:
  • dest_path (String) – absolute path to store downloaded file in.
  • write_cb (Function) –

    function to execute in order to write data to the remote end. Takes the following arguments:

    • The data to write as byte array.

    The function returns the following:

    Boolean: True if the write succeeded, False otherwise
  • read_cb (Function) –

    function to execute in order to read data from the remote end. Takes the following arguments:

    • The size of the data to read.
    • The timeout to wait for data. (seconds)

    The function returns the following:

    Bytearray: the read data, None if data could not be read
  • crc (Boolean, optional) – True to use 16-bit CRC verification, False for standard 1 byte checksum. Defaults to True.
  • progress_cb (Function, optional) –

    function to execute in order to receive progress information. Takes the following arguments:

    • The progress percentage as integer.
  • log (Logger, optional) – logger used to log download debug messages
Raises:
  • ValueError – if any input value is not valid.
  • XModemCancelException – if the file download is cancelled by the remote end.
  • XModemException – if there is any error during the file download process.