mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-25 18:37:19 +00:00
Compare commits
12 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98807a193f | ||
|
|
171de3b99e | ||
|
|
a62456ca5a | ||
|
|
d1e22b4d23 | ||
|
|
9e42a76ad2 | ||
|
|
35ce121781 | ||
|
|
22c1997ba2 | ||
|
|
f15b1f2ffa | ||
|
|
ad35edcab5 | ||
|
|
175d11e402 | ||
|
|
ef4e02e51d | ||
|
|
e00ed66238 |
14 changed files with 15784 additions and 3855 deletions
86
.github/workflows/build.yml
vendored
86
.github/workflows/build.yml
vendored
|
|
@ -1,9 +1,6 @@
|
|||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- beta
|
||||
workflow_dispatch:
|
||||
concurrency:
|
||||
group: build-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
|
@ -16,89 +13,47 @@ jobs:
|
|||
os: macos-latest
|
||||
node: x64
|
||||
command: prebuildify
|
||||
args: --arch x64+arm64
|
||||
|
||||
args: --arch x64+arm64 --target 14.0.0
|
||||
- name: win32-x86
|
||||
os: windows-latest
|
||||
os: windows-2019
|
||||
node: x86
|
||||
command: prebuildify
|
||||
|
||||
args: --target 14.0.0
|
||||
- name: win32-x64
|
||||
os: windows-latest
|
||||
os: windows-2019
|
||||
node: x64
|
||||
command: prebuildify
|
||||
|
||||
args: --target 14.0.0
|
||||
- name: win32-arm64
|
||||
os: windows-latest
|
||||
node: x64
|
||||
os: windows-2019
|
||||
command: prebuildify
|
||||
args: --arch arm64 --tag-armv 8
|
||||
|
||||
args: --arch arm64 --target 20.11.1
|
||||
- name: linux-x64
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i almalinux-devtoolset11 --tag-libc --libc glibc
|
||||
|
||||
- name: linux-x64-musl
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
# already has --tag-libc --libc musl
|
||||
args: -i alpine
|
||||
|
||||
- name: linux-arm64
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i linux-arm64 --tag-libc --libc glibc
|
||||
|
||||
- name: linux-arm64-musl
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i linux-arm64-musl --tag-libc --libc musl
|
||||
|
||||
args: -i centos7-devtoolset7 -i alpine --target 14.0.0
|
||||
- name: linux-arm
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i linux-armv7 -i linux-armv6 --tag-libc --libc glibc
|
||||
|
||||
- name: linux-arm-musl
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i linux-armv7l-musl --tag-libc --libc musl
|
||||
|
||||
args: -i linux-arm64-lts -i linux-armv7 -i linux-armv7l-musl -i linux-armv6 --target 14.0.0
|
||||
- name: android-arm
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i android-armv7
|
||||
|
||||
- name: android-arm64
|
||||
os: ubuntu-latest
|
||||
node: x64
|
||||
command: prebuildify-cross
|
||||
args: -i android-arm64
|
||||
|
||||
args: -i android-arm64 -i android-armv7 --target 14.0.0
|
||||
name: Build ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.13'
|
||||
- uses: actions/setup-node@v4
|
||||
- if: matrix.node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
architecture: ${{ matrix.node }}
|
||||
- uses: actions/checkout@v4
|
||||
- run: npm ci
|
||||
- run: npm run ${{ matrix.command }} -- ${{ matrix.args }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-artifacts-${{ matrix.name }}
|
||||
name: build-artifacts
|
||||
path: prebuilds/
|
||||
if-no-files-found: error
|
||||
- if: failure()
|
||||
|
|
@ -107,12 +62,15 @@ jobs:
|
|||
needs: prebuild
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
pattern: build-artifacts-*
|
||||
merge-multiple: true
|
||||
name: build-artifacts
|
||||
path: prebuilds
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
|
|
@ -121,5 +79,5 @@ jobs:
|
|||
- run: npm run build
|
||||
- run: npm run semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
|||
5
.github/workflows/test.yml
vendored
5
.github/workflows/test.yml
vendored
|
|
@ -1,7 +1,6 @@
|
|||
name: Test / Lint
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
|
@ -12,7 +11,7 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 18.x
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
- run: npm run typecheck
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
20.18.1
|
||||
20.18.0
|
||||
|
|
@ -13,10 +13,12 @@
|
|||
[
|
||||
"@semantic-release/github",
|
||||
{
|
||||
"successComment": false,
|
||||
"failComment": false,
|
||||
"assets": [
|
||||
{
|
||||
"path": "prebuilds-*.tar.gz",
|
||||
"label": "Binary modules (from npm @serialport/bindings-cpp)"
|
||||
"label": "Binary modules (from npm @sie-js/node-serialport-bindings-cpp)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# @serialport/bindings-cpp
|
||||
# @sie-js/node-serialport-bindings-cpp (fork with custom baudrate fix)
|
||||
|
||||
[](#backers)
|
||||
[](#sponsors)
|
||||
|
|
@ -13,14 +13,14 @@ Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your roboti
|
|||
|
||||
- 📚 [**Guides**](https://serialport.io/docs/)
|
||||
- [**API Docs**](https://serialport.io/docs/api-serialport)
|
||||
- [`@serialport/bindings-cpp`](https://www.npmjs.com/package/@serialport/bindings-cpp)
|
||||
- [`@sie-js/node-serialport-bindings-cpp`](https://www.npmjs.com/package/@sie-js/node-serialport-bindings-cpp)
|
||||
- 🐛 [Help and Bugs](https://github.com/serialport/node-serialport/issues/new/choose) All serialport issues are pointed to the main serialport repo.
|
||||
|
||||
### Bindings
|
||||
|
||||
The Bindings provide a low level interface to work with your serialport. It is possible to use them alone but it's usually easier to use them with an interface.
|
||||
|
||||
- [`@serialport/bindings-cpp`](https://serialport.io/docs/api-bindings-cpp) bindings for Linux, Mac and Windows
|
||||
- [`@sie-js/node-serialport-bindings-cpp`](https://serialport.io/docs/api-bindings-cpp) bindings for Linux, Mac and Windows
|
||||
- [`@serialport/binding-interface`](https://serialport.io/docs/api-bindings-interface) as an interface to use if you're making your own bindings
|
||||
- [`@serialport/binding-mock`](https://serialport.io/docs/api-binding-mock) for a mock binding package for testing
|
||||
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ function testBinding(bindingName: string, Binding: BindingInterface, testPort?:
|
|||
const port = await Binding.open(options)
|
||||
const readError = shouldReject(port.read(Buffer.alloc(100), 0, 100))
|
||||
await port.close()
|
||||
const err = await readError as BindingsError
|
||||
const err: BindingsError = await readError
|
||||
assert.isTrue(err.canceled)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import nodeGypBuild from 'node-gyp-build'
|
||||
import { promisify } from 'util'
|
||||
import { binding } from './serialport-bindings'
|
||||
import { join } from 'path'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const binding = nodeGypBuild(join(__dirname, '../')) as any
|
||||
|
||||
export const asyncClose = binding.close ? promisify(binding.close) : async () => { throw new Error('"binding.close" Method not implemented')}
|
||||
export const asyncDrain = binding.drain ? promisify(binding.drain) : async () => { throw new Error('"binding.drain" Method not implemented')}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import debug from 'debug'
|
||||
import { EventEmitter } from 'events'
|
||||
import { join } from 'path'
|
||||
import nodeGypBuild from 'node-gyp-build'
|
||||
import { BindingsError } from './errors'
|
||||
import { binding } from './serialport-bindings'
|
||||
|
||||
const { Poller: PollerBindings } = binding as { Poller: PollerClass }
|
||||
const { Poller: PollerBindings } = nodeGypBuild(join(__dirname, '../')) as { Poller: PollerClass }
|
||||
const logger = debug('serialport/bindings-cpp/poller')
|
||||
|
||||
interface PollerClass {
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
import { join } from 'path'
|
||||
import nodeGypBuild from 'node-gyp-build'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const binding = nodeGypBuild(join(__dirname, '../')) as any
|
||||
|
|
@ -99,13 +99,13 @@ describe('unixRead', () => {
|
|||
(mock as any).isOpen = false
|
||||
makeFsReadError('EAGAIN')()
|
||||
}
|
||||
const err = await shouldReject(unixRead({ binding: mock, buffer: readBuffer, offset: 0, length: 8, fsReadAsync })) as BindingsError
|
||||
const err: BindingsError = await shouldReject(unixRead({ binding: mock, buffer: readBuffer, offset: 0, length: 8, fsReadAsync }))
|
||||
assert.isTrue(err.canceled)
|
||||
})
|
||||
it('rejects a disconnected error when fsread errors a disconnect error', async () => {
|
||||
const readBuffer = Buffer.alloc(8, 0)
|
||||
const fsReadAsync = makeFsReadError('EBADF')
|
||||
const err = await shouldReject(unixRead({ binding: mock, buffer: readBuffer, offset: 0, length: 8, fsReadAsync })) as Error & {disconnect: boolean}
|
||||
const err = await shouldReject(unixRead({ binding: mock, buffer: readBuffer, offset: 0, length: 8, fsReadAsync }))
|
||||
assert.isTrue(err.disconnect)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ describe('unixWrite', () => {
|
|||
it('rejects a disconnect error when fswrite errors a disconnect error', async () => {
|
||||
const writeBuffer = Buffer.alloc(8, 0)
|
||||
const fsWriteAsync = makeFsWriteError('EBADF')
|
||||
const err = await shouldReject(unixWrite({ binding: mock, buffer: writeBuffer, fsWriteAsync })) as Error & {disconnect: boolean}
|
||||
const err = await shouldReject(unixWrite({ binding: mock, buffer: writeBuffer, fsWriteAsync }))
|
||||
assert.isTrue(err.disconnect)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
19464
package-lock.json
generated
19464
package-lock.json
generated
File diff suppressed because it is too large
Load diff
40
package.json
40
package.json
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@serialport/bindings-cpp",
|
||||
"name": "@sie-js/node-serialport-bindings-cpp",
|
||||
"description": "SerialPort Hardware bindings for node serialport written in c++",
|
||||
"version": "0.0.0-development",
|
||||
"main": "./dist/index.js",
|
||||
|
|
@ -19,37 +19,37 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"@serialport/bindings-interface": "1.2.2",
|
||||
"@serialport/parser-readline": "13.0.0",
|
||||
"debug": "4.4.0",
|
||||
"node-addon-api": "8.3.0",
|
||||
"node-gyp-build": "4.8.4"
|
||||
"@serialport/parser-readline": "12.0.0",
|
||||
"debug": "4.3.7",
|
||||
"node-addon-api": "8.2.1",
|
||||
"node-gyp-build": "4.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/exec": "6.0.3",
|
||||
"@serialport/binding-mock": "10.2.2",
|
||||
"@types/chai": "5.0.1",
|
||||
"@types/chai-subset": "1.3.6",
|
||||
"@types/chai": "4.3.9",
|
||||
"@types/chai-subset": "1.3.5",
|
||||
"@types/debug": "4.1.12",
|
||||
"@types/mocha": "10.0.10",
|
||||
"@types/node": "22.19.1",
|
||||
"@types/mocha": "10.0.9",
|
||||
"@types/node": "22.8.2",
|
||||
"@typescript-eslint/eslint-plugin": "6.21.0",
|
||||
"@typescript-eslint/parser": "6.21.0",
|
||||
"cc": "3.0.1",
|
||||
"chai": "6.2.1",
|
||||
"chai": "4.3.10",
|
||||
"chai-subset": "1.6.0",
|
||||
"esbuild": "0.27.1",
|
||||
"esbuild": "0.24.0",
|
||||
"esbuild-register": "3.6.0",
|
||||
"eslint": "8.57.1",
|
||||
"mocha": "11.7.5",
|
||||
"mocha": "10.8.2",
|
||||
"node-abi": "3.71.0",
|
||||
"node-gyp": "11.0.0",
|
||||
"node-gyp": "^10.1.0",
|
||||
"nyc": "17.1.0",
|
||||
"prebuildify": "6.0.1",
|
||||
"prebuildify-cross": "5.1.1",
|
||||
"semantic-release": "24.2.0",
|
||||
"semantic-release": "21.1.0",
|
||||
"shx": "0.3.4",
|
||||
"sinon": "21.0.0",
|
||||
"typescript": "5.7.2"
|
||||
"sinon": "19.0.2",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
|
@ -57,8 +57,8 @@
|
|||
"scripts": {
|
||||
"build": "rm -rf dist && tsc -p tsconfig-build.json",
|
||||
"install": "node-gyp-build",
|
||||
"prebuildify": "prebuildify --napi --target 20.0.0 --force --strip --verbose",
|
||||
"prebuildify-cross": "prebuildify-cross --napi --target 20.0.0 --force --strip --verbose",
|
||||
"prebuildify": "prebuildify --napi --force --strip --verbose",
|
||||
"prebuildify-cross": "prebuildify-cross --napi --force --strip --verbose",
|
||||
"rebuild": "node-gyp rebuild",
|
||||
"format": "eslint lib test bin --fix",
|
||||
"lint": "eslint lib test bin && cc --verbose",
|
||||
|
|
@ -86,12 +86,12 @@
|
|||
},
|
||||
"binary": {
|
||||
"napi_versions": [
|
||||
8
|
||||
6
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/serialport/bindings-cpp.git"
|
||||
"url": "https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git"
|
||||
},
|
||||
"funding": "https://opencollective.com/serialport/donate",
|
||||
"changelog": {
|
||||
|
|
|
|||
|
|
@ -453,11 +453,6 @@ void __stdcall ReadIOCompletion(DWORD errorCode, DWORD bytesTransferred, OVERLAP
|
|||
baton->bytesRead += bytesTransferred;
|
||||
baton->offset += bytesTransferred;
|
||||
}
|
||||
if (!baton->bytesToRead) {
|
||||
baton->complete = true;
|
||||
CloseHandle(ov->hEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
// ReadFileEx and GetOverlappedResult retrieved only 1 byte. Read any additional data in the input
|
||||
// buffer. Set the timeout to MAXDWORD in order to disable timeouts, so the read operation will
|
||||
|
|
@ -468,7 +463,6 @@ void __stdcall ReadIOCompletion(DWORD errorCode, DWORD bytesTransferred, OVERLAP
|
|||
lastError = GetLastError();
|
||||
ErrorCodeToString("Setting COM timeout (SetCommTimeouts)", lastError, baton->errorString);
|
||||
baton->complete = true;
|
||||
// CloseHandle(ov->hEvent); // wondering if we need to close the handle here
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -496,11 +490,11 @@ void __stdcall ReadIOCompletion(DWORD errorCode, DWORD bytesTransferred, OVERLAP
|
|||
return;
|
||||
}
|
||||
}
|
||||
CloseHandle(ov->hEvent);
|
||||
|
||||
baton->bytesToRead -= bytesTransferred;
|
||||
baton->bytesRead += bytesTransferred;
|
||||
baton->complete = true;
|
||||
CloseHandle(ov->hEvent);
|
||||
}
|
||||
|
||||
DWORD __stdcall ReadThread(LPVOID param) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue