Skip to content

Commit 338406c

Browse files
committed
some cleanups, proper CI will wait
1 parent b8d105b commit 338406c

21 files changed

Lines changed: 5959 additions & 767 deletions

File tree

.github/workflows/node-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
---
2+
# CI workflow for node projects
13
name: Run Tests
24

35
on:

.github/workflows/npm-publish.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1+
---
2+
# CI/CD for npm packages
13
name: Publish npm package
2-
34
on:
45
push:
56
tags:
67
- '*'
7-
8+
permissions:
9+
id-token: write
10+
contents: read
811
env:
912
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10-
1113
jobs:
1214
build-and-publish:
1315
runs-on: ubuntu-22.04
1416
steps:
15-
- name: Install libgpiod
16-
run: |
17-
sudo apt-get install gpiod libgpiod2 libgpiod-dev libnode-dev -y
18-
19-
- name: Checkout
20-
uses: actions/checkout@v3
21-
22-
- name: Configure Node
23-
uses: actions/setup-node@v3
17+
- run: apt-get install gpiod libgpiod2 libgpiod-dev libnode-dev -y\
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
2420
with:
2521
node-version: '18.x'
2622
registry-url: 'https://registry.npmjs.org'
27-
28-
- name: Publish tag on npm
29-
run: |
23+
- run: |
3024
npm ci
3125
npm run build
32-
npm run test:coverage
33-
npm publish
26+
npm publish --provenance --access public

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,43 @@ the node package will finally enter in 1.x series.
204204
Also see our [changelog][changelog] and [project updates][project-updates] for
205205
details.
206206

207+
## Functionality parity
208+
209+
This is the api parity table:
210+
211+
| Description | Scope | C/C++ | Node |
212+
|----------------------------------------------|---------------|--------------------------------|-----------------------|
213+
| get line's instant value | Miscellaneous | gpiod_ctxless_get_value | getInstantLineValue |
214+
| set line's instant value | Miscellaneous | gpiod_ctxless_set_value | setInstantLineValue |
215+
| get number of lines in a chip | Chip | gpiod_chip_num_lines | getNumberOfLines |
216+
| get chip name | Chip | gpiod_chip_name | getChipName |
217+
| get chip label | Chip | gpiod_chip_label | getChipLabel |
218+
| get line/pin offset number | Line | gpiod_line_offset | getLineOffset |
219+
| get line/pin name | Line | gpiod_line_name | getLineName |
220+
| get line/pin value | Line | gpiod_line_get_value | getValue |
221+
| set line/pin value | Line | gpiod_line_set_value | setValue |
222+
| get line consumer | Line | gpiod_line_consumer | getLineConsumer |
223+
| set line for input (read) | Line | gpiod_line_request_input | requestInputMode |
224+
| set line for input with [flags][input-flags] | Line | gpiod_line_request_input_flags | requestInputModeFlags |
225+
| set line for output (write) | Line | gpiod_line_request_output | requestOutputMode |
226+
| release the line | Line | gpiod_line_release | release |
227+
228+
## Other implementations
229+
230+
Those are other notable libgpiod wrapper implementations:
231+
232+
### Official C++ binding
233+
234+
- https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/bindings/cxx?h=v1.6.x
235+
236+
### Official Python binding
237+
238+
- https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/bindings/python?h=v1.6.x
239+
240+
### Golang binding
241+
242+
### Rust binding
243+
207244
## Contributing
208245

209246
This is open source, i am willing to evaluate PR's :sunglasses:
@@ -222,3 +259,4 @@ This is open source, i am willing to evaluate PR's :sunglasses:
222259
[udev-rules]: https://blog.oless.xyz/post/fedorarpigpio/#udev
223260
[changelog]: docs/CHANGELOG.md
224261
[project-updates]: https://github.com/sombriks/node-libgpiod/discussions/31
262+
[input-flags]: ./lib/line-flags.js

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"-lgpiod"
1818
],
1919
"cflags": [
20-
"-O3", "-DOLD_LIBGPIOD"
20+
"-O3"
2121
],
2222
"lflags": [
2323
"-flto"

docs/CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ Noteworthy changes
99
anymore.
1010
- did a fedora38 virtual machine and to my happy surprise this version has the
1111
gpio-sim kernel module built and offers libgpiod 1.6.4! best of two worlds.
12-
pretty soon to tell if our testsuite will run on github actions, but at least
13-
i can speed up things a little by coding into this vm instead of the smaller,
14-
slower board.
12+
- github CI remains unable to run testsuite sadly, tweaked the yaml script to
13+
use a fedora 38 container but it's just not the same thing.
14+
- on the plus side, thanks to the working gpio-sim on my dev environment i could
15+
finally cover everything already implemented quite fast. time to look at the
16+
issues and missing functions, notably bulk and watch operations.
1517

1618
## 2024-04-20
1719

docs/DEVELOPMENT.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -78,37 +78,6 @@ After compiling we can now load the new kernel module:
7878
# TBD
7979
```
8080

81-
## Functionality parity
82-
83-
This is the api parity table:
84-
85-
| Description | Scope | C/C++ | Node |
86-
|-------------------------------|---------------|--------------------------------|-----------------------|
87-
| get line's instant value | Miscellaneous | gpiod_ctxless_get_value | getInstantLineValue |
88-
| set line's instant value | Miscellaneous | gpiod_ctxless_set_value | setInstantLineValue |
89-
| get number of lines in a chip | Chip | gpiod_chip_num_lines | getNumberOfLines |
90-
| get chip name | Chip | gpiod_chip_name | getChipName |
91-
| get chip label | Chip | gpiod_chip_label | getChipLabel |
92-
| | Line | gpiod_line_offset | getLineOffset |
93-
| | Line | gpiod_line_name | getLineName |
94-
| | Line | gpiod_line_consumer | getLineConsumer |
95-
| | Line | gpiod_line_get_value | getValue |
96-
| | Line | gpiod_line_set_value | setValue |
97-
| | Line | gpiod_line_request_input | requestInputMode |
98-
| | Line | gpiod_line_request_input_flags | requestInputModeFlags |
99-
| | Line | gpiod_line_request_output | requestOutputMode |
100-
| | Line | gpiod_line_release | release |
101-
102-
## Other implementations
103-
104-
Those are other notable libgpiod wrapper implementations to take as reference.
105-
106-
### Official C++ binding
107-
108-
### Official Python binding
109-
110-
### Golang binding
111-
11281
[README]: ../README.md
11382
[gpiod-1.4]: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/log/?h=v1.4.x
11483
[gpiod-1.6]: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/log/?h=v1.6.x

index.d.ts

Lines changed: 63 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,101 @@
1-
declare module "node-libgpiod" {
2-
/**
1+
declare module 'node-libgpiod' {
2+
/**
33
* Chip instances represent GPIO chips (each with a fixed number of
44
* GPIO lines) on the Linux host. The number of GPIO chips depends on
55
* the hardware available.
66
*/
7-
declare class Chip {
8-
/**
7+
declare class Chip {
8+
/**
99
* Constructs a new Chip instance by its chip number.
1010
*
1111
* @param chipNumber the number of the GPIO chip
1212
* @throws error if the chip cannot be opened
1313
*/
14-
constructor(chipNumber: number);
15-
16-
/**
14+
constructor(chipNumber: number);
15+
16+
/**
1717
* Constructs a new Chip instance by its device name or full device path.
1818
*
1919
* @param deviceNameOrPath the device name or full device path of the GPIO chip
2020
* @throws error if the chip cannot be opened
2121
*/
22-
constructor(deviceNameOrPath: string);
23-
24-
/**
22+
constructor(deviceNameOrPath: string);
23+
24+
/**
2525
* Returns the number of GPIO lines available (reserved or not) on the GPIO chip.
2626
*/
27-
getNumberOfLines(): number
28-
29-
/**
27+
getNumberOfLines(): number;
28+
29+
/**
3030
* Returns the GPIO chip name as represented by the kernel.
3131
*/
32-
getChipName(): string
33-
34-
/**
32+
getChipName(): string;
33+
34+
/**
3535
* Returns the GPIO chip label as represented by the kernel.
3636
*/
37-
getChipLabel(): string
38-
}
39-
40-
/**
37+
getChipLabel(): string;
38+
}
39+
40+
/**
4141
* Line instances represent direct access to a specific GPIO line on
4242
* the Linux host. Those lines can be reserved as input or output.
4343
*/
44-
declare class Line {
45-
46-
/**
44+
declare class Line {
45+
/**
4746
* Constructs a new Line instance for the given chip and line offset.
4847
*
4948
* @param chip the parent gpio chip
5049
* @param offset the line offset
5150
* @throws error if the line cannot be opened
5251
*/
53-
constructor(chip: Chip, offset: number);
54-
55-
/**
52+
constructor(chip: Chip, offset: number);
53+
54+
/**
5655
* Returns the line offset of this Line instance for the assigned GPIO chip.
5756
*
5857
* @throws error if the line offset cannot be read
5958
*/
60-
getLineOffset(): number;
61-
62-
/**
59+
getLineOffset(): number;
60+
61+
/**
6362
* Returns the line name as represented by the kernel. The name is either a
6463
* valid string, or undefined if not set.
6564
*
6665
* @throws error if the line name cannot be read
6766
*/
68-
getLineName(): string | undefined;
69-
70-
/**
67+
getLineName(): string | undefined;
68+
69+
/**
7170
* Returns the line consumer as represented by the kernel. This consumer is
7271
* either a valid string, or undefined if not set.
7372
*
7473
* @throws error if the line consumer cannot be read
7574
*/
76-
getLineConsumer(): string | undefined;
77-
78-
/**
75+
getLineConsumer(): string | undefined;
76+
77+
/**
7978
* Returns the state value of the line as off (0) or on (1).
8079
* @throws error if the line is not reserved
8180
*/
82-
getValue(): 0 | 1;
83-
84-
/**
81+
getValue(): 0 | 1;
82+
83+
/**
8584
* Sets the state of the line to either on or off. Setting the same state as
8685
* current, nothing happens.
8786
*
8887
* @param value the new state of the output line (0 = off, 1 = on)
8988
* @throws error if the line is not reserved as an output
9089
*/
91-
setValue(value: 0 | 1): void;
92-
93-
/**
90+
setValue(value: 0 | 1): void;
91+
92+
/**
9493
* Releases a previously created reservation. If the line is not reserved at
9594
* the time of calling this method, nothing happens.
9695
*/
97-
release(): void;
98-
99-
/**
96+
release(): void;
97+
98+
/**
10099
* Reserves the current line as an output. It is possible to pass a defaultValue,
101100
* which defines the base state of the line (off or on). If not given, the default
102101
* state is off.
@@ -107,19 +106,19 @@ declare module "node-libgpiod" {
107106
* @param consumer an optional consumer name to assign to the reservation
108107
* @throws error if the line is already reserved
109108
*/
110-
requestOutputMode(defaultValue?: 0 | 1, consumer?: string): void;
111-
112-
/**
109+
requestOutputMode(defaultValue?: 0 | 1, consumer?: string): void;
110+
111+
/**
113112
* Reserves the current line as an input.
114113
*
115114
* A consumer name can be given to assign a name to the reservation.
116115
*
117116
* @param consumer an optional consumer name to assign to the reservation
118117
* @throws error if the line is already reserved
119118
*/
120-
requestInputMode(consumer?: string): void;
119+
requestInputMode(consumer?: string): void;
121120

122-
/**
121+
/**
123122
* Reserves the current line as an input with Flags.
124123
*
125124
* A consumer name can be given to assign a name to the reservation.
@@ -128,28 +127,27 @@ declare module "node-libgpiod" {
128127
* @param flags GPIOD_LINE_REQUEST_FLAG_xxxx as defined in gpiod.h
129128
* @throws error if the line is already reserved
130129
*/
131-
requestInputModeFlags(consumer?: string, flags?: number): void;
132-
}
133-
130+
requestInputModeFlags(consumer?: string, flags?: number): void;
131+
}
134132

135-
/**
133+
/**
136134
* LineFlags
137-
* Those flags where introduced in libgpiod 1.5 and allows to fine tune how
135+
* Those flags where introduced in libgpiod 1.5 and allows to fine tune how
138136
* line should behave.
139137
*/
140-
declare interface LineFlags {
141-
GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN: 1;
142-
GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE: 2;
143-
GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW: 4;
144-
GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE: 8;
145-
GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN: 16;
146-
GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP: 32;
147-
}
148-
149-
/**
138+
declare type LineFlags = {
139+
GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN: 1;
140+
GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE: 2;
141+
GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW: 4;
142+
GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE: 8;
143+
GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN: 16;
144+
GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP: 32;
145+
};
146+
147+
/**
150148
* Returns true if the libgpiod functionality is available in
151149
* the current execution environment, otherwise false (for example
152150
* in non-Linux development environments).
153151
*/
154-
declare function available(): boolean;
152+
declare function available(): boolean;
155153
}

0 commit comments

Comments
 (0)