@digipair/skill-serialport 0.133.0 → 0.133.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +4 -4
- package/dist/index.esm.js +4 -4
- package/dist/schema.fr.json +24 -7
- package/dist/schema.json +21 -0
- package/dist/src/lib/skill-serialport.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ let SerialPortService = class SerialPortService {
|
|
|
6
6
|
sleep(ms) {
|
|
7
7
|
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
8
8
|
}
|
|
9
|
-
async read(ser, timeout) {
|
|
9
|
+
async read(ser, timeout, type, value) {
|
|
10
10
|
return new Promise((resolve)=>{
|
|
11
11
|
const buffer = [];
|
|
12
12
|
const instance = setTimeout(()=>{
|
|
@@ -17,7 +17,7 @@ let SerialPortService = class SerialPortService {
|
|
|
17
17
|
for (const byte of chunk){
|
|
18
18
|
buffer.push(byte);
|
|
19
19
|
}
|
|
20
|
-
if (buffer.length >=
|
|
20
|
+
if (type === 'size' && buffer.length >= value) {
|
|
21
21
|
clearTimeout(instance);
|
|
22
22
|
ser.removeListener('data', onData);
|
|
23
23
|
resolve(buffer);
|
|
@@ -27,7 +27,7 @@ let SerialPortService = class SerialPortService {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
async command(params, _pinsSettingsList, context) {
|
|
30
|
-
const { data, sleep = 1000, timeout = 3000, config = context.privates.SERIALPORT_CONFIG } = params;
|
|
30
|
+
const { data, type = 'delimiter', value = '\n'.charCodeAt(0), sleep = 1000, timeout = 3000, config = context.privates.SERIALPORT_CONFIG } = params;
|
|
31
31
|
const command = Buffer.from(data);
|
|
32
32
|
return new Promise((resolve, reject)=>{
|
|
33
33
|
const ser = new serialport.SerialPort(config);
|
|
@@ -37,7 +37,7 @@ let SerialPortService = class SerialPortService {
|
|
|
37
37
|
ser.on('open', async ()=>{
|
|
38
38
|
await ser.write(command);
|
|
39
39
|
await this.sleep(sleep);
|
|
40
|
-
const reponse = await this.read(ser, timeout);
|
|
40
|
+
const reponse = await this.read(ser, timeout, type, value);
|
|
41
41
|
ser.close();
|
|
42
42
|
resolve(reponse);
|
|
43
43
|
});
|
package/dist/index.esm.js
CHANGED
|
@@ -10091,7 +10091,7 @@ let SerialPortService = class SerialPortService {
|
|
|
10091
10091
|
sleep(ms) {
|
|
10092
10092
|
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
10093
10093
|
}
|
|
10094
|
-
async read(ser, timeout) {
|
|
10094
|
+
async read(ser, timeout, type, value) {
|
|
10095
10095
|
return new Promise((resolve)=>{
|
|
10096
10096
|
const buffer = [];
|
|
10097
10097
|
const instance = setTimeout(()=>{
|
|
@@ -10102,7 +10102,7 @@ let SerialPortService = class SerialPortService {
|
|
|
10102
10102
|
for (const byte of chunk){
|
|
10103
10103
|
buffer.push(byte);
|
|
10104
10104
|
}
|
|
10105
|
-
if (buffer.length >=
|
|
10105
|
+
if (type === 'size' && buffer.length >= value) {
|
|
10106
10106
|
clearTimeout(instance);
|
|
10107
10107
|
ser.removeListener('data', onData);
|
|
10108
10108
|
resolve(buffer);
|
|
@@ -10112,7 +10112,7 @@ let SerialPortService = class SerialPortService {
|
|
|
10112
10112
|
});
|
|
10113
10113
|
}
|
|
10114
10114
|
async command(params, _pinsSettingsList, context) {
|
|
10115
|
-
const { data, sleep = 1000, timeout = 3000, config = context.privates.SERIALPORT_CONFIG } = params;
|
|
10115
|
+
const { data, type = 'delimiter', value = '\n'.charCodeAt(0), sleep = 1000, timeout = 3000, config = context.privates.SERIALPORT_CONFIG } = params;
|
|
10116
10116
|
const command = Buffer.from(data);
|
|
10117
10117
|
return new Promise((resolve, reject)=>{
|
|
10118
10118
|
const ser = new dist$g.SerialPort(config);
|
|
@@ -10122,7 +10122,7 @@ let SerialPortService = class SerialPortService {
|
|
|
10122
10122
|
ser.on('open', async ()=>{
|
|
10123
10123
|
await ser.write(command);
|
|
10124
10124
|
await this.sleep(sleep);
|
|
10125
|
-
const reponse = await this.read(ser, timeout);
|
|
10125
|
+
const reponse = await this.read(ser, timeout, type, value);
|
|
10126
10126
|
ser.close();
|
|
10127
10127
|
resolve(reponse);
|
|
10128
10128
|
});
|
package/dist/schema.fr.json
CHANGED
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
"paths": {
|
|
11
11
|
"/write": {
|
|
12
12
|
"post": {
|
|
13
|
-
"tags": [
|
|
14
|
-
"service"
|
|
15
|
-
],
|
|
13
|
+
"tags": ["service"],
|
|
16
14
|
"summary": "Écrire des données",
|
|
17
15
|
"description": "Écrire des données sur un port série sans attendre de réponse",
|
|
18
16
|
"parameters": [
|
|
@@ -66,9 +64,7 @@
|
|
|
66
64
|
},
|
|
67
65
|
"/command": {
|
|
68
66
|
"post": {
|
|
69
|
-
"tags": [
|
|
70
|
-
"service"
|
|
71
|
-
],
|
|
67
|
+
"tags": ["service"],
|
|
72
68
|
"summary": "Envoyer une commande",
|
|
73
69
|
"description": "Envoyer une commande à un appareil sur port série et attendre une réponse",
|
|
74
70
|
"parameters": [
|
|
@@ -84,6 +80,27 @@
|
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
82
|
},
|
|
83
|
+
{
|
|
84
|
+
"name": "type",
|
|
85
|
+
"summary": "Type de lecture",
|
|
86
|
+
"required": false,
|
|
87
|
+
"description": "Méthode pour déterminer la fin de la réponse (par défaut: 'delimiter')",
|
|
88
|
+
"schema": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"enum": ["size", "delimiter"],
|
|
91
|
+
"default": "delimiter"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "value",
|
|
96
|
+
"summary": "Valeur de lecture",
|
|
97
|
+
"required": false,
|
|
98
|
+
"description": "Valeur associée au type de lecture (taille en octets pour 'size' ou délimiteur en code ASCII pour 'delimiter', par défaut: '\\n')",
|
|
99
|
+
"schema": {
|
|
100
|
+
"type": "number",
|
|
101
|
+
"default": 10
|
|
102
|
+
}
|
|
103
|
+
},
|
|
87
104
|
{
|
|
88
105
|
"name": "sleep",
|
|
89
106
|
"summary": "Durée d'attente",
|
|
@@ -137,4 +154,4 @@
|
|
|
137
154
|
"components": {
|
|
138
155
|
"schemas": {}
|
|
139
156
|
}
|
|
140
|
-
}
|
|
157
|
+
}
|
package/dist/schema.json
CHANGED
|
@@ -84,6 +84,27 @@
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
+
{
|
|
88
|
+
"name": "type",
|
|
89
|
+
"summary": "Read Type",
|
|
90
|
+
"required": false,
|
|
91
|
+
"description": "Type of read operation to determine end of response (default: 'delimiter')",
|
|
92
|
+
"schema": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"enum": ["size", "delimiter"],
|
|
95
|
+
"default": "delimiter"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "value",
|
|
100
|
+
"summary": "Read Value",
|
|
101
|
+
"required": false,
|
|
102
|
+
"description": "Value associated with the read type (number of bytes to read for 'size' or ASCII code of delimiter for 'delimiter', default: 10 for '\\n')",
|
|
103
|
+
"schema": {
|
|
104
|
+
"type": "number",
|
|
105
|
+
"default": 10
|
|
106
|
+
}
|
|
107
|
+
},
|
|
87
108
|
{
|
|
88
109
|
"name": "sleep",
|
|
89
110
|
"summary": "Sleep Duration",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-serialport.d.ts","sourceRoot":"","sources":["../../../src/lib/skill-serialport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"skill-serialport.d.ts","sourceRoot":"","sources":["../../../src/lib/skill-serialport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiGhD,eAAO,MAAM,KAAK,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,qBACf,CAAC;AAEnE,eAAO,MAAM,OAAO,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,qBACf,CAAC"}
|