Comments (6)
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.
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.
Created PR #43, would you mind checking if it resolves the issue?
from serial.nim.
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.
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.
@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)
- Compile errors on macOS Mojave HOT 4
- Asynchronous IO blocks dispatcher thread. HOT 3
- Serial stream issues with current Nim compiler HOT 3
- All programs fail to compile with serial lib in nim 1.0 HOT 12
- Serial library wont compile on Windows HOT 9
- Linux implementation won't list the Bluetooth related serial ports HOT 2
- Windows 7 implementation won't list the serial USB related serial ports. HOT 12
- Read timeout does not function correctly on windows implementation. HOT 2
- Setting write timeout to zero results in TIMEOUT_INFINITE on windows. HOT 2
- ffi_windows.nim(29, 27) Error: cannot convert 4294967295 to DWORD HOT 3
- Implement some CI
- Error: type mismatch: got <clong> but expected 'Suseconds = int32' HOT 5
- Can't detect all serial ports on Windows 10 HOT 5
- Build fails on MacOS 10.13.6 with clang error: use of undeclared identifier 'IUCLC' HOT 1
- undeclared identifier: 'PCustomOverlapped' HOT 7
- Force synchronization of the serial port? HOT 18
- Fails to compile on Windows with `--gc:orc` HOT 1
- Getting an error with 'useWinUnicode' when trying to compile my serial import HOT 1
- Checking data before reading (non-blocking) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serial.nim.