Commit graph

151 commits

Author SHA1 Message Date
Francis Gulotta
5b02ec869f Change the windows read timeouts for optimal reads
ReadIntervalTimeout

A value of MAXDWORD, combined with zero values for both the ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier members, specifies that the read operation is to return immediately with the bytes that have already been received, even if no bytes have been received.
2017-01-03 23:56:32 -05:00
Francis Gulotta
adccc6dfde [unix] Correct error messages on .set unix bindings 2016-12-11 18:48:43 -05:00
Francis Gulotta
b80025ea10 Merge pull request #1018 from munyirik/win32read
Adding WindowsBinding reading
2016-12-10 13:15:48 -05:00
Anton Litvinov
f24110b196
Refactoring of EIO_List for Windows: … (#1019)
* Refactoring of EIO_List for Windows:  …
1. use single API -- SetupAPI directly without COM-object
2. supply ResultItem with vendorId, productId and locationId (issue #877)
3. solve problem with pnpId not being returned on some systems
2016-11-27 22:09:24 -05:00
Munyiri Kamau
72768179df Fix build and test issues + updates based on review feedback
- Fix CI failure to build
- Tests (including read) now pass locally
- Changes based on review feedback
2016-11-21 16:30:24 -08:00
Munyiri Kamau
975b270ba3 Adding WindowsBinding reading 2016-11-16 19:30:47 -08:00
Francis Gulotta
672e8319c3 Conform to NodeJS error message formats (#998)
https://github.com/nodejs/node/pull/3374
2016-11-04 23:29:07 -04:00
Francis Gulotta
77c351e46a Remove v8 deprecation warnings 2016-11-04 22:54:09 -04:00
Francis Gulotta
39d0103937 Streams rewrite
This is a major change.  To reading, the poller and the bindings layer, there isn’t a great way to do this piecemeal. The goal here is to make bindings a plugin layer, our c++ bindings isolated and tested, and make Serialport a streams object.

- Move all bindings into platform specific modules DarwinBinding LinuxBinding, and WindowsBinding
- Separate out the bindings from the SerialPort class so it can be required by itself.
- Provide mock bindings as a tested first class bindings layer
- Mixin stream methods with `pushBindingWrap`, inspired from fs.readStream
- All integration tests now require an Arduino 
- Ditch sandboxed modules as we don't need to be that heavy handed to test anymore

TODO

- windows binding
- performance test
- memory leak test
- 🎉
2016-11-04 21:03:35 -04:00
Francis Gulotta
ecc4c31bd8 Fix memory-leaks in SerialPortParity and cleanup (#989)
This should stop a leak in bindings.open() which calls ToParityEnum().

Thanks to @indutny for walking me through the changes and teaching me about valgrind!
2016-11-03 15:24:20 -04:00
enami tsugutomo
f25563dded Plug windows handle leak when open failed. 2016-10-24 12:35:20 +09:00
Francis Gulotta
23de171055 Do error checking when getting modem control flags 2016-10-21 21:35:50 -04:00
Francis Gulotta
0d757fd72c Merge pull request #967 from jgillick/master
Get modem status bits (CTS, DSR, DCD)
2016-10-21 17:50:49 -04:00
Francis Gulotta
0018f0cd25 remove all read timeouts for windows (#974)
per #781
2016-10-19 23:17:49 -04:00
Francis Gulotta
d26991187d Use PurgeComm to flush all current reads and writes on windows (#973)
Fixes #962
2016-10-19 22:20:18 -04:00
Francis Gulotta
ebad161050 Merge pull request #972 from giseburt/master
Fix for issue #781
2016-10-19 21:50:19 -04:00
jgillick
d3dcac14fa Fix code typos (duplicate ->cts) 2016-09-28 02:56:09 -07:00
jgillick
71a069f447 Add get function and bindings for modem status bits 2016-09-19 09:10:43 -07:00
Francis Gulotta
71f7fb317a strip whitespace (#913) 2016-08-22 11:29:45 -04:00
Francis Gulotta
3400822e80 [unix] Flush now gives errors and flushes tx and rx (#900)
- Bonus less structs as many functions return nothing or error
2016-08-08 15:13:04 -04:00
Rob Giseburt
1162513bfb Change windows write timeouts to 0 (never). 2016-07-25 20:51:27 -05:00
Francis Gulotta
7eca965961 Enable locking and sharing of the serialport (#840) 2016-06-11 22:34:07 -04:00
Francis Gulotta
e986563c75 Make sure .drain and .set error on all platforms. (#834) 2016-05-29 16:03:18 -04:00
Francis Gulotta
18b59eff3e Implement .update() on windows (#831) 2016-05-29 00:26:02 -04:00
Francis Gulotta
901c026ed6 whitespace and spelling 2016-05-28 23:24:58 -04:00
Roger Hardiman
19fb6f9e21 Add GetCommState to fix Error 87 on a Virtual Comm Port (#824)
* Add GetCommState to support a Virtual Comm Port
2016-05-24 22:20:37 -04:00
Francis Gulotta
67e84d950e Dry up serialport.cpp (#818) 2016-05-23 21:39:50 -04:00
Francis Gulotta
4b984e8995 write binding tests and cleanup (#808)
- Fix bug where write callback was being called multiple times when write operations blocked
 - [windows] refactored write code to be less complex
 - [unix] refactored write code to be less complex
 - added arduino required integration tests
2016-05-16 21:33:00 -04:00
Francis Gulotta
0063e13364 Make update cross platform for baud rates (#763)
- Errors should always be an error or null
 - bindings.close doesn't throw with proper args so why are we catching?
 - throw on update if given bad options
 - support and test updating and opening with custom baud rates
2016-05-12 13:03:59 -04:00
Francis Gulotta
cf41ef76bd Update the errors for unix to always include the err string and tests for close (#790) 2016-05-06 23:38:17 -04:00
Francis Gulotta
cf678e6f0b Small Update for windows bindings (#785)
- Error with the provided com port name instead of the mess we use under the hood to talk to the apis
 - update _snprintf calls to _snprintf_s as the former is depreciated 
 - Add a binding test for bad ports
2016-05-05 10:30:50 -04:00
fivdi
cb64745486 Avoid deprecation warnings 2016-05-01 17:43:40 -04:00
Francis Gulotta
7b815fd6a4 Using clang and cpplint lint our c++ as much as I can (#762)
The `src/win/" vendor files are scary
2016-04-24 00:19:35 -04:00
Francis Gulotta
1bd3e06c58 SerialportList updates (#761)
- Errors are now consistent across platforms
 - List is now completely async and promise ready
 - Test the bindings abstraction not the bindings itself
2016-04-23 12:43:31 -04:00
Francis Gulotta
39946c4bc0 Make the output of .list undefined if it’s an empty string (#740)
Add some tests to start defining the bindings.
2016-04-08 11:18:37 -04:00
Francis Gulotta
79ec1789e4 Fixes 100% cpu when serial ports disconnect on windows
- Fix a small memory leak
 - some linting for whitespace and indentation
2016-04-05 23:01:15 -04:00
Paul Kaplan
6d2e4b5fa7 Return after encountering errors in windows write
The unix version breaks the while loop by returning on certain errors.
On Windows, the errors were being contained because the while loop was
never breaking. For example, pulling the USB cable out would raise
“Access Denied” errors but the while loop would run forever and contain
that error.
2016-04-05 23:01:15 -04:00
Francis Gulotta
8365e186c6 Fix double open and times when we don't close file descriptors for unix
- Close the fd if we have any errors during setup
 - Properly receive errors when setting a custom baud rate on OS X
2016-04-05 14:47:43 -04:00
Peter A. Bigot
ac2682319f correct application of hupcl option
HUPCL is a TTY control flag, not an FCNTL flag.  Remove its effect on
open(2), and instead apply it tcsetattr(3).

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2016-04-05 14:47:43 -04:00
Guilherme Francescon
7151eb3fbf Fixes double open() call on unix 2016-04-05 14:47:43 -04:00
Francis Gulotta
0bf2ed2da3 Remove deprecated BuildCommDCB for windows support
- This replaces the removed shortcut methods to build a serial port
object with the non deprecated long form.
- Unit and Smoke tested on windows 10.
- Replaces #550 as that source tree has disappeared.
2016-01-26 12:39:29 -05:00
Kunal Pathak
25d6c18abb Fix heap corruption issue on windows
Fix the heap corruption issue in serialport causing random access violation failures.
2015-11-04 22:16:14 -08:00
Rick Waldron
0eeed4e378 Fix Wtautological-pointer-compare warnings: Dereference pointers to check for emptiness, instead of comparing pointer to != NULL.
Fixes:

```
> serialport@2.0.1 install /Users/rwaldron/clonez/node-serialport
> node-pre-gyp install --fallback-to-build

(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
  CXX(target) Release/obj.target/serialport/src/serialport.o
  CXX(target) Release/obj.target/serialport/src/serialport_unix.o
../src/serialport_unix.cpp:695:20: warning: comparison of array 'device.locationId' not
      equal to a null pointer is always true [-Wtautological-pointer-compare]
        if (device.locationId != NULL) {
            ~~~~~~~^~~~~~~~~~    ~~~~
../src/serialport_unix.cpp:698:20: warning: comparison of array 'device.vendorId' not
      equal to a null pointer is always true [-Wtautological-pointer-compare]
        if (device.vendorId != NULL) {
            ~~~~~~~^~~~~~~~    ~~~~
../src/serialport_unix.cpp:701:20: warning: comparison of array 'device.productId' not
      equal to a null pointer is always true [-Wtautological-pointer-compare]
        if (device.productId != NULL) {
            ~~~~~~~^~~~~~~~~    ~~~~
../src/serialport_unix.cpp:704:20: warning: comparison of array 'device.manufacturer' not
      equal to a null pointer is always true [-Wtautological-pointer-compare]
        if (device.manufacturer != NULL) {
            ~~~~~~~^~~~~~~~~~~~    ~~~~
../src/serialport_unix.cpp:707:20: warning: comparison of array 'device.serialNumber' not
      equal to a null pointer is always true [-Wtautological-pointer-compare]
        if (device.serialNumber != NULL) {
            ~~~~~~~^~~~~~~~~~~~    ~~~~
5 warnings generated.
```
2015-10-20 17:45:45 -04:00
Elijah Insua
d653ac396c code clenaup and release created objects 2015-10-12 18:39:25 -04:00
Elijah Insua
c2e0092875 add support for osx el capitan
It appears as though the registry topology has changed in 10.11.

In order to fix that, this code assumes nothing about the path, but
instead works on the assumption that we can already find the registry
entry as soon as the device is enumerated.  By increasing the bounds
of the search we have a better chance of finding the registry entry
that we are looking for

refs: voodootikigod/node-serialport#552
2015-10-12 18:39:25 -04:00
Cong Liu
866e4153b2 Upgrade to Nan 2.0.0 2015-10-11 22:00:46 +02:00
Chris Williams
8204dc647d Version 1.7.4 2015-05-31 15:27:57 -04:00
Chris Williams
c3250203a5 Merge fix. 2015-05-31 11:45:22 -04:00
Chris Williams
d9f26f36c4 Bug fix. 2015-05-31 11:43:52 -04:00
Thomas Sarlandie
e01b979eee Fix two small C errors that crashed build on mac os 10.10 2015-05-31 13:19:37 +02:00