Commit Graph

213 Commits

Author SHA1 Message Date
Cristian Maglie
68f27d6a45 Upgrade x/sys dependency 2023-01-02 13:02:01 +01:00
Jaime
75542ba31a Added support for sending breaks 2023-01-02 13:02:01 +01:00
Cristian Maglie
f85edb454b Merge pull request #152 from cmaglie/enumerator_improvements
Retry port enumeration 5 times before giving up (macosx)
2023-01-02 13:00:53 +01:00
Cristian Maglie
376ad6baaf Retry port enumeration 5 times before giving up (macosx)
We observer errors getting the IOCalloutDevice string, this is a
tentative fix based on the hypotesis that the enumerator is
called too early during the USB enumeration phase.
2023-01-02 12:56:19 +01:00
Cristian Maglie
bc6a7f7fde Merge pull request #147 from cmaglie/remove_windows_timeout_loop
Remove unnecessary code, originally for checking for disconnects when using non-overlapped I/O
2022-11-29 11:12:13 +01:00
Cristian Maglie
5d3a516f12 Removed port-alive-check loop on Windows implementation 2022-11-28 17:32:57 +01:00
Cristian Maglie
0103114d50 Merge pull request #142 from JackDoan/fix-mac-buffer-resets
Fix ResetInputBuffer and ResetOutputBuffer on Darwin
2022-11-25 14:42:21 +01:00
Frank Palazzolo
1b32e59871 Remove unnecessary code, originally for checking disconnects
The old code is no more needed when using overlapped I/O,
getOverlappedEvent() returns all required error codes.

Calling getCommState()/setCommState() every second in some
applications contributes to other downstream issues. For examples:

https://github.com/bugst/go-serial/issues/60#issuecomment-625749122
https://github.com/arduino/arduino-ide/issues/375
2022-11-24 17:18:20 +01:00
Jack Doan
1bf551e025 Fix ResetInputBuffer and ResetOutputBuffer on Darwin 2022-09-30 13:27:07 -05:00
Cristian Maglie
a77d80189a Merge pull request #140 from cmaglie/initial_rts_dtr
Allow setting RTS and DTR on `Open`
2022-09-04 13:34:37 +02:00
Cristian Maglie
3099149a03 Added a doc notice for posix 'pulse' problem 2022-09-03 18:04:47 +02:00
Cristian Maglie
3c9f14262a Default status bits to 'on' 2022-09-02 17:40:21 +02:00
Tobias Kaupat
980038c3ea Allow to set initial RTS and DTR state after connect 2022-09-01 15:29:06 +02:00
Cristian Maglie
7ca3f7d1cd Merge pull request #136 from cmaglie/fix_small_timeout
Fix potential small timeout bug on unix implementation
2022-02-21 16:04:00 +01:00
Cristian Maglie
5e9cceab81 Fix potential small timeout bug on unix implementation
A very small port.readTimeout may lead to a negative timeout if the
elapsed time between:

    deadline = time.Now().Add(port.readTimeout)

and

    timeout = time.Until(deadline)

is longer than port.readTimeout.

Fix #134
2022-02-18 12:45:36 +01:00
Cristian Maglie
de2de784c4 Merge pull request #135 from cmaglie/skip-enumerating-unaccessible-serial-port
Skip enumerating ports that are not accessible for any reason
2022-02-18 12:41:35 +01:00
Cristian Maglie
1a0bc3c536 Merge pull request #110 from cmaglie/slight_performance_fix
Move regex compile outside loop
2022-02-18 12:40:50 +01:00
Cristian Maglie
b27526b25d Skip enumerating ports that are not accessible for any reason
Otherwise ports like /dev/ttyS0 may be listed in case of "access
denied" errors.
2022-02-18 12:20:20 +01:00
Cristian Maglie
f344e5f764 Merge pull request #129 from cmaglie/update-deps-and-golang-support
Update deps and minimum golang support to 1.17
2022-01-04 17:36:45 +01:00
Cristian Maglie
0e95fd4d4b Updated test workflows to run on go1.17 2022-01-04 17:27:57 +01:00
Cristian Maglie
c3f2459bdd Update minimal go version to 1.17 and do a run of go mod tidy 2022-01-04 17:12:23 +01:00
Cristian Maglie
2cf9e2e281 Remove old go1.9- compatibilty files 2022-01-04 17:11:35 +01:00
Cristian Maglie
d244d828fe Merge pull request #120 from ctarsjp/uart-ports-detection
Added detection of UART ports (/dev/ttymxc*)
2021-09-13 10:06:40 +02:00
Stepan
9fed730fb2 Added detection of UART ports (/dev/ttymxc*) 2021-09-06 18:40:01 +09:00
Cristian Maglie
83a8c96664 Merge pull request #119 from cmaglie/fix-darwin-arm64-issue
Fixed runtime build problem with darwin/amd64
2021-09-01 14:59:17 +02:00
Cristian Maglie
40f997f235 Fixed runtime build problem with darwin/amd64
For some strange reason the interaction between the go-sqlite3 lib and
the go-serial produced a weird panic as described in:

https://github.com/bugst/go-serial/issues/115
https://github.com/bugst/go-serial/issues/116

The solution is to just upgrade the x/unix package to the latest
version available at the moment.

Fix #115
Fix #116
2021-08-27 16:19:34 +02:00
Cristian Maglie
adc54fb194 Updated license years 2021-07-20 12:56:48 +02:00
Cristian Maglie
9cebdc6aa3 Small update to docs 2021-07-20 12:54:16 +02:00
Cristian Maglie
37dba3ab43 Merge pull request #113 from cmaglie/fix-ppc64lebuild
Fixed build for linux/ppc64le
2021-07-20 12:45:35 +02:00
Cristian Maglie
0213833089 Fixed build for linux/ppc64le 2021-07-13 13:27:10 +02:00
Cristian Maglie
13b6f1ac38 Merge pull request #111 from cmaglie/custom-baudrate
Allow to set non-standard baud rates
2021-07-01 13:06:55 +02:00
Cristian Maglie
9d74cb081f Added *bsd placeholders 2021-07-01 00:48:39 +02:00
Cristian Maglie
8ed18bb997 Fixed custom baud rate settings for MacOSX 2021-07-01 00:41:27 +02:00
Cristian Maglie
cff9b2347b Allow setting custom baudrates on serial ports (mac and linux version)
Co-authored-by: Jan-Philipp Benecke <github@bnck.me>
2021-07-01 00:40:51 +02:00
Cristian Maglie
01c367d024 Merge pull request #109 from cmaglie/timeouts
Implementation of read timeouts
2021-06-29 17:00:47 +02:00
Cristian Maglie
25a9426221 Move regex compile outside loop 2021-06-29 16:40:56 +02:00
Cristian Maglie
23dbc8b9ba SetReadTimeout: windows implementation 2021-06-29 15:24:52 +02:00
Cristian Maglie
2cb14f049c SetReadTimeout: unix implementation 2021-06-29 15:24:40 +02:00
Cristian Maglie
a63b28875f linux: detect port disconnection during Read
See https://stackoverflow.com/a/34945814/1655275

> pselect signals that file descriptor is ready and
> ioctl(fd, FIONREAD, &len) returns zero len.

Failure to detect this condition has been revealed by
the testsuite:

=== RUN   TestDisconnectingPortDetection
2017/07/27 13:56:37 PR - Connecting to Probe
2017/07/27 13:56:37      > Searching for port 2341:8037
2017/07/27 13:56:37        Detected port '/dev/ttyACM0' 2341:8037
2017/07/27 13:56:37        Using '/dev/ttyACM0'
2017/07/27 13:56:37 Starting test (timeout 20s)
2017/07/27 13:56:37 PR - Turn ON target
2017/07/27 13:56:37 TR - Connecting to Target
2017/07/27 13:56:37      > Searching for port 2341:8036
2017/07/27 13:56:37        Detected port '/dev/ttyACM0' 2341:8037
[...cut...]
2017/07/27 13:56:46      > Searching for port 2341:8036
2017/07/27 13:56:46        Detected port '/dev/ttyACM0' 2341:8037
2017/07/27 13:56:46        Detected port '/dev/ttyACM1' 2341:8036
2017/07/27 13:56:46        Using '/dev/ttyACM1'
2017/07/27 13:56:46 T2 - Make a Read call
2017/07/27 13:56:46 T1 - Delay 200ms before disconnecting target
2017/07/27 13:56:46 T1 - Disconnect target
2017/07/27 13:56:46 PR - Turn OFF target
2017/07/27 13:56:46 T2 - Read returned: n=0 err=nil
--- FAIL: TestDisconnectingPortDetection (9.18s)
        Error Trace:    serial_test.go:100
	Error:		An error is expected but got nil. %s
	Messages:	Read returned no errors

this commit fix the problem above.
2021-06-29 15:24:32 +02:00
Cristian Maglie
f355dbf608 windows: correcly signal PortClosed error on blocked Read()
This commit fix regression test TestConcurrentReadAndWrite.

Even if the test checks purpose is another it has detected
anyway that the returned error is incorrect.

Another specific test for closing port detection will be added
in the future.
2021-06-29 15:23:40 +02:00
Cristian Maglie
383ed1cd2a Merge pull request #103 from cmaglie/windows-improve-usb-sernum-disc
Windows improve usb serial number discovery
2021-02-26 14:59:48 +01:00
Cristian Maglie
57ac200f98 windows: improved serial number detection on composite USB devices 2021-02-26 12:34:22 +00:00
Cristian Maglie
7183520fbb run of go-fmt 2021-02-26 12:34:22 +00:00
Cristian Maglie
388e793063 Merge pull request #102 from cmaglie/go-generate-rerun
Refresh run of go generate with the latest mksyscall
2021-02-26 13:25:56 +01:00
Cristian Maglie
233eb2a09b Refresh run of go generate with the latest mksyscall 2021-02-26 13:20:02 +01:00
Cristian Maglie
b6c28f76a4 Merge pull request #101 from cmaglie/big-sur-support
Added support for macosx 10.11+
2021-02-26 13:17:09 +01:00
Cristian Maglie
b62cd2386c Added support for macosx 10.11+
Seems like, starting from 10.11, IOUSBDevice has been renamed to IOUSBHostDevice.
2021-02-26 13:07:44 +01:00
Tomáš Polomský
e18766f4d1 update go generate
Replace old mkwinsyscall call by the new version which is recommended
by Go since version 1.13.3.
2021-02-26 12:26:27 +01:00
Cliff Brake
be77090773 update goselect to get riscv support 2021-02-26 12:24:20 +01:00
Tobias Kohlbau
57b513a432 add support for darwin arm64
Support arm64 which is used by the new lineup of computers
from apple.

Signed-off-by: Tobias Kohlbau <tobias@kohlbau.de>
2021-02-15 09:39:59 +01:00