Commit Graph

244 Commits

Author SHA1 Message Date
Cristian Maglie
674fbae95a Upgraded dependencies 2024-02-20 09:52:27 +01:00
Cristian Maglie
2aa105e32e Improved issue template message 2024-02-20 09:51:06 +01:00
Cristian Maglie
7f490f208a Added issues templates 2024-02-18 19:33:23 +01:00
Cristian Maglie
9a2045a5ff Merge pull request #174 from bugst/windows-multi-set-rtscts
windows: Avoid double-set of communication parameters on Open
v1.6.2
2024-02-16 14:29:21 +01:00
Cristian Maglie
8b563a8428 Merge pull request #175 from cmaglie/improve_error_messages
Improved error messages
2024-02-16 14:23:34 +01:00
Cristian Maglie
9aae282f09 Improved error messages 2024-02-16 14:17:53 +01:00
Cristian Maglie
1d3c0099c3 Merge pull request #173 from jes/master
unix: nativeOpen: always close the port on errors
2024-02-16 13:51:41 +01:00
Cristian Maglie
c414e4f55c windows: Avoid double-set of communication parameters on Open 2024-02-16 13:32:43 +01:00
James Stanley
0f730e491f unix: nativeOpen: always close the port on errors 2024-02-11 21:08:52 +00:00
Cristian Maglie
8a31fcbd9b Merge pull request #165 from cmaglie/fix_darwin_enumerator
Fix some rare MacOSX USB port enumerator failures
2023-09-14 15:31:58 +02:00
Cristian Maglie
f3f01227e9 Fix some rare IOServiceGetMatchingServices failure on MacOSX
We had reports of users always getting:

  IOServiceGetMatchingServices failed, data changed while iterating

The issue seems related to the function getMatchingServices that
returns an always-invalid iterator even if there are no actual services.

This is a workaround for this issue.
2023-09-14 15:24:41 +02:00
Cristian Maglie
2e9030760a Merge pull request #163 from deadprogram/define-darwin-cgo-types
darwin: use Go type wrappers to avoid declaring Go methods on C types.
2023-08-10 13:10:52 +02:00
Cristian Maglie
1e13b2f610 removed leftover print 2023-08-10 13:10:27 +02:00
Cristian Maglie
c9a9ed456d darwin: wrap cgo-types directly (without using a struct)
This makes easier the boxing/unboxing of the wrapped types.
2023-08-10 13:10:27 +02:00
Cristian Maglie
c1ded5fc98 darwin: moved type definitions near methods definition 2023-08-10 13:10:27 +02:00
deadprogram
80a3721f8b darwin: use Go type wrappers to avoid declaring Go methods on C types.
This is needed starting with Go 1.21 due to stricter enforcement of rules
about adding methods to existing types, now including C types.

See https://github.com/golang/go/issues/60725 for further details.

Signed-off-by: deadprogram <ron@hybridgroup.com>
2023-08-10 13:10:27 +02:00
Cristian Maglie
74e194ea45 Updated license 2023-08-10 01:09:42 +02:00
Cristian Maglie
386b387977 Updated license 2023-08-10 01:07:25 +02:00
Cristian Maglie
93097bf495 Removed obsolete +build directives in favor of modern go:build 2023-08-09 18:54:02 +02:00
Cristian Maglie
75c59a9418 Removed obsolete code 2023-08-09 18:48:09 +02:00
Daniel Lublin
d2a59a651d Make Open return a nil interface on failure
Closes #154

Signed-off-by: Daniel Lublin <daniel@lublin.se>
2023-08-09 18:41:06 +02:00
Cristian Maglie
a2c15aa1f5 Merge pull request #159 from AndreRenaud/feature/drain-support
Feature/drain support
2023-08-09 18:36:31 +02:00
Cristian Maglie
cce21700eb Added informative comment 2023-08-09 18:29:02 +02:00
Andre Renaud
bafe313749 Rework for Linux & BSD differences 2023-08-09 18:27:06 +02:00
Cristian Maglie
c89f81c053 Merge pull request #164 from ian-xu/master
feat: add ttyHS support for linux
2023-08-09 11:45:40 +02:00
Ancient Xu
10b7b3e7af feat: add ttyHS support for linux
Signed-off-by: Ancient Xu <ancientxu@gmail.com>
2023-08-08 18:17:02 +08:00
Tomáš Polomský
ff38fe2a78 add support for drain
Tested on Mac OS, Linux and Windows with UART emulated on USB.

I wrote general BSD code, because it should work, but I am not able to test
it.

On Mac OS I am quite sure that drain behaves as expected because it fixed
an issue with buffer overflow (which OS does not report but fails).

For Windows it seems that drain is actually part of `Write`, because
`Write` was long and `Drain` was fast. But I have not found any mention in
Win32 docs about buffering and asynchronous write, so I put there flushing
code to be sure, and this code did not break anything.

For Linux `Drain` is also taking more time than writing so it looks working
too.
2023-06-16 09:14:39 +02:00
Cristian Maglie
e381f2c133 Merge pull request #153 from cmaglie/fix_windows_enumerator
windows: Avoid panic if USB Product name is empty
2023-01-03 23:39:20 +01:00
Cristian Maglie
e6cff1a986 windows: Avoid panic if USB Product name is empty 2023-01-02 14:44:56 +01:00
Cristian Maglie
0c6a048ffa Merge pull request #145 from cmaglie/send_break
Added support for sending break (unix + windows)
2023-01-02 13:07:23 +01:00
Cristian Maglie
893b2eb082 Added Break implementation for windows 2023-01-02 13:02:01 +01:00
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