skyeye-sdk-js 1.4.9 → 1.4.11

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.
@@ -14,6 +14,8 @@ export declare class RequestFactory {
14
14
  getCpuList(): JSONRequest;
15
15
  getMemoryValue(cpuName: string, baseAddr: string, length: string, addressWidth?: number): JSONRequest;
16
16
  setMemoryValue(cpuName: string, baseAddr: string, value: string, length: string, addressWidth?: number): JSONRequest;
17
+ getBitValue(cpuName: string, baseAddr: string, bitIndex: number, addressWidth?: number): JSONRequest;
18
+ setBitValue(cpuName: string, baseAddr: string, bitIndex: number, value: number, addressWidth?: number): JSONRequest;
17
19
  enableDeviceWork(deviceName: string): JSONRequest;
18
20
  disableDeviceWork(deviceName: string): JSONRequest;
19
21
  changeDir(path: string): JSONRequest;
@@ -91,6 +91,31 @@ class RequestFactory {
91
91
  request.setRequest(baseRequest.toJSONString());
92
92
  return request;
93
93
  }
94
+ getBitValue(cpuName, baseAddr, bitIndex, addressWidth) {
95
+ const baseRequest = new BaseRequest_1.BaseRequest("SE_get_bit_value");
96
+ const args = {};
97
+ args.cpuname = cpuName;
98
+ args.baseaddr = "0x" + baseAddr;
99
+ args.bitindex = bitIndex;
100
+ args.address_width = addressWidth;
101
+ baseRequest.setArgs(args);
102
+ const request = new skyeye_rpc_pb_1.JSONRequest();
103
+ request.setRequest(baseRequest.toJSONString());
104
+ return request;
105
+ }
106
+ setBitValue(cpuName, baseAddr, bitIndex, value, addressWidth) {
107
+ const baseRequest = new BaseRequest_1.BaseRequest("SE_set_bit_value");
108
+ const args = {};
109
+ args.cpuname = cpuName;
110
+ args.baseaddr = "0x" + baseAddr;
111
+ args.bitindex = bitIndex;
112
+ args.value = value;
113
+ args.address_width = addressWidth;
114
+ baseRequest.setArgs(args);
115
+ const request = new skyeye_rpc_pb_1.JSONRequest();
116
+ request.setRequest(baseRequest.toJSONString());
117
+ return request;
118
+ }
94
119
  enableDeviceWork(deviceName) {
95
120
  const baseRequest = new BaseRequest_1.BaseRequest("SE_enable_device_work");
96
121
  const args = {};
@@ -7,6 +7,7 @@ import { GetRunningStateResponse } from './response/GetRunningStateResponse';
7
7
  import { Register } from './models/Register';
8
8
  import { GetDeviceTreeResponse } from './response/GetDeviceTreeResponse';
9
9
  import { GetAllDeviceInfoResponse } from './response/GetAllDeviceInfoResponse';
10
+ import { GetAllDeviceInfoResponse2 } from './response/GetAllDeviceInfoResponse2';
10
11
  import { GetRamAddrInfoResponse } from './response/GetRamAddrInfoResponse';
11
12
  import { Device } from './models/Device';
12
13
  import { FaultInjectType } from './models/FaultInjectType';
@@ -56,6 +57,8 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
56
57
  getAddressingSpaceDefault(baseAddr: string, length: string): Promise<any>;
57
58
  setMemoryValue(cpuName: string, baseAddr: string, value: string, length: string, addressWidth?: number): Promise<any>;
58
59
  setMemoryValueDefault(baseAddr: string, value: string, length: string, addressWidth?: number): Promise<any>;
60
+ setBitValue(cpuName: string, baseAddr: string, bitIndex: number, value: number, addressWidth?: number): Promise<any>;
61
+ getBitValue(cpuName: string, baseAddr: string, bitIndex: number, addressWidth?: number): Promise<any>;
59
62
  getCpuRegisters(cpuName: string): Promise<GetCpuRegisterInfoResponse>;
60
63
  getCpuRegistersDefault(): Promise<GetCpuRegisterInfoResponse>;
61
64
  setCpuRegisterValueDefault(register: Register, value: string): Promise<any>;
@@ -66,6 +69,7 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
66
69
  getModuleStatus(): Promise<BaseResponse>;
67
70
  getCurrentRunningState(): Promise<GetRunningStateResponse>;
68
71
  getAllDeviceInfo(): Promise<GetAllDeviceInfoResponse>;
72
+ getAllDeviceInfo2(): Promise<GetAllDeviceInfoResponse2>;
69
73
  getRamAddrInfo(machName: string, addr: string): Promise<GetRamAddrInfoResponse>;
70
74
  setRamFaultInjectDefault(device: Device, addr: string, bit: string, mode: FaultInjectType): Promise<any>;
71
75
  setRamFaultInject(boardName: string, deviceName: string, addr: string, bit: string, mode: FaultInjectType): Promise<any>;
@@ -45,6 +45,7 @@ const Register_1 = require("./models/Register");
45
45
  const GetDeviceTreeResponse_1 = require("./response/GetDeviceTreeResponse");
46
46
  const ParseBoardUtils_1 = require("./utils/ParseBoardUtils");
47
47
  const GetAllDeviceInfoResponse_1 = require("./response/GetAllDeviceInfoResponse");
48
+ const GetAllDeviceInfoResponse2_1 = require("./response/GetAllDeviceInfoResponse2");
48
49
  const GetRamAddrInfoResponse_1 = require("./response/GetRamAddrInfoResponse");
49
50
  const Device_1 = require("./models/Device");
50
51
  const FaultInjectType_1 = require("./models/FaultInjectType");
@@ -631,6 +632,28 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
631
632
  }
632
633
  });
633
634
  }
635
+ setBitValue(cpuName, baseAddr, bitIndex, value, addressWidth) {
636
+ return __awaiter(this, void 0, void 0, function* () {
637
+ try {
638
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().setBitValue(cpuName, baseAddr, bitIndex, value, addressWidth));
639
+ }
640
+ catch (error) {
641
+ console.error("Error during getAddressingSpaceDefault:", error);
642
+ throw error;
643
+ }
644
+ });
645
+ }
646
+ getBitValue(cpuName, baseAddr, bitIndex, addressWidth) {
647
+ return __awaiter(this, void 0, void 0, function* () {
648
+ try {
649
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().getBitValue(cpuName, baseAddr, bitIndex, addressWidth));
650
+ }
651
+ catch (error) {
652
+ console.error("Error during getAddressingSpaceDefault:", error);
653
+ throw error;
654
+ }
655
+ });
656
+ }
634
657
  getCpuRegisters(cpuName) {
635
658
  return __awaiter(this, void 0, void 0, function* () {
636
659
  const response = new GetCpuRegisterInfoResponse_1.GetCpuRegisterInfoResponse();
@@ -865,6 +888,26 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
865
888
  return response;
866
889
  });
867
890
  }
891
+ getAllDeviceInfo2() {
892
+ return __awaiter(this, void 0, void 0, function* () {
893
+ const response = new GetAllDeviceInfoResponse2_1.GetAllDeviceInfoResponse2();
894
+ try {
895
+ const call = yield this.call(RequestFactory_1.RequestFactory.getInstance().getAllDeviceInfo());
896
+ if (call != null) {
897
+ response.isSuccess = true;
898
+ response.result = call;
899
+ }
900
+ else {
901
+ throw new SkyEyeSDKException_1.SkyEyeSDKException(String(call.error));
902
+ }
903
+ }
904
+ catch (error) {
905
+ console.error("Error during getAllDeviceInfo:", error);
906
+ throw error;
907
+ }
908
+ return response;
909
+ });
910
+ }
868
911
  getRamAddrInfo(machName, addr) {
869
912
  return __awaiter(this, void 0, void 0, function* () {
870
913
  const response = new GetRamAddrInfoResponse_1.GetRamAddrInfoResponse();
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SkyEyeClientFactory = void 0;
13
13
  const SkyEyeClient_1 = require("./SkyEyeClient");
14
+ const GetRunningStateResponse_1 = require("./response/GetRunningStateResponse");
14
15
  class SkyEyeClientFactory {
15
16
  constructor() { }
16
17
  static get instance() {
@@ -31,11 +32,15 @@ class SkyEyeClientFactory {
31
32
  return __awaiter(this, void 0, void 0, function* () {
32
33
  const client = this.createClient(ip, port);
33
34
  const startTime = Date.now();
35
+ let isTimeout = true;
34
36
  while (Date.now() - startTime < time * 1000) {
35
37
  try {
36
- const response = client.getCurrentRunningState();
38
+ const response = yield client.getCurrentRunningState();
37
39
  console.log("response:", response);
38
- break;
40
+ if (response.getState() !== GetRunningStateResponse_1.StateState.QUITED) {
41
+ isTimeout = false;
42
+ break;
43
+ }
39
44
  }
40
45
  catch (error) {
41
46
  try {
@@ -46,6 +51,9 @@ class SkyEyeClientFactory {
46
51
  }
47
52
  }
48
53
  }
54
+ if (isTimeout) {
55
+ throw new Error('连接超时');
56
+ }
49
57
  return client;
50
58
  });
51
59
  }
@@ -0,0 +1,4 @@
1
+ import { BaseResponse } from "./BaseResponse";
2
+ export declare class GetAllDeviceInfoResponse2 extends BaseResponse {
3
+ result: object;
4
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAllDeviceInfoResponse2 = void 0;
4
+ const BaseResponse_1 = require("./BaseResponse");
5
+ class GetAllDeviceInfoResponse2 extends BaseResponse_1.BaseResponse {
6
+ }
7
+ exports.GetAllDeviceInfoResponse2 = GetAllDeviceInfoResponse2;
package/dist/test.js CHANGED
@@ -50,15 +50,29 @@ function test() {
50
50
  // const fileName = "FMQL45T900_SylixOS.skyeye";
51
51
  // const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe"
52
52
  // const port = "50066"
53
- const pathSkyEye = "D:/data/case/c6713_timer_test";
54
- const fileName = "c6k.skyeye";
55
- const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe";
53
+ const pathSkyEye = "G:/SkyEye/demo/c6713_demo";
54
+ const fileName = "G:/SkyEye/demo/c6713_demo/c6713_demo.skyeye";
55
+ const skyeyeDir = "G:/SkyEye/opt/skyeye/bin/skyeye.exe";
56
56
  const port = "50053";
57
57
  const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port);
58
58
  const t = yield client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir);
59
- client.runCommand();
60
- const response = yield client.runToTime("c67x_core_0", "1");
61
- console.log("response:", response);
59
+ yield client.runCommand();
60
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
61
+ let response = yield client.stopCommand();
62
+ console.log("response:", response);
63
+ response = yield client.getMemoryValue('c67x_core_0', '16120', '1', 8);
64
+ console.log("response:", response);
65
+ response = yield client.getBitValue('c67x_core_0', '16120', 1, 8);
66
+ console.log("response:", response);
67
+ response = yield client.setBitValue('c67x_core_0', '16120', 1, 0, 8);
68
+ console.log("response:", response);
69
+ response = yield client.getMemoryValue('c67x_core_0', '16120', '1', 8);
70
+ console.log("response:", response);
71
+ response = yield client.getBitValue('c67x_core_0', '16120', 1, 8);
72
+ console.log("response:", response);
73
+ }), 2000);
74
+ // response = client.setBitValue('c67x_core_0', '0x1000','1', 8)
75
+ // console.log("response:", response)
62
76
  // const responseCpuList = await client.getCpuList()
63
77
  // console.log("responseCpuList:", responseCpuList)
64
78
  // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', 50056);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -107,6 +107,32 @@ export class RequestFactory {
107
107
  return request;
108
108
  }
109
109
 
110
+ public getBitValue(cpuName: string, baseAddr: string, bitIndex: number, addressWidth?: number) {
111
+ const baseRequest = new BaseRequest("SE_get_bit_value");
112
+ const args: { [key: string]: any } = {};
113
+ args.cpuname = cpuName;
114
+ args.baseaddr = "0x" + baseAddr;
115
+ args.bitindex = bitIndex;
116
+ args.address_width = addressWidth;
117
+ baseRequest.setArgs(args)
118
+ const request = new JSONRequest()
119
+ request.setRequest(baseRequest.toJSONString());
120
+ return request;
121
+ }
122
+ public setBitValue(cpuName: string, baseAddr: string, bitIndex: number, value: number, addressWidth?: number) {
123
+ const baseRequest = new BaseRequest("SE_set_bit_value");
124
+ const args: { [key: string]: any } = {};
125
+ args.cpuname = cpuName;
126
+ args.baseaddr = "0x" + baseAddr;
127
+ args.bitindex = bitIndex;
128
+ args.value = value;
129
+ args.address_width = addressWidth;
130
+ baseRequest.setArgs(args)
131
+ const request = new JSONRequest()
132
+ request.setRequest(baseRequest.toJSONString());
133
+ return request;
134
+ }
135
+
110
136
 
111
137
 
112
138
  public enableDeviceWork(deviceName: string) {
@@ -12,6 +12,7 @@ import { Register } from './models/Register';
12
12
  import { GetDeviceTreeResponse } from './response/GetDeviceTreeResponse';
13
13
  import { ParseBoardUtils } from './utils/ParseBoardUtils';
14
14
  import { GetAllDeviceInfoResponse } from './response/GetAllDeviceInfoResponse';
15
+ import { GetAllDeviceInfoResponse2 } from './response/GetAllDeviceInfoResponse2';
15
16
  import { GetRamAddrInfoResponse } from './response/GetRamAddrInfoResponse';
16
17
  import { Device } from './models/Device';
17
18
  import { FaultInjectType } from './models/FaultInjectType';
@@ -554,6 +555,23 @@ export class SkyEyeClient extends JSONTransmissionClient {
554
555
  }
555
556
  }
556
557
 
558
+ public async setBitValue(cpuName: string, baseAddr: string, bitIndex: number, value: number, addressWidth?: number) {
559
+ try {
560
+ return await this.call(RequestFactory.getInstance().setBitValue(cpuName, baseAddr, bitIndex , value, addressWidth));
561
+ } catch (error) {
562
+ console.error("Error during getAddressingSpaceDefault:", error);
563
+ throw error;
564
+ }
565
+ }
566
+
567
+ public async getBitValue(cpuName: string, baseAddr: string, bitIndex: number, addressWidth?: number) {
568
+ try {
569
+ return await this.call(RequestFactory.getInstance().getBitValue(cpuName, baseAddr, bitIndex, addressWidth));
570
+ } catch (error) {
571
+ console.error("Error during getAddressingSpaceDefault:", error);
572
+ throw error;
573
+ }
574
+ }
557
575
 
558
576
 
559
577
  public async getCpuRegisters(cpuName: string) {
@@ -786,6 +804,24 @@ export class SkyEyeClient extends JSONTransmissionClient {
786
804
  }
787
805
 
788
806
 
807
+ public async getAllDeviceInfo2() {
808
+ const response = new GetAllDeviceInfoResponse2();
809
+ try {
810
+ const call = await this.call(RequestFactory.getInstance().getAllDeviceInfo());
811
+ if (call != null) {
812
+ response.isSuccess = true;
813
+ response.result = call;
814
+ } else {
815
+ throw new SkyEyeSDKException(String(call.error));
816
+ }
817
+ } catch (error) {
818
+ console.error("Error during getAllDeviceInfo:", error);
819
+ throw error;
820
+ }
821
+ return response;
822
+ }
823
+
824
+
789
825
  public async getRamAddrInfo(machName: string, addr: string) {
790
826
  const response = new GetRamAddrInfoResponse();
791
827
  try {
@@ -2,6 +2,7 @@ import { SkyEyeClient } from "./SkyEyeClient";
2
2
  import { RequestFactory } from "./RequestFactory";
3
3
  import { JSONResponse } from "./proto/skyeye_rpc_pb";
4
4
  import { time } from "console";
5
+ import { StateState } from "./response/GetRunningStateResponse";
5
6
 
6
7
  class SkyEyeClientFactory {
7
8
  private static _instance: SkyEyeClientFactory;
@@ -26,11 +27,16 @@ class SkyEyeClientFactory {
26
27
  public async createConnectedClientTime(ip: string, port: string, time: number): Promise<SkyEyeClient> {
27
28
  const client = this.createClient(ip, port);
28
29
  const startTime: number = Date.now();
30
+ let isTimeout = true
29
31
  while (Date.now() - startTime < time * 1000) {
30
32
  try {
31
- const response = client.getCurrentRunningState();
33
+ const response = await client.getCurrentRunningState();
32
34
  console.log("response:", response);
33
- break;
35
+ if (response.getState() !== StateState.QUITED) {
36
+ isTimeout = false
37
+ break
38
+ }
39
+
34
40
  } catch (error) {
35
41
  try {
36
42
  await new Promise(resolve => setTimeout(resolve, 100));
@@ -39,6 +45,9 @@ class SkyEyeClientFactory {
39
45
  }
40
46
  }
41
47
  }
48
+ if (isTimeout) {
49
+ throw new Error('连接超时')
50
+ }
42
51
  return client;
43
52
  }
44
53
  }
@@ -0,0 +1,6 @@
1
+ import { Board } from "../models/Board";
2
+ import { BaseResponse } from "./BaseResponse";
3
+
4
+ export class GetAllDeviceInfoResponse2 extends BaseResponse{
5
+ result: object;
6
+ }
package/test.ts CHANGED
@@ -57,15 +57,30 @@ async function test() {
57
57
  // const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe"
58
58
  // const port = "50066"
59
59
 
60
- const pathSkyEye = "D:/data/case/c6713_timer_test";
61
- const fileName = "c6k.skyeye";
62
- const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe"
60
+ const pathSkyEye = "G:/SkyEye/demo/c6713_demo";
61
+ const fileName = "G:/SkyEye/demo/c6713_demo/c6713_demo.skyeye";
62
+ const skyeyeDir = "G:/SkyEye/opt/skyeye/bin/skyeye.exe"
63
63
  const port = "50053"
64
64
  const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port);
65
65
  const t = await client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir)
66
- client.runCommand();
67
- const response = await client.runToTime("c67x_core_0","1");
68
- console.log("response:", response)
66
+ await client.runCommand()
67
+ setTimeout(async () => {
68
+ let response = await client.stopCommand()
69
+ console.log("response:", response)
70
+ response = await client.getMemoryValue('c67x_core_0', '16120','1', 8)
71
+ console.log("response:", response)
72
+ response = await client.getBitValue('c67x_core_0', '16120',1, 8)
73
+ console.log("response:", response)
74
+ response = await client.setBitValue('c67x_core_0', '16120',1, 0, 8)
75
+ console.log("response:", response)
76
+ response = await client.getMemoryValue('c67x_core_0', '16120','1', 8)
77
+ console.log("response:", response)
78
+ response = await client.getBitValue('c67x_core_0', '16120',1, 8)
79
+ console.log("response:", response)
80
+ },2000)
81
+
82
+ // response = client.setBitValue('c67x_core_0', '0x1000','1', 8)
83
+ // console.log("response:", response)
69
84
 
70
85
  // const responseCpuList = await client.getCpuList()
71
86
  // console.log("responseCpuList:", responseCpuList)