skyeye-sdk-js 1.3.6 → 1.3.9

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.
@@ -54,6 +54,7 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
54
54
  getCpuRegistersDefault(): Promise<GetCpuRegisterInfoResponse>;
55
55
  setCpuRegisterValueDefault(register: Register, value: string): Promise<any>;
56
56
  setCpuRegisterValue(boardName: string, cpuName: string, registerName: string, value: string): Promise<any>;
57
+ setDeviceRegisterValue(machName: string, deviceName: string, registerName: string, value: string): Promise<any>;
57
58
  getDeviceTree(): Promise<GetDeviceTreeResponse>;
58
59
  getCurrentRunningState(): Promise<GetRunningStateResponse>;
59
60
  getAllDeviceInfo(): Promise<GetAllDeviceInfoResponse>;
@@ -147,8 +147,8 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
147
147
  return ackObj;
148
148
  }
149
149
  catch (error) {
150
- console.error("Error during gRPC request:", JSON.stringify(request));
151
- console.error("Error during gRPC call:", error);
150
+ // console.error("Error during gRPC request:", JSON.stringify(request));
151
+ // console.error("Error during gRPC call:", error);
152
152
  throw error;
153
153
  }
154
154
  });
@@ -660,6 +660,27 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
660
660
  }
661
661
  });
662
662
  }
663
+ setDeviceRegisterValue(machName, deviceName, registerName, value) {
664
+ return __awaiter(this, void 0, void 0, function* () {
665
+ const deviceTree = yield this.getDeviceTree();
666
+ const boardMap = deviceTree.boardMap;
667
+ if (!deviceTree.boardMap.has(machName)) {
668
+ throw new SkyEyeSDKException_1.SkyEyeSDKException("未能找到该板卡");
669
+ }
670
+ // const board: Board = boardMap.get(machName);
671
+ // const deviceMap = board.deviceMap
672
+ // if (!deviceMap.has(deviceName) || deviceMap.get(deviceName) instanceof Cpu) {
673
+ // throw new SkyEyeSDKException("未能找到该设备");
674
+ // }
675
+ // const device = deviceMap.get(deviceName);
676
+ try {
677
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().setRegisterValue(machName, deviceName, registerName, value));
678
+ }
679
+ catch (e) {
680
+ console.log("error during setDeviceRegisterValue:", e);
681
+ }
682
+ });
683
+ }
663
684
  getDeviceTree() {
664
685
  return __awaiter(this, void 0, void 0, function* () {
665
686
  const state = (yield this.getCurrentRunningState()).getState();
@@ -711,7 +732,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
711
732
  // }
712
733
  }
713
734
  catch (error) {
714
- console.error("Error during getCurrentRunningState:", error);
735
+ // console.error("Error during getCurrentRunningState:", error);
715
736
  // throw error;
716
737
  }
717
738
  return response;
package/dist/test.js CHANGED
@@ -242,12 +242,109 @@ function getRegisterMap(bean, allRegister) {
242
242
  function setRegister() {
243
243
  return __awaiter(this, void 0, void 0, function* () {
244
244
  const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
245
- const result = yield client.setCpuRegisterValue('c6713_0', 'c67x_core_0', 'FADCR_REG', '3');
245
+ const r2 = yield client.setDeviceRegisterValue('c6713_0', 'c67x_core_0', 'A7', '34');
246
+ console.log("setRegister:", r2);
247
+ });
248
+ }
249
+ function getRegister() {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
252
+ const result = yield client.getCpuRegisters("");
246
253
  console.log("setRegister:", result);
247
254
  });
248
255
  }
249
- // getAllRegisterList()
250
- setRegister();
256
+ function getState() {
257
+ return __awaiter(this, void 0, void 0, function* () {
258
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.2', '50051');
259
+ const result = yield client.getCurrentRunningState();
260
+ console.log("getState:", result);
261
+ });
262
+ }
263
+ // getState()
264
+ function setMemoryValue() {
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
267
+ const result = yield client.setMemoryValue('c67x_core_0', '10000', '15', 2);
268
+ console.log("setMemoryValue:", result);
269
+ });
270
+ }
271
+ // setMemoryValue()
272
+ function getMemoryValue() {
273
+ return __awaiter(this, void 0, void 0, function* () {
274
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
275
+ const result = yield client.getMemoryValue('c67x_core_0', "10000", 2);
276
+ console.log("setMemoryValue:", result);
277
+ });
278
+ }
279
+ // getMemoryValue()
280
+ function testSocket() {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const json = {
283
+ "msgId": "0",
284
+ "msgTime": "2023-12-5 12:00:00",
285
+ "msgType": "2",
286
+ "msgData": {
287
+ "version": "10001",
288
+ "protocol": "0",
289
+ "direction": "0",
290
+ "bigEndian": "0",
291
+ "length": "0",
292
+ "data": "0"
293
+ }
294
+ };
295
+ const net = require('net');
296
+ const client = new net.Socket();
297
+ const host = '127.0.0.1';
298
+ const port = 8099;
299
+ client.connect(port, host, () => {
300
+ console.log('Connected');
301
+ // const str = JSON.stringify(json)
302
+ // // const str = "hhh"
303
+ // const strBuffer = Buffer.from(str, 'utf8'); // 将字符串转换为 Buffer
304
+ // const strLength = strBuffer.length; // 获取 JSON 数据的长度
305
+ // // 创建一个新的 Buffer 用于存储长度信息和数据
306
+ // const totalLength = 4 + strLength; // 4 字节长度 + 数据长度
307
+ // const buffer = Buffer.alloc(totalLength);
308
+ // // 写入前 4 个字节的长度信息
309
+ // buffer.writeUInt32LE(strLength, 0); // 以小端序方式写入 JSON 数据的长度
310
+ // // 将 JSON 数据复制到 Buffer 中
311
+ // strBuffer.copy(buffer, 4); // 从第 5 个字节开始复制 JSON 数据
312
+ // console.log("Buffer sent:", buffer);
313
+ // console.log("String Length:", strLength); // 打印实际的字符串长度
314
+ // console.log("Hex Length:", strLength.toString(16)); // 打印十六进制表示
315
+ // client.write(buffer); // 发送拼接后的 Buffer
316
+ // 发送数据
317
+ //第一阶段0827测试
318
+ // const hexString = "B90000007B0A09226D73674964223A2230222C0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0A09226D736754797065223A2232222C0A09226D736744617461223A7B0A09092276657273696F6E223A2231222C0A09092270726F746F636F6C223A2230222C0A090922646972656374696F6E223A2230222C0A090922626967456E6469616E223A2230222C0A0909226C656E677468223A2230222C0A09092264617461223A2230220A097D0A7D0A";
319
+ const s1 = "12 01 AA 11 BB 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 33 33 00 00 00 00 00 00 00 00 44 44 00 00 00 00 00 00 88 88 66 44 00 00 00 00 00 00 00 00 00 00 65 76";
320
+ const s1_1 = s1.replace(/\s+/g, '');
321
+ const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A36340D0A097D0D0A7D" + s1_1;
322
+ //74
323
+ // const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A37340D0A097D0D0A7D1201AA11BB220000000000000000000000000000FFFF000000003333000000000000000044440000000000008888664400000000000000000000006576";
324
+ console.log("hexString:", hexString);
325
+ console.log("hexString:", hexString.length);
326
+ const buffer2 = Buffer.from(hexString, 'hex');
327
+ console.log("buffer2:", buffer2.length);
328
+ client.write(buffer2);
329
+ });
330
+ client.on('data', (data) => {
331
+ console.log('Received: ' + data);
332
+ client.destroy();
333
+ });
334
+ client.on('close', () => {
335
+ console.log('Connection closed');
336
+ });
337
+ });
338
+ }
339
+ testSocket();
340
+ function testgetGlobalVarValue() {
341
+ return __awaiter(this, void 0, void 0, function* () {
342
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50052');
343
+ const response = yield client.getGlobalVarValue("cx53123", "a", 16, "double");
344
+ console.log("testgetGlobalVarValue response:", response);
345
+ });
346
+ }
347
+ // testgetGlobalVarValue()
251
348
  function test() {
252
349
  return __awaiter(this, void 0, void 0, function* () {
253
350
  // console.log("Connected to SkyEye server");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.3.6",
3
+ "version": "1.3.9",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,6 @@
27
27
  "google-protobuf": "^3.21.2",
28
28
  "lodash": "^4.6.1",
29
29
  "minimist": "^1.2.0",
30
- "protobufjs": "^7.2.6",
31
- "skyeye-sdk-js": "^1.3.2"
30
+ "protobufjs": "^7.2.6"
32
31
  }
33
32
  }
Binary file
Binary file
Binary file
Binary file
@@ -110,8 +110,8 @@ export class SkyEyeClient extends JSONTransmissionClient {
110
110
  // this.printResponseLog(ackObj)
111
111
  return ackObj;
112
112
  } catch (error) {
113
- console.error("Error during gRPC request:", JSON.stringify(request));
114
- console.error("Error during gRPC call:", error);
113
+ // console.error("Error during gRPC request:", JSON.stringify(request));
114
+ // console.error("Error during gRPC call:", error);
115
115
  throw error;
116
116
  }
117
117
  }
@@ -590,6 +590,31 @@ export class SkyEyeClient extends JSONTransmissionClient {
590
590
  }
591
591
 
592
592
 
593
+ public async setDeviceRegisterValue(machName: string, deviceName: string, registerName: string, value: string) {
594
+ const deviceTree = await this.getDeviceTree();
595
+ const boardMap = deviceTree.boardMap
596
+ if (!deviceTree.boardMap.has(machName)) {
597
+ throw new SkyEyeSDKException("未能找到该板卡");
598
+ }
599
+
600
+ // const board: Board = boardMap.get(machName);
601
+ // const deviceMap = board.deviceMap
602
+ // if (!deviceMap.has(deviceName) || deviceMap.get(deviceName) instanceof Cpu) {
603
+ // throw new SkyEyeSDKException("未能找到该设备");
604
+ // }
605
+
606
+ // const device = deviceMap.get(deviceName);
607
+ try {
608
+ return await this.call(RequestFactory.getInstance().setRegisterValue(machName, deviceName, registerName, value))
609
+ } catch (e) {
610
+ console.log("error during setDeviceRegisterValue:", e)
611
+ }
612
+ }
613
+
614
+
615
+
616
+
617
+
593
618
  public async getDeviceTree() {
594
619
  const state = (await this.getCurrentRunningState()).getState();
595
620
  if (StateState.UNLOADED === state || StateState.QUITED === state) {
@@ -638,7 +663,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
638
663
  // throw new SkyEyeSDKException(String(call.error));
639
664
  // }
640
665
  } catch (error) {
641
- console.error("Error during getCurrentRunningState:", error);
666
+ // console.error("Error during getCurrentRunningState:", error);
642
667
  // throw error;
643
668
  }
644
669
  return response;
package/test.ts CHANGED
@@ -259,13 +259,133 @@ function getRegisterMap(bean: any, allRegister: RegisterItem[]) {
259
259
 
260
260
  async function setRegister() {
261
261
  const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
262
- const result = await client.setCpuRegisterValue('c6713_0', 'c67x_core_0', 'FADCR_REG', '3')
262
+ const r2 = await client.setDeviceRegisterValue('c6713_0', 'c67x_core_0', 'A7', '34')
263
+ console.log("setRegister:", r2)
264
+ }
265
+
266
+ async function getRegister() {
267
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
268
+ const result = await client.getCpuRegisters("")
263
269
  console.log("setRegister:", result)
270
+ }
271
+
272
+ async function getState() {
273
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.2', '50051');
274
+ const result = await client.getCurrentRunningState()
275
+ console.log("getState:", result)
276
+ }
277
+ // getState()
278
+
279
+
280
+ async function setMemoryValue() {
281
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
282
+ const result = await client.setMemoryValue('c67x_core_0', '10000', '15', 2)
283
+ console.log("setMemoryValue:", result)
284
+ }
285
+ // setMemoryValue()
286
+
264
287
 
288
+
289
+ async function getMemoryValue() {
290
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
291
+ const result = await client.getMemoryValue('c67x_core_0', "10000", 2)
292
+ console.log("setMemoryValue:", result)
265
293
  }
294
+ // getMemoryValue()
295
+
296
+
297
+
298
+ async function testSocket() {
299
+ const json = {
300
+ "msgId": "0",
301
+ "msgTime": "2023-12-5 12:00:00",
302
+ "msgType": "2",
303
+ "msgData": {
304
+ "version": "10001",
305
+ "protocol": "0",
306
+ "direction": "0",
307
+ "bigEndian": "0",
308
+ "length": "0",
309
+ "data": "0"
310
+ }
311
+ }
312
+ const net = require('net');
313
+ const client = new net.Socket();
314
+ const host = '127.0.0.1';
315
+ const port = 8099;
316
+ client.connect(port, host, () => {
317
+ console.log('Connected');
318
+
319
+ // const str = JSON.stringify(json)
320
+ // // const str = "hhh"
321
+
322
+ // const strBuffer = Buffer.from(str, 'utf8'); // 将字符串转换为 Buffer
323
+ // const strLength = strBuffer.length; // 获取 JSON 数据的长度
324
+
325
+ // // 创建一个新的 Buffer 用于存储长度信息和数据
326
+ // const totalLength = 4 + strLength; // 4 字节长度 + 数据长度
327
+ // const buffer = Buffer.alloc(totalLength);
328
+
329
+ // // 写入前 4 个字节的长度信息
330
+ // buffer.writeUInt32LE(strLength, 0); // 以小端序方式写入 JSON 数据的长度
331
+
332
+ // // 将 JSON 数据复制到 Buffer 中
333
+ // strBuffer.copy(buffer, 4); // 从第 5 个字节开始复制 JSON 数据
334
+
335
+ // console.log("Buffer sent:", buffer);
336
+
337
+ // console.log("String Length:", strLength); // 打印实际的字符串长度
338
+ // console.log("Hex Length:", strLength.toString(16)); // 打印十六进制表示
266
339
 
267
- // getAllRegisterList()
268
- setRegister()
340
+
341
+ // client.write(buffer); // 发送拼接后的 Buffer
342
+
343
+ // 发送数据
344
+
345
+ //第一阶段0827测试
346
+ // const hexString = "B90000007B0A09226D73674964223A2230222C0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0A09226D736754797065223A2232222C0A09226D736744617461223A7B0A09092276657273696F6E223A2231222C0A09092270726F746F636F6C223A2230222C0A090922646972656374696F6E223A2230222C0A090922626967456E6469616E223A2230222C0A0909226C656E677468223A2230222C0A09092264617461223A2230220A097D0A7D0A";
347
+
348
+
349
+
350
+ const s1 = "12 01 AA 11 BB 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 00 33 33 00 00 00 00 00 00 00 00 44 44 00 00 00 00 00 00 88 88 66 44 00 00 00 00 00 00 00 00 00 00 65 76"
351
+ const s1_1 = s1.replace(/\s+/g, '');
352
+ const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A36340D0A097D0D0A7D" + s1_1
353
+
354
+
355
+
356
+
357
+ //74
358
+ // const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A37340D0A097D0D0A7D1201AA11BB220000000000000000000000000000FFFF000000003333000000000000000044440000000000008888664400000000000000000000006576";
359
+
360
+
361
+
362
+ console.log("hexString:", hexString)
363
+ console.log("hexString:", hexString.length)
364
+ const buffer2 = Buffer.from(hexString, 'hex');
365
+ console.log("buffer2:", buffer2.length)
366
+ client.write(buffer2);
367
+
368
+
369
+ });
370
+ client.on('data', (data) => {
371
+ console.log('Received: ' + data);
372
+ client.destroy();
373
+ });
374
+ client.on('close', () => {
375
+ console.log('Connection closed');
376
+ });
377
+ }
378
+ testSocket()
379
+
380
+
381
+
382
+
383
+ async function testgetGlobalVarValue() {
384
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50052');
385
+ const response = await client.getGlobalVarValue("cx53123", "a", 16, "double");
386
+ console.log("testgetGlobalVarValue response:", response)
387
+ }
388
+ // testgetGlobalVarValue()
269
389
 
270
390
 
271
391