Giter Site home page Giter Site logo

Comments (6)

euantorano avatar euantorano commented on July 19, 2024 1

Ah, yes. That makes more sense - good catch on my writeTimeout bug too. Luckily I didn't commit straight to master 😄

I'll do some testing after work tonight. Unfortunately I got a new mac recently with USB-C ports and only one USB-C to USB-A adapter, so tetsing my USB to serial ports is difficult without using two computers.

from serial.nim.

euantorano avatar euantorano commented on July 19, 2024

Yep, looks like the default writeTimeout is TIMEOUT_INFINITE which is -1. The code then checks if writeTimeout != 0 and if so, uses a timeout. This would fail in the infinite case.

from serial.nim.

euantorano avatar euantorano commented on July 19, 2024

Created PR #43, would you mind checking if it resolves the issue?

from serial.nim.

martin-c avatar martin-c commented on July 19, 2024

Thanks for your quick response Euan! Unfortunately, it this doesn't seem to fix the problem. I still get the same error: Invalid argument [OSError]. But what I didn't test yesterday is trying a writeTimeout value other than 1000 which appears in serial.nim and 0. It seems any timeout value from 1 to 999 works, but 1000 and up do not.

By the way, I think your commit introduces a change in the logic of the write function: testing for port.writeTimeout > 0'i32 on line 769 means that the conditional on line 780 if port.writeTimeout < 0: will always be false, right? So now timeout values of -1 and 0 both use posix.write after the else clause, and ptrTimer will never be nil whereas before this commit a timeout value of -1 used select with a nil timeout pointer (block indefinitely), and timeout = 0 used select with a 0uS timeout. I'm not sure if this is what you intended or not.

I'm trying to find why select timeout values of 1,000,000uS cause an error on MacOS.

from serial.nim.

martin-c avatar martin-c commented on July 19, 2024

So this is what needs to go on lines 777 and 778 I think:

    timer.tv_usec = Suseconds((port.writeTimeout mod 1000) * 1000)
    timer.tv_sec = Time(port.writeTimeout div 1000)

from serial.nim.

euantorano avatar euantorano commented on July 19, 2024

@martin-c Would you mind testing again? During testing I found a bug with read() when using an infinite timeout which caused read() to be called repeatedly, which I've fixed in #43 along with hopefully fixing the write timeout. I've tested sending from my Mac to a windows machine and from a windows machine to my Mac without any issues now.

There is some odd behaviour with SerialStream.readLine(), but I'll need to look into that another day - I had to hit enter twice on my Windows machine for it to be received on the Mac side...

from serial.nim.

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.