考拉悠然三菱mc通信
一、API
1. 创建及初始化连接
``
javascript
const klMcClientProxy = new KlMcClientProxy();
await klMcClientProxy.initClient("127.0.0.1", 6000);
`
2. 关闭连接
`
javascript
klMcClientProxy.close();
`
3. 发送/读取字符串
`
javascript
const str = "klMcClientProxy";
await klMcClientProxy.writeString("D0", str);
const res1 = await klMcClientProxy.readString("D0", str.length);
`
4. 发送数组/读取数组
`
javascript
const arr = [111, 222, 333, 444, 555, 666, 777];
await klMcClientProxy.writeArr("D0", arr);
const res2 = await klMcClientProxy.readArr("D0", 7);
`
5. 发送/读取单个数值
`
javascript
await klMcClientProxy.writeNum("D0", 888);
const res3 = await klMcClientProxy.readNum("D0");
`
二、安装
`
bash
npm install kl-mc
``