Commit Graph

55 Commits

Author SHA1 Message Date
Stepan
5069d66aa2 Windows: fixed port enumeration 2025-03-28 16:28:13 +09:00
Cristian Maglie
1ff9b6fa9a If the timeout is set to NoTimeout, make Read wait forever.
Otherwise the maximul allowed timeout is 0x7FFFFFFF milliseconds,
equivalent to about 24.85 days.
This patch will make a transparent repeated read in case this long
timeout should ever happen.
2025-03-17 10:57:21 +01:00
Cristian Maglie
fb4b111d50 Hack for CH340 support 2025-03-12 20:50:56 +01:00
Tom Payne
56ac2d4e76 Restore check for no detected serial ports on Windows 2024-06-25 11:02:05 +02:00
Tom Payne
1c72447e64 Fix typos
Co-authored-by: Cristian Maglie <c.maglie@bug.st>
2024-06-25 10:48:18 +02:00
Tom Payne
45e996e1b0 Use Windows serial comm functions from golang.org/x/sys/windows 2024-06-24 18:28:26 +02:00
Andreas Deininger
0b7848559a Fix typos (#183)
Co-authored-by: Cristian Maglie <c.maglie@bug.st>
2024-06-24 17:33:18 +02:00
Cristian Maglie
572f392ca9 Updated license year 2024-02-20 15:27:44 +01:00
Cristian Maglie
c414e4f55c windows: Avoid double-set of communication parameters on Open 2024-02-16 13:32:43 +01:00
Cristian Maglie
386b387977 Updated license 2023-08-10 01:07:25 +02: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
893b2eb082 Added Break implementation for windows 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
5d3a516f12 Removed port-alive-check loop on Windows implementation 2022-11-28 17:32:57 +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
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
adc54fb194 Updated license years 2021-07-20 12:56:48 +02:00
Cristian Maglie
23dbc8b9ba SetReadTimeout: windows implementation 2021-06-29 15:24:52 +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
00e63fcc18 small cosmetic fix 2020-09-23 18:27:06 +02:00
Tobias Kaupat
f0282e0b50 Use mutex on Close() to avoid data races on windows 2020-04-19 01:25:10 +02:00
Tobias Kaupat
545e830e04 Allow multiple calls to close 2020-04-19 01:24:57 +02:00
Cristian Maglie
f7a06a7c47 Merge remote-tracking branch 'origin/v1' 2020-04-18 23:46:54 +02:00
martin-zaber
9f6eea0188 Fixing getPortList on windows without any ports 2020-04-18 23:43:54 +02:00
Cristian Maglie
df95023074 Introducing go.mod for dep management 2019-12-02 19:51:36 +01:00
Cristian Maglie
24a6610f05 Updated license years
Updated to 2020 even if we are less than one month ahead.
2019-12-02 19:27:10 +01:00
Tobias Kaupat
04b4ab1e45 Remove GetDTR() and GetRTS() 2017-07-28 09:49:49 +02:00
Tobias Kaupat
fd75bf3895 Windows: Set DTS via setCommState
https://github.com/bugst/go-serial/issues/35
2017-07-25 13:07:20 +02:00
Veniamin Albaev
8b7629bfe1 Added buffer flush methods
+ serial.Port.ResetInputBuffer()
+ serial.Port.ResetOutputBuffer()
2017-03-09 11:47:38 +03:00
Cristian Maglie
970475ed06 Updated licenses 2017-03-04 16:29:55 +01:00
Veniamin Albaev
b55fdf163b All //sys instructions moved to separate syscall_* files
Generated `syscall_*` files ranamed to `zsyscall_*` ones
like it done in `golang.org/x/sys` package.
2017-02-23 21:40:47 +03:00
Veniamin Albaev
378aafb2f7 //go:generate moved out of OS specific go file
To avoid cross platform go generate issue
Look at https://github.com/golang/go/issues/16368
2017-01-24 11:29:30 +03:00
Cristian Maglie
ff9cf2b84b Windows: use OVERLAPPED operations 2017-01-21 12:47:54 +01:00
Cristian Maglie
aa77894c35 Modem signals implementaions (windows) 2016-10-31 18:02:38 +01:00
Cristian Maglie
5be0087bd5 Added interface methods for RS232 signals 2016-10-31 18:02:38 +01:00
Cristian Maglie
f56a50621e Slighlty improved bits handling in windows 2016-10-31 18:02:38 +01:00
Cristian Maglie
b93c8f2fea Use go:generate to create syscall_windows.go
This dramatically improves maintainability of generated files.

This will be eventually implemented on other generated files as well.
2016-10-22 22:37:33 +02:00
Cristian Maglie
b89deafa1c Change import path to "go.bug.st/serial.v1"
This is needed when there are breaking changes in the API.
2016-09-05 01:05:22 +02:00
Cristian Maglie
f5235118e1 Made mode bits enumeration explicit in Windows implementation 2016-04-25 00:05:34 +02:00
Cristian Maglie
294a68d523 Another round of lint on Windows implementation 2016-04-25 00:05:34 +02:00
Cristian Maglie
f5be203394 Created interface Port. Rationalized documentation. 2016-04-24 17:20:49 +02:00
Cristian Maglie
88e647775e Rename serial.SerialPort to serial.Port
another lint suggestion.
2016-04-24 17:20:49 +02:00
Cristian Maglie
485b2f86a8 Fixed a bunch of golint warnings (this needs an API change) 2016-04-24 17:20:49 +02:00
Cristian Maglie
e90aca32c8 Updates to documentation 2016-01-01 21:14:05 +01:00
Cristian Maglie
5946927a79 Fix for field visibility in SerialPort struct 2015-01-02 03:10:12 +01:00
Cristian Maglie
55b609d095 Added first draft of documentation 2015-01-02 03:08:31 +01:00
Cristian Maglie
2629684436 Cosmetic change: rewritten error conditions in a more compact way 2014-12-31 00:37:02 +01:00
Cristian Maglie
9e85415532 Removed cgo dependency from windows implementation 2014-12-31 00:27:28 +01:00
Cristian Maglie
3415c57d6a Use pointers in windowsSerialPort methods 2014-12-30 20:45:25 +01:00