skyeye-sdk-js 1.3.5 → 1.3.7

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.
@@ -70,7 +70,6 @@ class RequestFactory {
70
70
  baseRequest.setArgs(args);
71
71
  const request = new skyeye_rpc_pb_1.JSONRequest();
72
72
  request.setRequest(baseRequest.toJSONString());
73
- console.log("setMemoryValue:", request);
74
73
  return request;
75
74
  }
76
75
  enableDeviceWork(deviceName) {
@@ -150,7 +149,6 @@ class RequestFactory {
150
149
  baseRequest.setArgs(args);
151
150
  const request = new skyeye_rpc_pb_1.JSONRequest();
152
151
  request.setRequest(baseRequest.toJSONString());
153
- console.log("request:", request);
154
152
  return request;
155
153
  }
156
154
  setGlobalVarValue(cpuName, varName, bytesNum, valueType, value) {
@@ -164,7 +162,6 @@ class RequestFactory {
164
162
  baseRequest.setArgs(args);
165
163
  const request = new skyeye_rpc_pb_1.JSONRequest();
166
164
  request.setRequest(baseRequest.toJSONString());
167
- console.log('setGlobalVarValue:', request);
168
165
  return request;
169
166
  }
170
167
  getDeviceList() {
@@ -182,9 +179,9 @@ class RequestFactory {
182
179
  setRegisterValue(machName, deviceName, regName, value) {
183
180
  const baseRequest = new BaseRequest_1.BaseRequest("SE_set_device_register_value");
184
181
  const args = {};
185
- args.machName = machName;
186
- args.deviceName = deviceName;
187
- args.regName = regName;
182
+ args.machname = machName;
183
+ args.devname = deviceName;
184
+ args.regname = regName;
188
185
  args.value = String(value);
189
186
  baseRequest.setArgs(args);
190
187
  const request = new skyeye_rpc_pb_1.JSONRequest();
@@ -200,7 +197,7 @@ class RequestFactory {
200
197
  getRamAddrInfo(machName, addr) {
201
198
  const baseRequest = new BaseRequest_1.BaseRequest("SE_get_mem_device_addr_info");
202
199
  const args = {};
203
- args.machName = machName;
200
+ args.machname = machName;
204
201
  args.addr = addr;
205
202
  baseRequest.setArgs(args);
206
203
  const request = new skyeye_rpc_pb_1.JSONRequest();
@@ -210,8 +207,8 @@ class RequestFactory {
210
207
  setFaultInject(machName, deviceName, addr, bit, mode) {
211
208
  const baseRequest = new BaseRequest_1.BaseRequest("SE_set_fault_inject");
212
209
  const args = {};
213
- args.machName = machName;
214
- args.deviceName = deviceName;
210
+ args.machname = machName;
211
+ args.devicename = deviceName;
215
212
  args.addr = addr;
216
213
  args.bit = bit;
217
214
  args.mode = mode;
@@ -223,8 +220,8 @@ class RequestFactory {
223
220
  deleteFaultInject(machName, deviceName, addr, bit, mode) {
224
221
  const baseRequest = new BaseRequest_1.BaseRequest("SE_delete_fault");
225
222
  const args = {};
226
- args.machName = machName;
227
- args.deviceName = deviceName;
223
+ args.machname = machName;
224
+ args.devicename = deviceName;
228
225
  args.addr = addr;
229
226
  args.bit = bit;
230
227
  args.mode = mode;
@@ -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>;
@@ -645,14 +645,14 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
645
645
  if (!deviceTree.boardMap.has(boardName)) {
646
646
  throw new SkyEyeSDKException_1.SkyEyeSDKException("未能找到该板卡");
647
647
  }
648
- const board = boardMap.get(boardName);
649
- const deviceMap = board.getDeveceMap();
650
- if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu_1.Cpu)) {
651
- throw new SkyEyeSDKException_1.SkyEyeSDKException("未能找到该设备");
652
- }
653
- const cpu = deviceMap.get(cpuName);
648
+ // const board: Board = boardMap.get(boardName);
649
+ // const deviceMap = board.deviceMap;
650
+ // if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu)) {
651
+ // throw new SkyEyeSDKException("未能找到该设备");
652
+ // }
653
+ // const cpu = deviceMap.get(cpuName);
654
654
  try {
655
- return yield this.call(RequestFactory_1.RequestFactory.getInstance().setRegisterValue(cpu.getParent().getName(), cpuName, registerName, value));
655
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().setRegisterValue(boardName, cpuName, registerName, value));
656
656
  }
657
657
  catch (error) {
658
658
  console.error("Error during getAddressingSpace:", error);
@@ -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
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory');
13
13
  const { SkyEyeClient } = require('./src/SkyEyeClient');
14
+ const { Cpu } = require('./src/models/Cpu');
14
15
  const json = {
15
16
  "id": "4a162d75-3a84-5264-992f-287624830ead",
16
17
  "name": "鍙戦€佸唴瀛樻秷鎭祴璇?",
@@ -182,6 +183,168 @@ const json = {
182
183
  "updatedAt": "2024-06-11T06:37:05.487Z",
183
184
  "results": []
184
185
  };
186
+ class RegisterItem {
187
+ }
188
+ var RegisterType;
189
+ (function (RegisterType) {
190
+ RegisterType[RegisterType["CPU"] = 0] = "CPU";
191
+ RegisterType[RegisterType["Device"] = 1] = "Device";
192
+ })(RegisterType || (RegisterType = {}));
193
+ function getAllRegisterList() {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ const allRegister = [];
196
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
197
+ //通过 getDeviceTree 获取板卡、设备、寄存器层级, 列出所有寄存器列表选择
198
+ const resultTree = yield client.getDeviceTree();
199
+ console.log("结果 resultTree:", JSON.stringify(resultTree));
200
+ console.log("结果 keys:", resultTree.boardMap.keys());
201
+ for (const key of resultTree.boardMap.keys()) {
202
+ const device = resultTree.boardMap.get(key);
203
+ // 在这里对获取到的键值对进行处理
204
+ console.log(`板卡: ${key},设备: ${device.deviceMap}`);
205
+ if (!device.deviceMap || device.deviceMap.keys().length == 0) {
206
+ continue;
207
+ }
208
+ for (const k of device.deviceMap.keys()) {
209
+ const register = device.deviceMap.get(k);
210
+ console.log(`设备: ${k}, 寄存器: ${register}`);
211
+ console.log("寄存器下的寄存器: ", register.registerMap);
212
+ if (!register.registerMap || register.registerMap.keys().length == 0) {
213
+ continue;
214
+ }
215
+ getRegisterMap(register, allRegister);
216
+ }
217
+ }
218
+ console.log("allRegister2:", allRegister.length);
219
+ return allRegister;
220
+ });
221
+ }
222
+ function getRegisterMap(bean, allRegister) {
223
+ if (!bean.registerMap || bean.registerMap.keys().length == 0) {
224
+ return;
225
+ }
226
+ for (const r of bean.registerMap.keys()) {
227
+ const result = bean.registerMap.get(r);
228
+ console.log(`设备: ${r}, 寄存器: ${result}`);
229
+ const item = new RegisterItem();
230
+ item.name = r.name;
231
+ if (bean instanceof Cpu) {
232
+ console.log(`寄存器类型: ${bean.className}`);
233
+ item.type = RegisterType.CPU;
234
+ }
235
+ else {
236
+ item.type = RegisterType.Device;
237
+ }
238
+ allRegister.push(item);
239
+ getRegisterMap(result, allRegister);
240
+ }
241
+ }
242
+ function setRegister() {
243
+ return __awaiter(this, void 0, void 0, function* () {
244
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
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("");
253
+ console.log("setRegister:", result);
254
+ });
255
+ }
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()
185
348
  function test() {
186
349
  return __awaiter(this, void 0, void 0, function* () {
187
350
  // console.log("Connected to SkyEye server");
@@ -206,49 +369,59 @@ function test() {
206
369
  // const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
207
370
  // const fileName = "c6713_fc_1553b.skyeye";
208
371
  // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
209
- const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
372
+ // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
210
373
  // const response =await client.getCurrentRunningState()
211
374
  // const response = await client.getMemoryValueDefault("128","4")
212
- const response = yield client.getGlobalVarValueDefault("number_a", "int");
375
+ // const response = await client.getGlobalVarValueDefault("number_a","int")
213
376
  // const response = await client.setGlobalVarValueDefault("number_a", "int", "12")
377
+ // const response = await client.getDeviceTree()
214
378
  // const response = await client.getMemoryValueDefault("10001", "1")
215
- console.log("response:", response);
379
+ // console.log("response:", response)
380
+ // console.log("response:", response.boardMap)
381
+ // console.log("response:", response.boardMap.keys[0])
382
+ });
383
+ }
384
+ function testMutil() {
385
+ return __awaiter(this, void 0, void 0, function* () {
386
+ const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
387
+ const fileName = "c6713_fc_1553b.skyeye";
388
+ const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe";
389
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
216
390
  //启动多个skyeye
217
- // const count = 5;
218
- // const map = new Map<number, any>;
219
- // for (let i = 1; i < count; i++) {
220
- // const port = 50050 + i
221
- // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port.toString());
222
- // await client.initSkyEyeAndRun2(pathSkyEye, fileName, port.toString(), skyeyeDir)
223
- // await client.RunTestcase(json)
224
- // await client.runCommand()
225
- // const res = await client.getCurrentRunningState()
226
- // console.log("state3:", res.state)
227
- // map.set(port, client);
228
- // }
229
- // for (let i = 1; i < count; i++) {
230
- // setTimeout(async () => {
231
- // const port = 50050 + i
232
- // const client = map.get(port)
233
- // await client.quitCommand()
234
- // }, i * 5000)
235
- // }
236
- // setTimeout(async () => {
237
- // // await map.get(50051).stopGrpcService("")
238
- // await map.get(50051).quitCommand()
239
- // }, 2000)
240
- // setTimeout(async () => {
241
- // // await map.get(50052).stopGrpcService("")
242
- // await map.get(50052).quitCommand()
243
- // }, 5000)
244
- // setTimeout(async () => {
245
- // // await map.get(50053).stopGrpcService("")
246
- // await map.get(50053).quitCommand()
247
- // }, 8000)
248
- // setTimeout(async () => {
249
- // // await map.get(50054).stopGrpcService("")
250
- // await map.get(50054).quitCommand()
251
- // }, 11000)
391
+ const count = 5;
392
+ const map = new Map;
393
+ for (let i = 1; i < count; i++) {
394
+ const port = 50050 + i;
395
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port.toString());
396
+ yield client.initSkyEyeAndRun2(pathSkyEye, fileName, port.toString(), skyeyeDir);
397
+ yield client.RunTestcase(json);
398
+ yield client.runCommand();
399
+ const res = yield client.getCurrentRunningState();
400
+ console.log("state3:", res.state);
401
+ map.set(port, client);
402
+ }
403
+ for (let i = 1; i < count; i++) {
404
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
405
+ const port = 50050 + i;
406
+ const client = map.get(port);
407
+ yield client.quitCommand();
408
+ }), i * 5000);
409
+ }
410
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
411
+ // await map.get(50051).stopGrpcService("")
412
+ yield map.get(50051).quitCommand();
413
+ }), 2000);
414
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
415
+ // await map.get(50052).stopGrpcService("")
416
+ yield map.get(50052).quitCommand();
417
+ }), 5000);
418
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
419
+ // await map.get(50053).stopGrpcService("")
420
+ yield map.get(50053).quitCommand();
421
+ }), 8000);
422
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
423
+ // await map.get(50054).stopGrpcService("")
424
+ yield map.get(50054).quitCommand();
425
+ }), 11000);
252
426
  });
253
427
  }
254
- test();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
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
@@ -83,7 +83,6 @@ export class RequestFactory {
83
83
  baseRequest.setArgs(args)
84
84
  const request = new JSONRequest()
85
85
  request.setRequest(baseRequest.toJSONString());
86
- console.log("setMemoryValue:",request)
87
86
  return request;
88
87
  }
89
88
 
@@ -178,7 +177,6 @@ export class RequestFactory {
178
177
  baseRequest.setArgs(args)
179
178
  const request = new JSONRequest()
180
179
  request.setRequest(baseRequest.toJSONString());
181
- console.log("request:", request)
182
180
  return request;
183
181
  }
184
182
 
@@ -194,7 +192,6 @@ export class RequestFactory {
194
192
  baseRequest.setArgs(args)
195
193
  const request = new JSONRequest()
196
194
  request.setRequest(baseRequest.toJSONString());
197
- console.log('setGlobalVarValue:', request)
198
195
  return request;
199
196
  }
200
197
 
@@ -220,9 +217,9 @@ export class RequestFactory {
220
217
  public setRegisterValue(machName: string, deviceName: string, regName: string, value: string) {
221
218
  const baseRequest = new BaseRequest("SE_set_device_register_value");
222
219
  const args: { [key: string]: string } = {};
223
- args.machName = machName;
224
- args.deviceName = deviceName;
225
- args.regName = regName;
220
+ args.machname = machName;
221
+ args.devname = deviceName;
222
+ args.regname = regName;
226
223
  args.value = String(value);
227
224
  baseRequest.setArgs(args)
228
225
  const request = new JSONRequest()
@@ -242,7 +239,7 @@ export class RequestFactory {
242
239
  public getRamAddrInfo(machName: string, addr: string) {
243
240
  const baseRequest = new BaseRequest("SE_get_mem_device_addr_info");
244
241
  const args: { [key: string]: string } = {};
245
- args.machName = machName;
242
+ args.machname = machName;
246
243
  args.addr = addr
247
244
  baseRequest.setArgs(args)
248
245
  const request = new JSONRequest()
@@ -256,8 +253,8 @@ export class RequestFactory {
256
253
  public setFaultInject(machName: string, deviceName: string, addr: string, bit: string, mode: string) {
257
254
  const baseRequest = new BaseRequest("SE_set_fault_inject");
258
255
  const args: { [key: string]: string } = {};
259
- args.machName = machName;
260
- args.deviceName = deviceName;
256
+ args.machname = machName;
257
+ args.devicename = deviceName;
261
258
  args.addr = addr;
262
259
  args.bit = bit;
263
260
  args.mode = mode;
@@ -272,8 +269,8 @@ export class RequestFactory {
272
269
  public deleteFaultInject(machName: string, deviceName: string, addr: string, bit: string, mode: string) {
273
270
  const baseRequest = new BaseRequest("SE_delete_fault");
274
271
  const args: { [key: string]: string } = {};
275
- args.machName = machName;
276
- args.deviceName = deviceName;
272
+ args.machname = machName;
273
+ args.devicename = deviceName;
277
274
  args.addr = addr;
278
275
  args.bit = bit;
279
276
  args.mode = mode;
@@ -23,6 +23,7 @@ import { GetCpuRegisterInfoResponse } from './response/GetCpuRegisterInfoRespons
23
23
  import { SkyEyeSDKException } from './exception/SkyEyeSDKException';
24
24
  import { ServiceError } from '@grpc/grpc-js';
25
25
  import * as cp from 'child_process';
26
+ import { Board } from './models/Board';
26
27
  let client: JSONTransmissionClient | any = null;
27
28
 
28
29
 
@@ -574,14 +575,14 @@ export class SkyEyeClient extends JSONTransmissionClient {
574
575
  if (!deviceTree.boardMap.has(boardName)) {
575
576
  throw new SkyEyeSDKException("未能找到该板卡");
576
577
  }
577
- const board = boardMap.get(boardName);
578
- const deviceMap = board.getDeveceMap();
579
- if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu)) {
580
- throw new SkyEyeSDKException("未能找到该设备");
581
- }
582
- const cpu = deviceMap.get(cpuName);
578
+ // const board: Board = boardMap.get(boardName);
579
+ // const deviceMap = board.deviceMap;
580
+ // if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu)) {
581
+ // throw new SkyEyeSDKException("未能找到该设备");
582
+ // }
583
+ // const cpu = deviceMap.get(cpuName);
583
584
  try {
584
- return await this.call(RequestFactory.getInstance().setRegisterValue(cpu.getParent().getName(), cpuName, registerName, value));
585
+ return await this.call(RequestFactory.getInstance().setRegisterValue(boardName, cpuName, registerName, value));
585
586
  } catch (error) {
586
587
  console.error("Error during getAddressingSpace:", error);
587
588
  throw error;
@@ -589,6 +590,31 @@ export class SkyEyeClient extends JSONTransmissionClient {
589
590
  }
590
591
 
591
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
+
592
618
  public async getDeviceTree() {
593
619
  const state = (await this.getCurrentRunningState()).getState();
594
620
  if (StateState.UNLOADED === state || StateState.QUITED === state) {
@@ -637,7 +663,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
637
663
  // throw new SkyEyeSDKException(String(call.error));
638
664
  // }
639
665
  } catch (error) {
640
- console.error("Error during getCurrentRunningState:", error);
666
+ // console.error("Error during getCurrentRunningState:", error);
641
667
  // throw error;
642
668
  }
643
669
  return response;
package/test.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { JSONResponse } from "./src/proto/skyeye_rpc_pb";
2
2
  import { GrpcUtil } from "./src/GrpcUtil";
3
3
  import { ServiceError } from "@grpc/grpc-js";
4
+ import { Enum } from "protobufjs";
4
5
 
5
6
  const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory')
6
7
  const { SkyEyeClient } = require('./src/SkyEyeClient')
7
8
 
8
-
9
+ const { Cpu } = require('./src/models/Cpu')
9
10
 
10
11
  const json = {
11
12
  "id": "4a162d75-3a84-5264-992f-287624830ead",
@@ -180,9 +181,215 @@ const json = {
180
181
  }
181
182
 
182
183
 
184
+ class RegisterItem {
185
+ name: string;
186
+ type: RegisterType; //0 cpu寄存器 1 设备寄存器
187
+ deviceName: string; //设备名称
188
+ boardName: string;
189
+ }
183
190
 
184
- async function test() {
191
+ enum RegisterType {
192
+ CPU,
193
+ Device
194
+ }
195
+
196
+
197
+
198
+ async function getAllRegisterList() {
199
+ const allRegister: RegisterItem[] = [];
200
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
201
+
202
+ //通过 getDeviceTree 获取板卡、设备、寄存器层级, 列出所有寄存器列表选择
203
+
204
+ const resultTree = await client.getDeviceTree()
205
+ console.log("结果 resultTree:", JSON.stringify(resultTree))
206
+ console.log("结果 keys:", resultTree.boardMap.keys())
207
+
208
+ for (const key of resultTree.boardMap.keys()) {
209
+ const device = resultTree.boardMap.get(key);
210
+ // 在这里对获取到的键值对进行处理
211
+ console.log(`板卡: ${key},设备: ${device.deviceMap}`);
212
+
213
+ if (!device.deviceMap || device.deviceMap.keys().length == 0) {
214
+ continue
215
+ }
216
+
217
+ for (const k of device.deviceMap.keys()) {
218
+ const register = device.deviceMap.get(k);
219
+ console.log(`设备: ${k}, 寄存器: ${register}`);
220
+ console.log("寄存器下的寄存器: ", register.registerMap)
221
+ if (!register.registerMap || register.registerMap.keys().length == 0) {
222
+ continue
223
+ }
224
+ getRegisterMap(register, allRegister)
225
+
226
+ }
227
+ }
228
+ console.log("allRegister2:", allRegister.length)
229
+ return allRegister;
230
+ }
231
+
232
+
233
+
234
+ function getRegisterMap(bean: any, allRegister: RegisterItem[]) {
235
+ if (!bean.registerMap || bean.registerMap.keys().length == 0) {
236
+ return
237
+ }
238
+
239
+ for (const r of bean.registerMap.keys()) {
240
+ const result = bean.registerMap.get(r);
241
+ console.log(`设备: ${r}, 寄存器: ${result}`);
242
+
243
+ const item = new RegisterItem()
244
+ item.name = r.name
245
+
246
+ if (bean instanceof Cpu) {
247
+ console.log(`寄存器类型: ${bean.className}`);
248
+ item.type = RegisterType.CPU
249
+ } else {
250
+ item.type = RegisterType.Device
251
+ }
252
+ allRegister.push(item)
253
+ getRegisterMap(result, allRegister)
254
+ }
255
+ }
256
+
257
+
258
+
259
+
260
+ async function setRegister() {
261
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
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("")
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
+
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)
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');
185
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)); // 打印十六进制表示
339
+
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()
389
+
390
+
391
+
392
+ async function test() {
186
393
  // console.log("Connected to SkyEye server");
187
394
  // await client.getDeviceList();
188
395
  // await client.getCurrentCpuMips();
@@ -202,10 +409,6 @@ async function test() {
202
409
 
203
410
 
204
411
  // await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
205
-
206
-
207
-
208
-
209
412
  // const pathSkyEye = "D:/data/case/c6713_demo";
210
413
  // const fileName = "c6713_demo.skyeye";
211
414
  // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
@@ -220,68 +423,76 @@ async function test() {
220
423
  // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
221
424
 
222
425
 
223
- const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
426
+ // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
224
427
 
225
428
  // const response =await client.getCurrentRunningState()
226
429
  // const response = await client.getMemoryValueDefault("128","4")
227
- const response = await client.getGlobalVarValueDefault("number_a","int")
430
+ // const response = await client.getGlobalVarValueDefault("number_a","int")
228
431
  // const response = await client.setGlobalVarValueDefault("number_a", "int", "12")
229
432
 
433
+ // const response = await client.getDeviceTree()
230
434
 
231
435
 
232
436
  // const response = await client.getMemoryValueDefault("10001", "1")
233
- console.log("response:", response)
437
+ // console.log("response:", response)
438
+ // console.log("response:", response.boardMap)
439
+ // console.log("response:", response.boardMap.keys[0])
440
+ }
234
441
 
235
- //启动多个skyeye
236
- // const count = 5;
237
- // const map = new Map<number, any>;
238
- // for (let i = 1; i < count; i++) {
239
- // const port = 50050 + i
240
- // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port.toString());
241
- // await client.initSkyEyeAndRun2(pathSkyEye, fileName, port.toString(), skyeyeDir)
242
- // await client.RunTestcase(json)
243
- // await client.runCommand()
244
- // const res = await client.getCurrentRunningState()
245
- // console.log("state3:", res.state)
246
- // map.set(port, client);
247
- // }
248
- // for (let i = 1; i < count; i++) {
249
- // setTimeout(async () => {
250
- // const port = 50050 + i
251
- // const client = map.get(port)
252
- // await client.quitCommand()
253
- // }, i * 5000)
254
- // }
255
442
 
256
443
 
257
444
 
258
445
 
259
446
 
260
447
 
261
- // setTimeout(async () => {
262
- // // await map.get(50051).stopGrpcService("")
263
- // await map.get(50051).quitCommand()
264
- // }, 2000)
265
448
 
266
- // setTimeout(async () => {
267
- // // await map.get(50052).stopGrpcService("")
268
- // await map.get(50052).quitCommand()
269
- // }, 5000)
270
449
 
271
- // setTimeout(async () => {
272
- // // await map.get(50053).stopGrpcService("")
273
- // await map.get(50053).quitCommand()
274
- // }, 8000)
450
+ async function testMutil() {
275
451
 
276
- // setTimeout(async () => {
277
- // // await map.get(50054).stopGrpcService("")
278
- // await map.get(50054).quitCommand()
279
- // }, 11000)
452
+ const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
453
+ const fileName = "c6713_fc_1553b.skyeye";
454
+ const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
455
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
280
456
 
281
457
 
458
+ //启动多个skyeye
459
+ const count = 5;
460
+ const map = new Map<number, any>;
461
+ for (let i = 1; i < count; i++) {
462
+ const port = 50050 + i
463
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port.toString());
464
+ await client.initSkyEyeAndRun2(pathSkyEye, fileName, port.toString(), skyeyeDir)
465
+ await client.RunTestcase(json)
466
+ await client.runCommand()
467
+ const res = await client.getCurrentRunningState()
468
+ console.log("state3:", res.state)
469
+ map.set(port, client);
470
+ }
471
+ for (let i = 1; i < count; i++) {
472
+ setTimeout(async () => {
473
+ const port = 50050 + i
474
+ const client = map.get(port)
475
+ await client.quitCommand()
476
+ }, i * 5000)
477
+ }
478
+
479
+ setTimeout(async () => {
480
+ // await map.get(50051).stopGrpcService("")
481
+ await map.get(50051).quitCommand()
482
+ }, 2000)
483
+
484
+ setTimeout(async () => {
485
+ // await map.get(50052).stopGrpcService("")
486
+ await map.get(50052).quitCommand()
487
+ }, 5000)
488
+
489
+ setTimeout(async () => {
490
+ // await map.get(50053).stopGrpcService("")
491
+ await map.get(50053).quitCommand()
492
+ }, 8000)
493
+
494
+ setTimeout(async () => {
495
+ // await map.get(50054).stopGrpcService("")
496
+ await map.get(50054).quitCommand()
497
+ }, 11000)
282
498
  }
283
- test();
284
-
285
-
286
-
287
-