Skip to content

Need help with Xmodemย #280

@rahul007-bit

Description

@rahul007-bit

Hi Everyone,
Currently, I am working on my university project were, we have to transfer an image via Zigbee XBee Module S2C.

So, I am trying to use the Xmodem (https://xbplib.readthedocs.io/en/latest/api/digi.xbee.util.xmodem.html) protocol but cannot understand how to use it.

Sender Code

def write_cb(Bytearray):
    try:
        device.send_data(remote_device, Bytearray)
        time.sleep(0.25)
        return True
    except Exception as e:
        print(e)
        return False


def read_cb(size_read, timeout):
    message = device.read_data_from(remote_device, timeout=timeout)
    print(message)
    return message
try:
    device.open()

    # Obtain the remote XBee device from the XBee network.
    xbee_network = device.get_network()
    remote_device = xbee_network.discover_device(REMOTE_NODE_ID)
    if remote_device is None:
        print("Could not find the remote device")
        exit(1)

    send_file_ymodem(FILE, write_cb=write_cb, read_cb=read_cb)

    print("Success")


finally:
    if device is not None and device.is_open():
        device.close()

Receiver Code

def write_cb(Bytearray):
  try:
      res = device.send_data_async(remote_device,Bytearray)
      print(res)
      if res:
          return True
      else:
          return False
  except Exception as e:
      print(e)
      return False

def read_cb(size_read, timeout):
  try:
      size_read = device.read_data_from(remote_device, timeout=timeout)
      return size_read
  except Exception as e:
      print(e)
      return None

try:
    device.open()
    xbee_network = device.get_network()
    remote_device = xbee_network.discover_device(REMOTE_NODE_ID)
    if remote_device is None:
        print("Could not find the remote device")
        exit(1)

    get_file_ymodem(FILE, write_cb, read_cb)
    print("Waiting for data...\n")
    input()

finally:
    if device is not None and device.is_open():
        device.close()

This is what I have tried till now, you may have guessed till now it's not going to work, so please guide me ๐Ÿ™๐Ÿผ ๐Ÿฅบ.

Your reply will be like thor's hammer for which I am worthy(I assume).

any example will help a lot.

Thank You,
waiting for your reply ๐Ÿค—!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions