GithubHelp home page GithubHelp logo

change parity on the fly? about serial HOT 3 CLOSED

tarm avatar tarm commented on August 21, 2024
change parity on the fly?

from serial.

Comments (3)

tarm avatar tarm commented on August 21, 2024

I have a similar problem with a bootloader.

I don't think it would be right to change the baud rate while a read operation is occurring. That would cause a race condition and you would not know whether the data returned from the read was before or after the baud rate change (some bytes at different baud rates look valid at other baud rates depending on how the hardware samples the values). You should finish the read before changing the baud rate.

As you mentioned in the UPDATE, one way to force the read to finish and get a point to synchronize the code between goroutines is to use a read timeout. That is what I recommend and what I do for my bootloader 9600->faster transition.

I'm not sure what you mean by "EOF due to a port disconnect". As far as I know most serial hardware does not provide a way to determine a port disconnect. Unless you mean the whole module disappears (ie a USB<->serial cable gets unplugged at the USB side.

from serial.

jcw avatar jcw commented on August 21, 2024

"EOF due to a port disconnect"

Yes, I meant an unplugged cable. It'd be useful to detect the difference between an unplugged cable (and possibly try to re-open the device periodically), and a timed-out read request.

Changing parameters mid-flight is not necessarily a problem: the upload process starts with a sync handshake, ignoring any characters left over from a previous session until they're in sync.

from serial.

jcw avatar jcw commented on August 21, 2024

I'll close this issue. Feel free to re-open of course if you want to keep it around.
I've switched to go.bug.st/serial.v1, which supports on-the-fly mode changes.
Thanks for your response.

from serial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.