Python Forum

Full Version: problems sending BIN file with XMODEM python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello my freinds,


i am trying to send a bin file which i already tested with teraterm before.
the reciever is an energy meter, i am connected to it by usb/rs232 converter.

when i start the XMODEM i recieve the following error:

*Read Byte: b'\x00'

send error: expected NAK, CRC, or CAN; got b'\x00'*



can anyone please help?

i am using the following code:

def sendFile():

    ser= serialPort.serialport
    ser.flushInput()
    print (ser)

def getc(size, timeout=8):
    gbytes = ser.read(size)
    sleep(2)
    print(f'Read Byte: {gbytes}')
    return gbytes or None


def putc(data, timeout=8):
    pbytes = ser.write(data)
    sleep(2)
    print(f'Put Byte: {pbytes}')
    return pbytes or None

modem =XMODEM(getc,putc)
stream = open('104_new.BIN', 'rb')
modem.send(stream)
print(stream)