feat: v1.0.0 收尾 — 五芯片 DTR/RTS、类型声明、示例、CI
test / test (push) Canceled after 0s

- CP210x / FTDI / PL2303 补齐 setSignals()(编码与各自初始化序列一致)
- 新增 index.d.ts(TypeScript 类型声明)、examples/minimal.html(最小接入示例)
- 新增 .gitea/workflows/ci.yml(push 时跑离线单测)、.gitattributes(强制 LF)、CHANGELOG.md
- package.json 补 repository / homepage / bugs / types / engines
- 单测 16 项全部通过:node test/driver.test.mjs
This commit is contained in:
2026-09-23 00:41:29 +08:00
parent f02c0b06b8
commit 6c5e647c8a
9 changed files with 271 additions and 10 deletions
+16
View File
@@ -268,6 +268,11 @@
await req(0x07, 0x0302);
log('driver', 'CP210x 初始化完成 @' + opts.baudRate + ' bps');
},
/** SET_MHS(0x07):高字节=掩码,低字节=电平;0x03 掩码表示"两条线都由本调用决定" */
setSignals: async function (ctx, sig) {
var bits = (sig.dataTerminalReady ? 0x01 : 0) | (sig.requestToSend ? 0x02 : 0);
await ctx.controlOut('vendor', 'interface', 0x07, 0x0300 | bits, ctx.layout.controlInterface);
},
shutdown: async function (ctx) {
var ci = ctx.layout.controlInterface;
await ctx.controlOut('vendor', 'interface', 0x12, 0x000f, ci);
@@ -342,6 +347,12 @@
await req(0x01, 0x0202);
log('driver', 'FTDI 初始化完成 @' + opts.baudRate + ' bps');
},
/** SET_MODEM_CTRL(0x01):高字节=掩码,低字节=电平(0x01 DTR / 0x02 RTS) */
setSignals: async function (ctx, sig) {
var idx = ctx.layout.controlInterface + 1;
var bits = (sig.dataTerminalReady ? 0x01 : 0) | (sig.requestToSend ? 0x02 : 0);
await ctx.controlOut('vendor', 'device', 0x01, 0x0300 | bits, idx);
},
shutdown: async function (ctx) {
var idx = ctx.layout.controlInterface + 1;
await ctx.controlOut('vendor', 'device', 0x00, 0x0001, idx);
@@ -411,6 +422,11 @@
await ctx.controlOut('class', 'interface', 0x22, 0x0003, 0x0000);
log('driver', 'PL2303 初始化完成 (' + type + ') @' + opts.baudRate + ' bps');
},
/** 标准 CDC 请求 SET_CONTROL_LINE_STATE(0x22):bit0=DTR, bit1=RTS */
setSignals: async function (ctx, sig) {
var bits = (sig.dataTerminalReady ? 0x01 : 0) | (sig.requestToSend ? 0x02 : 0);
await ctx.controlOut('class', 'interface', 0x22, bits, 0x0000);
},
shutdown: async function (ctx) {
var type = ctx.pl2303Type;
if (!type) return;