Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:55:14+00:00 2026-05-20T10:55:14+00:00

I have a working connection with my serial device via PySerial, but I also

  • 0

I have a working connection with my serial device via PySerial, but I also want to transfer files via the xmodem protocol as part of my program.

Which would be the most platform-neutral way to do this? Worst case, I could close() my serial.Serial object in Python and use subprocess to call upon /usr/bin/sb, but that seems inelegant.

I’m currently on Ubuntu 9.10 and am using a USB-TTY adapter.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:55:14+00:00Added an answer on May 20, 2026 at 10:55 am

    There is xmodem module on PyPi. It takes two functions in constructor for reading and writing data, implement them to work with your opened serial port. Below is simple sample of its usage:

    import serial
    try:
        from cStringIO import StringIO
    except:
        from StringIO import StringIO
    from xmodem import XMODEM, CRC
    from time import sleep
    
    def readUntil(char = None):
        def serialPortReader():
            while True:
                tmp = port.read(1)
                if not tmp or (char and char == tmp):
                    break
                yield tmp
        return ''.join(serialPortReader())
    
    def getc(size, timeout=1):
        return port.read(size)
    
    def putc(data, timeout=1):
        port.write(data)
        sleep(0.001) # give device time to send ACK
    
    
    port = serial.Serial(port='COM5',parity=serial.PARITY_NONE,bytesize=serial.EIGHTBITS,stopbits=serial.STOPBITS_ONE,timeout=0,xonxoff=0,rtscts=0,dsrdtr=0,baudrate=115200)
    port.write("command that loads data via xmodem\r\n")
    sleep(0.02) # give device time to handle command
    readUntil(CRC)
    buffer = StringIO('data to send')
    XMODEM(getc, putc).send(buffer, quiet = 1)
    buffer.close()
    readUntil()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I already have a working connection to the AD and can search and
I have a working controller for another stored procedure in the database, but I
I'm working in Python and using the MySQLdb module. I have a working connection
I have been working on a java application that has a connection to a
I have a problem connecting to any serial port (want to exchange with an
I have a working application that establishes an SSL connection to a server. The
I'm working on a device that has an unstable wireless connection and therefore requires
i have been working on developing an blackberry application. as per now i want
I have a Windows Service which performs some data collection from a serial device
I have a working LINQ to SQL model. I want to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.