Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to stop Xmodem after bin file transfer was finished
hello freinds,

I am sending a BIN file successfully to my energy meter through serial port using the code in the bottom. My problem is that Xmodem doesn't stop after all 128 blocks where sent and i have no idea how to break from it and communicate again with my meter.

Please your kind help.
def sendFile():
    fileSize = os.path.getsize('104_new.BIN')
    total = math.ceil(fileSize /128) 
    ser= serialPort.serialport
    print (ser)

    def getc(size, timeout=0):
        gbytes =
        print(f'Read Byte: {gbytes}')
        return gbytes or None

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

    modem =XMODEM(getc,putc)
    f = open('104_new.BIN', "rb")
this is the error code i get:

send error: expected ACK; got None Exception in thread Thread-2: Traceback (most recent call last): File "C:\Users\shay\AppData\Local\Programs\Python\Python37-32\lib\", line 926, in _bootstrap_inner File "C:\Users\shay\AppData\Local\Programs\Python\Python37-32\lib\", line 870, in run self._target(*self._args, **self._kwargs) File "C:\PythonTerminal-master\PythonTerminal-master\", line 211, in sendFile status= modem.send(f,retry=50,timeout=0) File "C:\Users\shay\AppData\Local\Programs\Python\Python37-32\lib\site-packages\xmodem\", line 349, in send self.putc(EOT) File "C:\PythonTerminal-master\PythonTerminal-master\", line 203, in putc pbytes = ser.write(data) File "C:\Users\shay\AppData\Local\Programs\Python\Python37-32\lib\site-packages\serial\", line 315, in write raise SerialException("WriteFile failed ({!r})".format(ctypes.WinError())) serial.serialutil.SerialException: WriteFile failed (OSError(9, 'The handle is invalid.', None, 6))
Larz60+ wrote Nov-28-2019, 03:25 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  problems sending BIN file with XMODEM python shaya2103 0 199 Nov-23-2019, 10:27 AM
Last Post: shaya2103
  Xmodem error neethuvp 6 463 Oct-18-2019, 06:08 AM
Last Post: neethuvp
  Process finished with exit code -107374819 (0xC0000375) mrazko 2 2,095 Apr-05-2019, 12:46 PM
Last Post: mrazko
  Fabric - Run method is not being finished mglowinski93 3 764 Dec-29-2018, 10:45 AM
Last Post: mglowinski93
  SFTP transfer using paramiko fails estebanup03 0 1,673 Sep-06-2018, 08:06 PM
Last Post: estebanup03
  Progress Finished Question malonn 32 5,415 May-23-2018, 02:43 AM
Last Post: malonn
  Python script that transfer it self iboman5 6 1,540 Nov-13-2017, 05:27 PM
Last Post: AceScottie
  Python script that transfer it self iboman5 2 1,243 Nov-10-2017, 06:56 PM
Last Post: iboman5
  How to transfer a music file, from "uploads" directory into my project sylas 15 3,358 Sep-10-2017, 09:16 PM
Last Post: sylas
  How to transfer a music file, from "Telechargements" into my project sylas 6 1,791 Sep-02-2017, 09:27 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)