Commit graph

89 commits

Author SHA1 Message Date
Azq2
f3174ff804
fix: custom baudrate for OSX & Linux (#186) 2024-12-23 14:51:15 -05:00
Francis Gulotta
cf03d6ddd1
feat: new binding interface (#19)
- We now only return a port object if it's open and list and open methods are now exported on an interface
- hardware tests now work and only require a loopback (no ready event)
- Test pass on darwin (not on mock - it's not up to date yet and coverage is going to drop)
- cleanup up tests with modern javascript
- Breaking - change the names of the exported types
- No more constructors, now all binding specicific open options are specificd on open
- Arduino test file for loopback
2022-01-29 22:51:40 -05:00
Francis Gulotta
095b7c50be
chore: cleanup single package repository 2021-12-29 21:53:13 -05:00
Francis Gulotta
826545bd0a
chore: change to a monorepo structure with Lerna (#1586)
- move from istanbul to nyc and update coverage reporting
- global docs
- global linting
- global tests
2018-07-24 01:15:09 -04:00
Iván Sánchez Ortega
59960a3920 feat(linter): Added 'cc' to lint the C++ code on 'npm lint' (#1501) 2018-02-27 21:41:23 -05:00
Jade Bilkey
910438c2ca feat(linux): Custom baud rates for linux (eg 250k baudrate) (#1464)
* 250k baudrate now works
* Generic linux non-standard baudrate setting using termios2
* Tested successfully with an FTDI usb chip with the tx and rx pins bridged. Previous solution using the B38400 hack returned gibberish in same setup.
* Test for linux and win32 baudrate setting. Darwin stubbed out.

The arbitrary baud interface has been working on darwin up to this point so it's
likely that it works properly. The GetBaudRate extension should still get
written to be thorough but for now, this will let the CI tests pass properly and
still throw a warning about the check being disabled.

That is, of course, if anyone's testing with the arduino hardware on darwin,
otherwise, these tests never run anyway.
2018-02-05 09:33:11 -05:00
kimushu
0e4b1f9fb4 fix(windows): Fix read & write bugs for windows (#1364)
* Fix OVERLAPPED initialization
* Fix buffer overrun for writing and reading
* Remove unsafe memset for non-POD structures
* Fix thread handle leak
2017-10-16 10:10:16 -04:00
Francis Gulotta
4fc1404c8c [all] Unify the serialport.list output (#1266)
- [osx] remove the 0x from productID and locationId and vendorId
- [linux] remove the starting 0x from any values, small refactor
- [linux] Fixup output using the hex encoded fields
- [windows] Grab the serial number from the pnp id
- Isolate list functions to their own platform files (c++)
- Better ensure our serialports fields are present

closes #1220
2017-07-29 19:40:39 -04:00
Francis Gulotta
468dfc29d7 [osx] Return the tty instead of the cu for osx serialports
For the record, tty's are `DialinDevice`s and cu's are `CalloutDevice`s

Thanks to @kishinmanglani for helping me solve this!

The closest we could come to docs. https://opensource.apple.com/source/IOSerialFamily/IOSerialFamily-7/IOSerialFamily.kmodproj/IOSerialKeys.h
2017-07-18 21:14:25 -04:00
Francis Gulotta
9c67ee2a43 [unix] Move setting up the baudrate to the end of the open()
- Test 1000000 baud
2017-07-15 13:06:44 -04:00
Francis Gulotta
2ed7b119d0 Test flushing data
- [unix] small changes to flushing data during port open and setup to prevent bad data
- [all] mock binding flush now works
- cleanup on mock-binding pending reads
- add `serialport-repl` as a bin and npm command
2017-07-09 21:25:02 -04:00
Francis Gulotta
6455ecbb51 [unix] New read/write subsystem (#1212)
This has always been the dream. Use `fs.read` and `fs.write` to do reading and writing. To make that happen I've created a cross platform `Poller` object that notifies us once on `readable` and `writable` states.

- Reduce large write cpu usage from 100% to 1-2%
- Replace ReadPoller with a multi purpose poller because you can only have a single uv_poll_t on a fd at a time because reasons
- Experimented with doing this all in c++, maybe there are gains to doing that but I'd never finish.
- Some unrelated eslint changes
- Arduino echo should just echo, writing random bytes was messing it up
- use a file to disable tests in envs
- read and write errors can trigger disconnects
- disconnect event only happens if there are listeners, otherwise error events will be triggered
- a disconnect during write will always have a write error too
- win32 bindings seem to only trigger disconnects on writes
2017-07-05 09:12:31 -04:00
Francis Gulotta
4984943543 Pull out the c++ write queue (#1198) 2017-06-19 21:13:45 -04:00
Francis Gulotta
adccc6dfde [unix] Correct error messages on .set unix bindings 2016-12-11 18:48:43 -05: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
23de171055 Do error checking when getting modem control flags 2016-10-21 21:35:50 -04:00
jgillick
71a069f447 Add get function and bindings for modem status bits 2016-09-19 09:10:43 -07: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
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
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
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
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
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
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
Pedro Miguel Henriques Pereira
e39b2215a9 Updated master to v1.7.1 [publish binary] 2015-05-22 18:51:54 +01:00
Chris Williams
1343881af6 Version 1.7.1 fixing broken code. 2015-05-09 11:30:42 -04:00
Chris Williams
876cd1e3a4 Merge fix. 2015-05-07 11:03:11 -04:00
Chris Williams
eaa4f0a721 Merge fix. 2015-05-07 11:01:03 -04:00
Jacob Rosenthal
7eba3f8d41 unix support for update baudrate 2015-04-10 16:36:27 -07:00
Jacob Rosenthal
9b33efc8e8 set cloexec after open, possible fix for #468 2015-04-10 16:26:35 -07:00
Jonathan Bendes
3f6c7192cd Added hang up on close option to constructor. 2015-04-06 12:44:32 -04:00
Chris Williams
d06870652f Merge pull request #490 from jacobrosenthal/revert-break
Revert "Add BREAK command, useful for CISCO router to break into rommon"
2015-03-17 13:26:08 -07:00
Jacob Rosenthal
b428c3d940 Revert "Add BREAK command, useful for CISCO router to break into rommon"
This reverts commit f37d1e690d.
2015-03-17 11:11:16 -07:00
Chris Williams
ef3e7afd4d Merge fix. 2015-03-14 21:24:06 -04:00
iangregory
52bdfb573a Fix OpenBSD compatibility issue in serialport_unix.cpp
ioctl() on OpenBSD is defined in <sys/ioctl.h>
2015-03-08 17:17:29 +00:00
Jérôme Marteaux
f37d1e690d Add BREAK command, useful for CISCO router to break into rommon 2015-03-06 15:12:08 +01:00
Jacob Rosenthal
52abeb002f preliminary unix support for break 2015-02-24 06:14:20 -07:00
Chris Williams
a742c97279 Merge branch 'master' of github.com:voodootikigod/node-serialport into develop 2014-12-10 20:04:15 -05:00