skyeye-sdk-js 1.3.2 → 1.3.5

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.
@@ -11,6 +11,7 @@ export declare class RequestFactory {
11
11
  quitCommand(): JSONRequest;
12
12
  getCpuList(): JSONRequest;
13
13
  getMemoryValue(cpuName: string, baseAddr: string, length: string): JSONRequest;
14
+ setMemoryValue(cpuName: string, baseAddr: string, value: string, length: string): JSONRequest;
14
15
  enableDeviceWork(deviceName: string): JSONRequest;
15
16
  disableDeviceWork(deviceName: string): JSONRequest;
16
17
  changeDir(path: string): JSONRequest;
@@ -19,8 +20,8 @@ export declare class RequestFactory {
19
20
  getCurrentSimulationTime(): JSONRequest;
20
21
  getCurrentPC(cpuName: string): JSONRequest;
21
22
  getCpuMips(cpuName: string): JSONRequest;
22
- getGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType): JSONRequest;
23
- setGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType, value: string): JSONRequest;
23
+ getGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType): JSONRequest;
24
+ setGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType, value: string): JSONRequest;
24
25
  getDeviceList(): JSONRequest;
25
26
  getDeviceTree(): JSONRequest;
26
27
  setRegisterValue(machName: string, deviceName: string, regName: string, value: string): JSONRequest;
@@ -60,6 +60,19 @@ class RequestFactory {
60
60
  request.setRequest(baseRequest.toJSONString());
61
61
  return request;
62
62
  }
63
+ setMemoryValue(cpuName, baseAddr, value, length) {
64
+ const baseRequest = new BaseRequest_1.BaseRequest("SE_set_memory_value");
65
+ const args = {};
66
+ args.cpuname = cpuName;
67
+ args.baseaddr = "0x" + baseAddr;
68
+ args.value = value;
69
+ args.length = length;
70
+ baseRequest.setArgs(args);
71
+ const request = new skyeye_rpc_pb_1.JSONRequest();
72
+ request.setRequest(baseRequest.toJSONString());
73
+ console.log("setMemoryValue:", request);
74
+ return request;
75
+ }
63
76
  enableDeviceWork(deviceName) {
64
77
  const baseRequest = new BaseRequest_1.BaseRequest("SE_enable_device_work");
65
78
  const args = {};
@@ -137,6 +150,7 @@ class RequestFactory {
137
150
  baseRequest.setArgs(args);
138
151
  const request = new skyeye_rpc_pb_1.JSONRequest();
139
152
  request.setRequest(baseRequest.toJSONString());
153
+ console.log("request:", request);
140
154
  return request;
141
155
  }
142
156
  setGlobalVarValue(cpuName, varName, bytesNum, valueType, value) {
@@ -144,12 +158,13 @@ class RequestFactory {
144
158
  const args = {};
145
159
  args.cpu_name = cpuName;
146
160
  args.var_name = varName;
147
- args.value_bytes_number = String(bytesNum);
161
+ args.value_bytes_number = bytesNum;
148
162
  args.value_type = valueType;
149
163
  args.value = value;
150
164
  baseRequest.setArgs(args);
151
165
  const request = new skyeye_rpc_pb_1.JSONRequest();
152
166
  request.setRequest(baseRequest.toJSONString());
167
+ console.log('setGlobalVarValue:', request);
153
168
  return request;
154
169
  }
155
170
  getDeviceList() {
@@ -40,14 +40,16 @@ export declare class SkyEyeClient extends JSONTransmissionClient {
40
40
  getCurrentPC(): Promise<any>;
41
41
  getCpuMips(cpuName: string): Promise<any>;
42
42
  getCurrentCpuMips(): Promise<any>;
43
- getGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType): Promise<any>;
43
+ getGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType): Promise<any>;
44
44
  getGlobalVarValueDefault(varName: string, valueType: GlobalVarType): Promise<any>;
45
- setGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType, value: string): Promise<any>;
45
+ setGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType, value: string): Promise<any>;
46
46
  setGlobalVarValueDefault(varName: string, valueType: GlobalVarType, value: string): Promise<any>;
47
- getMemoryValue(cpuName: string, baseAddr: string, length: string): Promise<any>;
48
47
  getAddressingSpace(cpuName: string, baseAddr: string, length: string): Promise<any>;
48
+ getMemoryValue(cpuName: string, baseAddr: string, length: string): Promise<any>;
49
49
  getMemoryValueDefault(baseAddr: string, length: string): Promise<any>;
50
50
  getAddressingSpaceDefault(baseAddr: string, length: string): Promise<any>;
51
+ setMemoryValue(cpuName: string, baseAddr: string, value: string, length: string): Promise<any>;
52
+ setMemoryValueDefault(baseAddr: string, value: string, length: string): Promise<any>;
51
53
  getCpuRegisters(cpuName: string): Promise<GetCpuRegisterInfoResponse>;
52
54
  getCpuRegistersDefault(): Promise<GetCpuRegisterInfoResponse>;
53
55
  setCpuRegisterValueDefault(register: Register, value: string): Promise<any>;
@@ -147,6 +147,7 @@ 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));
150
151
  console.error("Error during gRPC call:", error);
151
152
  throw error;
152
153
  }
@@ -435,7 +436,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
435
436
  const cpuList = (yield this.getCpuList()).getCpuList();
436
437
  if (cpuList != null && cpuList.length > 0) {
437
438
  try {
438
- return yield this.call(RequestFactory_1.RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, "4", valueType));
439
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, 4, valueType));
439
440
  }
440
441
  catch (error) {
441
442
  console.error("Error during getGlobalVarValueDefault:", error);
@@ -464,7 +465,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
464
465
  const cpuList = (yield this.getCpuList()).getCpuList();
465
466
  if (cpuList != null && cpuList.length > 0) {
466
467
  try {
467
- return yield this.call(RequestFactory_1.RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, "4", valueType, value));
468
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, 8, valueType, value));
468
469
  }
469
470
  catch (error) {
470
471
  console.error("Error during setGlobalVarValueDefault:", error);
@@ -477,24 +478,24 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
477
478
  }
478
479
  });
479
480
  }
480
- getMemoryValue(cpuName, baseAddr, length) {
481
+ getAddressingSpace(cpuName, baseAddr, length) {
481
482
  return __awaiter(this, void 0, void 0, function* () {
482
483
  try {
483
- return this.getAddressingSpace(cpuName, baseAddr, length);
484
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().getMemoryValue(cpuName, baseAddr, length));
484
485
  }
485
486
  catch (error) {
486
- console.error("Error during getMemoryValue:", error);
487
+ console.error("Error during getAddressingSpace:", error);
487
488
  throw error;
488
489
  }
489
490
  });
490
491
  }
491
- getAddressingSpace(cpuName, baseAddr, length) {
492
+ getMemoryValue(cpuName, baseAddr, length) {
492
493
  return __awaiter(this, void 0, void 0, function* () {
493
494
  try {
494
- return yield this.call(RequestFactory_1.RequestFactory.getInstance().getMemoryValue(cpuName, baseAddr, length));
495
+ return this.getAddressingSpace(cpuName, baseAddr, length);
495
496
  }
496
497
  catch (error) {
497
- console.error("Error during getAddressingSpace:", error);
498
+ console.error("Error during getMemoryValue:", error);
498
499
  throw error;
499
500
  }
500
501
  });
@@ -528,6 +529,35 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
528
529
  }
529
530
  });
530
531
  }
532
+ setMemoryValue(cpuName, baseAddr, value, length) {
533
+ return __awaiter(this, void 0, void 0, function* () {
534
+ try {
535
+ return yield this.call(RequestFactory_1.RequestFactory.getInstance().setMemoryValue(cpuName, baseAddr, value, length));
536
+ }
537
+ catch (error) {
538
+ console.error("Error during getAddressingSpaceDefault:", error);
539
+ throw error;
540
+ }
541
+ });
542
+ }
543
+ setMemoryValueDefault(baseAddr, value, length) {
544
+ return __awaiter(this, void 0, void 0, function* () {
545
+ const cpuList = (yield this.getCpuList()).getCpuList();
546
+ if (cpuList != null && cpuList.length > 0) {
547
+ try {
548
+ return yield this.setMemoryValue(cpuList[0].getName(), baseAddr, value, length);
549
+ }
550
+ catch (error) {
551
+ console.error("Error during getAddressingSpaceDefault:", error);
552
+ throw error;
553
+ }
554
+ }
555
+ else {
556
+ console.error("无法获取cpu,请确认cpu是否存在:");
557
+ throw new SkyEyeSDKException_1.SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
558
+ }
559
+ });
560
+ }
531
561
  getCpuRegisters(cpuName) {
532
562
  return __awaiter(this, void 0, void 0, function* () {
533
563
  const response = new GetCpuRegisterInfoResponse_1.GetCpuRegisterInfoResponse();
@@ -559,7 +589,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
559
589
  let result = 0;
560
590
  if (!isNaN(numOffset1) && !isNaN(numOffset2)) {
561
591
  result = numOffset1 - numOffset2;
562
- console.log("Result:", result);
592
+ // console.log("Result:", result);
563
593
  }
564
594
  else {
565
595
  console.log("Invalid offset values.");
package/dist/test.js CHANGED
@@ -11,9 +11,179 @@ 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 json = {
15
+ "id": "4a162d75-3a84-5264-992f-287624830ead",
16
+ "name": "鍙戦€佸唴瀛樻秷鎭祴璇?",
17
+ "overview": "",
18
+ "parentId": "8a6d70cd-bd7a-4871-d2f3-2f4fdf7b5a46",
19
+ "projectId": "15ffe24f-8ca6-4fcf-afe5-fe01027e2ffb",
20
+ "steps": [
21
+ {
22
+ "id": "35846013-6510-fd0a-a046-a98c2f24157b",
23
+ "sendConditions": {
24
+ "id": "b3c97e92-7367-63ba-6a6b-5f7ca590164c",
25
+ "name": "杩愯0.5s",
26
+ "projectId": "15ffe24f-8ca6-4fcf-afe5-fe01027e2ffb",
27
+ "overview": "",
28
+ "relationship": "A",
29
+ "child": [
30
+ {
31
+ "id": "5ba88de6-a224-0e80-6585-d5e417b424ce",
32
+ "tag": "A",
33
+ "condition": {
34
+ "type": 1,
35
+ "time": 0.5
36
+ }
37
+ }
38
+ ]
39
+ },
40
+ "expectConditions": {
41
+ "id": "6e265328-255e-d7e3-11fd-0a4211d0d0d6",
42
+ "name": "杩愯0.8s",
43
+ "projectId": "15ffe24f-8ca6-4fcf-afe5-fe01027e2ffb",
44
+ "overview": "",
45
+ "relationship": "A",
46
+ "child": [
47
+ {
48
+ "id": "d9e08452-f88b-8de9-bd20-5d5288987fde",
49
+ "tag": "A",
50
+ "condition": {
51
+ "type": 1,
52
+ "time": 0.8
53
+ }
54
+ }
55
+ ]
56
+ },
57
+ "sends": {
58
+ "templateId": "",
59
+ "name": "鍐呭瓨0x4鍙戦€?",
60
+ "child": [
61
+ {
62
+ "id": "0cd71a92-4e7a-dcb8-d74b-dc6ea8103d02",
63
+ "templdateId": "",
64
+ "name": "鏂扮殑鍙戦€?",
65
+ "target": {
66
+ "type": 3,
67
+ "globalName": "",
68
+ "varType": "",
69
+ "addr": "0x4",
70
+ "length": 4,
71
+ "name": "",
72
+ "deviceName": "",
73
+ "busType": 0,
74
+ "directions": 1,
75
+ "nodes": [
76
+ {
77
+ "name": "鑺傜偣1",
78
+ "rtAddr": "",
79
+ "subAddr": "",
80
+ "id": "row_253"
81
+ },
82
+ {
83
+ "name": "鑺傜偣2",
84
+ "rtAddr": "",
85
+ "subAddr": "",
86
+ "id": "row_254"
87
+ }
88
+ ],
89
+ "fields": [
90
+ {
91
+ "name": "field1",
92
+ "dataType": 0,
93
+ "defaultValue": 4,
94
+ "dataRange": [],
95
+ "desc": "this is field1",
96
+ "id": "a89ee30f-ea3d-411e-9bf1-543935a003fc"
97
+ }
98
+ ]
99
+ },
100
+ "dataFormat": 0,
101
+ "value": "4",
102
+ "fields": [
103
+ {
104
+ "name": "field1",
105
+ "dataType": 0,
106
+ "defaultValue": 4,
107
+ "dataRange": [],
108
+ "desc": "this is field1",
109
+ "id": "d4c808d1-47ba-a30e-cfbe-68c0d2772b3d"
110
+ }
111
+ ],
112
+ "_X_ROW_KEY": "row_251"
113
+ }
114
+ ]
115
+ },
116
+ "expects": {
117
+ "templateId": "",
118
+ "name": "鍐呭瓨0x14鍙戦€?",
119
+ "child": [
120
+ {
121
+ "id": "85276ca0-0a09-aa87-ebff-1e6dfc4e5f4f",
122
+ "name": "鏂扮殑棰勬湡",
123
+ "templateId": "",
124
+ "target": {
125
+ "type": 3,
126
+ "globalName": "",
127
+ "varType": "",
128
+ "addr": "0x44",
129
+ "length": 4,
130
+ "name": "",
131
+ "deviceName": "",
132
+ "busType": 0,
133
+ "directions": 1,
134
+ "nodes": [
135
+ {
136
+ "name": "鑺傜偣1",
137
+ "rtAddr": "",
138
+ "subAddr": "",
139
+ "id": "row_299"
140
+ },
141
+ {
142
+ "name": "鑺傜偣2",
143
+ "rtAddr": "",
144
+ "subAddr": "",
145
+ "id": "row_300"
146
+ }
147
+ ],
148
+ "fields": [
149
+ {
150
+ "name": "field1",
151
+ "dataType": 0,
152
+ "defaultValue": 4,
153
+ "dataRange": [],
154
+ "desc": "this is field1",
155
+ "id": "ef2b8873-516c-a338-a8d0-5e8eda5fa08b"
156
+ }
157
+ ]
158
+ },
159
+ "dataFormat": 0,
160
+ "value": "8",
161
+ "fields": [
162
+ {
163
+ "name": "field1",
164
+ "dataType": 0,
165
+ "defaultValue": 4,
166
+ "dataRange": [],
167
+ "desc": "this is field1",
168
+ "id": "379506c9-33d2-167d-6c22-8e0ca8559c0a"
169
+ }
170
+ ],
171
+ "_X_ROW_KEY": "row_297"
172
+ }
173
+ ]
174
+ },
175
+ "select": true
176
+ }
177
+ ],
178
+ "settings": {
179
+ "timeout": ""
180
+ },
181
+ "createdAt": "2024-06-05T02:18:27.630Z",
182
+ "updatedAt": "2024-06-11T06:37:05.487Z",
183
+ "results": []
184
+ };
14
185
  function test() {
15
186
  return __awaiter(this, void 0, void 0, function* () {
16
- const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
17
187
  // console.log("Connected to SkyEye server");
18
188
  // await client.getDeviceList();
19
189
  // await client.getCurrentCpuMips();
@@ -26,22 +196,59 @@ function test() {
26
196
  // const response = await client.getMemoryValueDefault(1, 16);
27
197
  // const response = await client.getMemoryValue("c7s",0,16);
28
198
  // console.log("结果response:", response)
29
- const pathSkyEye = "D:/data/case/c6713_demo";
30
- const fileName = "c6713_demo.skyeye";
31
- const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe";
32
- const port = "50051";
33
199
  // await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
34
- yield client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir);
35
- const res = yield client.getCurrentRunningState();
36
- console.log("state:", res.state);
37
- // setTimeout(async ()=>{
38
- // const quitResponse = await client.quitCommand()
39
- // console.log("quitResponse",quitResponse)
40
- // const response = await client.stopGrpcService("")
41
- // console.log("stopGrpcService",response)
42
- // },6000)
43
- // GrpcUtil.initAndRunExample();
44
- // const bean:string = '{"id":"33d209da-2459-4e49-97c3-5b1509bc638c","steps":[{"condition":{"type":10,"value":"123"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}},{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}}],"expects":[{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":3,"addr":"2221"}}}]}';
200
+ // const pathSkyEye = "D:/data/case/c6713_demo";
201
+ // const fileName = "c6713_demo.skyeye";
202
+ // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
203
+ // const port = "50051"
204
+ // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
205
+ // await client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir)
206
+ // const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
207
+ // const fileName = "c6713_fc_1553b.skyeye";
208
+ // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
209
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
210
+ // const response =await client.getCurrentRunningState()
211
+ // const response = await client.getMemoryValueDefault("128","4")
212
+ const response = yield client.getGlobalVarValueDefault("number_a", "int");
213
+ // const response = await client.setGlobalVarValueDefault("number_a", "int", "12")
214
+ // const response = await client.getMemoryValueDefault("10001", "1")
215
+ console.log("response:", response);
216
+ //启动多个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)
45
252
  });
46
253
  }
47
254
  test();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.3.2",
3
+ "version": "1.3.5",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,6 +27,7 @@
27
27
  "google-protobuf": "^3.21.2",
28
28
  "lodash": "^4.6.1",
29
29
  "minimist": "^1.2.0",
30
- "protobufjs": "^7.2.6"
30
+ "protobufjs": "^7.2.6",
31
+ "skyeye-sdk-js": "^1.3.2"
31
32
  }
32
33
  }
@@ -73,6 +73,21 @@ export class RequestFactory {
73
73
  request.setRequest(baseRequest.toJSONString());
74
74
  return request;
75
75
  }
76
+ public setMemoryValue(cpuName: string, baseAddr: string, value: string, length: string) {
77
+ const baseRequest = new BaseRequest("SE_set_memory_value");
78
+ const args: { [key: string]: string } = {};
79
+ args.cpuname = cpuName;
80
+ args.baseaddr = "0x" + baseAddr;
81
+ args.value = value;
82
+ args.length = length;
83
+ baseRequest.setArgs(args)
84
+ const request = new JSONRequest()
85
+ request.setRequest(baseRequest.toJSONString());
86
+ console.log("setMemoryValue:",request)
87
+ return request;
88
+ }
89
+
90
+
76
91
 
77
92
  public enableDeviceWork(deviceName: string) {
78
93
  const baseRequest = new BaseRequest("SE_enable_device_work");
@@ -153,10 +168,9 @@ export class RequestFactory {
153
168
  return request;
154
169
  }
155
170
 
156
- public getGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType) {
171
+ public getGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType) {
157
172
  const baseRequest = new BaseRequest("SE_get_global_variable_value");
158
- const args: { [key: string]: string } = {};
159
-
173
+ const args: { [key: string]: any } = {};
160
174
  args.cpu_name = cpuName;
161
175
  args.var_name = varName;
162
176
  args.value_bytes_number = bytesNum
@@ -164,21 +178,23 @@ export class RequestFactory {
164
178
  baseRequest.setArgs(args)
165
179
  const request = new JSONRequest()
166
180
  request.setRequest(baseRequest.toJSONString());
181
+ console.log("request:", request)
167
182
  return request;
168
183
  }
169
184
 
170
185
 
171
- public setGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType, value: string) {
186
+ public setGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType, value: string) {
172
187
  const baseRequest = new BaseRequest("SE_set_global_variable_value");
173
- const args: { [key: string]: string } = {};
188
+ const args: { [key: string]: any } = {};
174
189
  args.cpu_name = cpuName;
175
190
  args.var_name = varName;
176
- args.value_bytes_number = String(bytesNum);
191
+ args.value_bytes_number = bytesNum
177
192
  args.value_type = valueType;
178
193
  args.value = value;
179
194
  baseRequest.setArgs(args)
180
195
  const request = new JSONRequest()
181
196
  request.setRequest(baseRequest.toJSONString());
197
+ console.log('setGlobalVarValue:', request)
182
198
  return request;
183
199
  }
184
200
 
@@ -214,7 +230,7 @@ export class RequestFactory {
214
230
  return request;
215
231
  }
216
232
 
217
-
233
+
218
234
  public getAllDeviceInfo() {
219
235
  const baseRequest = new BaseRequest("SE_get_all_fault_inject_device_info");
220
236
  const request = new JSONRequest()
@@ -223,7 +239,7 @@ export class RequestFactory {
223
239
  }
224
240
 
225
241
 
226
- public getRamAddrInfo(machName:string,addr:string){
242
+ public getRamAddrInfo(machName: string, addr: string) {
227
243
  const baseRequest = new BaseRequest("SE_get_mem_device_addr_info");
228
244
  const args: { [key: string]: string } = {};
229
245
  args.machName = machName;
@@ -237,7 +253,7 @@ export class RequestFactory {
237
253
 
238
254
 
239
255
 
240
- public setFaultInject(machName:string,deviceName:string,addr:string,bit:string,mode:string){
256
+ public setFaultInject(machName: string, deviceName: string, addr: string, bit: string, mode: string) {
241
257
  const baseRequest = new BaseRequest("SE_set_fault_inject");
242
258
  const args: { [key: string]: string } = {};
243
259
  args.machName = machName;
@@ -253,7 +269,7 @@ export class RequestFactory {
253
269
 
254
270
 
255
271
 
256
- public deleteFaultInject(machName:string,deviceName:string,addr:string,bit:string,mode:string){
272
+ public deleteFaultInject(machName: string, deviceName: string, addr: string, bit: string, mode: string) {
257
273
  const baseRequest = new BaseRequest("SE_delete_fault");
258
274
  const args: { [key: string]: string } = {};
259
275
  args.machName = machName;
@@ -268,7 +284,7 @@ export class RequestFactory {
268
284
  }
269
285
 
270
286
 
271
-
287
+
272
288
 
273
289
  public getFaultInjectList() {
274
290
  const baseRequest = new BaseRequest("SE_get_fault_inject_list");
@@ -279,11 +295,11 @@ export class RequestFactory {
279
295
 
280
296
 
281
297
 
282
- public getDisassembleInfo(cpuName:string,startAddr:string,nums:string){
298
+ public getDisassembleInfo(cpuName: string, startAddr: string, nums: string) {
283
299
  const baseRequest = new BaseRequest("SE_get_disassemble_info");
284
300
  const args: { [key: string]: string } = {};
285
301
  args.cpuname = cpuName;
286
- args.startAddr = "0x"+startAddr
302
+ args.startAddr = "0x" + startAddr
287
303
  args.length = nums
288
304
  baseRequest.setArgs(args)
289
305
  const request = new JSONRequest()
@@ -295,7 +311,7 @@ export class RequestFactory {
295
311
 
296
312
 
297
313
 
298
- public singleStep(cpuName:string){
314
+ public singleStep(cpuName: string) {
299
315
  const baseRequest = new BaseRequest("SE_system_step");
300
316
  const args: { [key: string]: string } = {};
301
317
  args.cpuname = cpuName;
@@ -306,7 +322,7 @@ export class RequestFactory {
306
322
  }
307
323
 
308
324
 
309
- public getcpuRegisterInfo(cpuName:string){
325
+ public getcpuRegisterInfo(cpuName: string) {
310
326
  const baseRequest = new BaseRequest("SE_get_cpu_register_info");
311
327
  const args: { [key: string]: string } = {};
312
328
  args.cpuname = cpuName;
@@ -109,6 +109,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
109
109
  // this.printResponseLog(ackObj)
110
110
  return ackObj;
111
111
  } catch (error) {
112
+ console.error("Error during gRPC request:", JSON.stringify(request));
112
113
  console.error("Error during gRPC call:", error);
113
114
  throw error;
114
115
  }
@@ -370,7 +371,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
370
371
  }
371
372
 
372
373
 
373
- public async getGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType) {
374
+ public async getGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType) {
374
375
  try {
375
376
  return await this.call(RequestFactory.getInstance().getGlobalVarValue(cpuName, varName, bytesNum, valueType))
376
377
  } catch (error) {
@@ -386,7 +387,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
386
387
  const cpuList = (await this.getCpuList()).getCpuList();
387
388
  if (cpuList != null && cpuList.length > 0) {
388
389
  try {
389
- return await this.call(RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, "4", valueType));
390
+ return await this.call(RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, 4, valueType));
390
391
  } catch (error) {
391
392
  console.error("Error during getGlobalVarValueDefault:", error);
392
393
  throw error;
@@ -401,7 +402,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
401
402
 
402
403
 
403
404
 
404
- public async setGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType, value: string) {
405
+ public async setGlobalVarValue(cpuName: string, varName: string, bytesNum: number, valueType: GlobalVarType, value: string) {
405
406
  try {
406
407
  return await this.call(RequestFactory.getInstance().setGlobalVarValue(cpuName, varName, bytesNum, valueType, value))
407
408
  } catch (error) {
@@ -414,7 +415,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
414
415
  const cpuList = (await this.getCpuList()).getCpuList();
415
416
  if (cpuList != null && cpuList.length > 0) {
416
417
  try {
417
- return await this.call(RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, "4", valueType, value));
418
+ return await this.call(RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, 8, valueType, value));
418
419
  } catch (error) {
419
420
  console.error("Error during setGlobalVarValueDefault:", error);
420
421
  throw error;
@@ -426,14 +427,6 @@ export class SkyEyeClient extends JSONTransmissionClient {
426
427
  }
427
428
 
428
429
 
429
- public async getMemoryValue(cpuName: string, baseAddr: string, length: string) {
430
- try {
431
- return this.getAddressingSpace(cpuName, baseAddr, length);
432
- } catch (error) {
433
- console.error("Error during getMemoryValue:", error);
434
- throw error;
435
- }
436
- }
437
430
 
438
431
 
439
432
  public async getAddressingSpace(cpuName: string, baseAddr: string, length: string) {
@@ -444,9 +437,14 @@ export class SkyEyeClient extends JSONTransmissionClient {
444
437
  throw error;
445
438
  }
446
439
  }
447
-
448
-
449
-
440
+ public async getMemoryValue(cpuName: string, baseAddr: string, length: string) {
441
+ try {
442
+ return this.getAddressingSpace(cpuName, baseAddr, length);
443
+ } catch (error) {
444
+ console.error("Error during getMemoryValue:", error);
445
+ throw error;
446
+ }
447
+ }
450
448
  public async getMemoryValueDefault(baseAddr: string, length: string) {
451
449
  try {
452
450
  return this.getAddressingSpaceDefault(baseAddr, length);
@@ -455,8 +453,6 @@ export class SkyEyeClient extends JSONTransmissionClient {
455
453
  throw error;
456
454
  }
457
455
  }
458
-
459
-
460
456
  public async getAddressingSpaceDefault(baseAddr: string, length: string) {
461
457
  const cpuList = (await this.getCpuList()).getCpuList();
462
458
  if (cpuList != null && cpuList.length > 0) {
@@ -472,6 +468,30 @@ export class SkyEyeClient extends JSONTransmissionClient {
472
468
  }
473
469
  }
474
470
 
471
+ public async setMemoryValue(cpuName: string, baseAddr: string, value: string, length: string) {
472
+ try {
473
+ return await this.call(RequestFactory.getInstance().setMemoryValue(cpuName, baseAddr, value, length));
474
+ } catch (error) {
475
+ console.error("Error during getAddressingSpaceDefault:", error);
476
+ throw error;
477
+ }
478
+ }
479
+ public async setMemoryValueDefault(baseAddr: string, value: string, length: string) {
480
+ const cpuList = (await this.getCpuList()).getCpuList();
481
+ if (cpuList != null && cpuList.length > 0) {
482
+ try {
483
+ return await this.setMemoryValue(cpuList[0].getName(), baseAddr, value, length)
484
+ } catch (error) {
485
+ console.error("Error during getAddressingSpaceDefault:", error);
486
+ throw error;
487
+ }
488
+ } else {
489
+ console.error("无法获取cpu,请确认cpu是否存在:");
490
+ throw new SkyEyeSDKException("无法获取cpu,请确认cpu是否存在:");
491
+ }
492
+ }
493
+
494
+
475
495
 
476
496
  public async getCpuRegisters(cpuName: string) {
477
497
  const response = new GetCpuRegisterInfoResponse();
@@ -504,7 +524,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
504
524
  let result: number = 0;
505
525
  if (!isNaN(numOffset1) && !isNaN(numOffset2)) {
506
526
  result = numOffset1 - numOffset2;
507
- console.log("Result:", result);
527
+ // console.log("Result:", result);
508
528
  } else {
509
529
  console.log("Invalid offset values.");
510
530
  }
package/test.ts CHANGED
@@ -5,8 +5,184 @@ import { ServiceError } from "@grpc/grpc-js";
5
5
  const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory')
6
6
  const { SkyEyeClient } = require('./src/SkyEyeClient')
7
7
 
8
+
9
+
10
+ const json = {
11
+ "id": "4a162d75-3a84-5264-992f-287624830ead",
12
+ "name": "鍙戦€佸唴瀛樻秷鎭祴璇?",
13
+ "overview": "",
14
+ "parentId": "8a6d70cd-bd7a-4871-d2f3-2f4fdf7b5a46",
15
+ "projectId": "15ffe24f-8ca6-4fcf-afe5-fe01027e2ffb",
16
+ "steps": [
17
+ {
18
+ "id": "35846013-6510-fd0a-a046-a98c2f24157b",
19
+ "sendConditions": {
20
+ "id": "b3c97e92-7367-63ba-6a6b-5f7ca590164c",
21
+ "name": "杩愯0.5s",
22
+ "projectId": "15ffe24f-8ca6-4fcf-afe5-fe01027e2ffb",
23
+ "overview": "",
24
+ "relationship": "A",
25
+ "child": [
26
+ {
27
+ "id": "5ba88de6-a224-0e80-6585-d5e417b424ce",
28
+ "tag": "A",
29
+ "condition": {
30
+ "type": 1,
31
+ "time": 0.5
32
+ }
33
+ }
34
+ ]
35
+ },
36
+ "expectConditions": {
37
+ "id": "6e265328-255e-d7e3-11fd-0a4211d0d0d6",
38
+ "name": "杩愯0.8s",
39
+ "projectId": "15ffe24f-8ca6-4fcf-afe5-fe01027e2ffb",
40
+ "overview": "",
41
+ "relationship": "A",
42
+ "child": [
43
+ {
44
+ "id": "d9e08452-f88b-8de9-bd20-5d5288987fde",
45
+ "tag": "A",
46
+ "condition": {
47
+ "type": 1,
48
+ "time": 0.8
49
+ }
50
+ }
51
+ ]
52
+ },
53
+ "sends": {
54
+ "templateId": "",
55
+ "name": "鍐呭瓨0x4鍙戦€?",
56
+ "child": [
57
+ {
58
+ "id": "0cd71a92-4e7a-dcb8-d74b-dc6ea8103d02",
59
+ "templdateId": "",
60
+ "name": "鏂扮殑鍙戦€?",
61
+ "target": {
62
+ "type": 3,
63
+ "globalName": "",
64
+ "varType": "",
65
+ "addr": "0x4",
66
+ "length": 4,
67
+ "name": "",
68
+ "deviceName": "",
69
+ "busType": 0,
70
+ "directions": 1,
71
+ "nodes": [
72
+ {
73
+ "name": "鑺傜偣1",
74
+ "rtAddr": "",
75
+ "subAddr": "",
76
+ "id": "row_253"
77
+ },
78
+ {
79
+ "name": "鑺傜偣2",
80
+ "rtAddr": "",
81
+ "subAddr": "",
82
+ "id": "row_254"
83
+ }
84
+ ],
85
+ "fields": [
86
+ {
87
+ "name": "field1",
88
+ "dataType": 0,
89
+ "defaultValue": 4,
90
+ "dataRange": [],
91
+ "desc": "this is field1",
92
+ "id": "a89ee30f-ea3d-411e-9bf1-543935a003fc"
93
+ }
94
+ ]
95
+ },
96
+ "dataFormat": 0,
97
+ "value": "4",
98
+ "fields": [
99
+ {
100
+ "name": "field1",
101
+ "dataType": 0,
102
+ "defaultValue": 4,
103
+ "dataRange": [],
104
+ "desc": "this is field1",
105
+ "id": "d4c808d1-47ba-a30e-cfbe-68c0d2772b3d"
106
+ }
107
+ ],
108
+ "_X_ROW_KEY": "row_251"
109
+ }
110
+ ]
111
+ },
112
+ "expects": {
113
+ "templateId": "",
114
+ "name": "鍐呭瓨0x14鍙戦€?",
115
+ "child": [
116
+ {
117
+ "id": "85276ca0-0a09-aa87-ebff-1e6dfc4e5f4f",
118
+ "name": "鏂扮殑棰勬湡",
119
+ "templateId": "",
120
+ "target": {
121
+ "type": 3,
122
+ "globalName": "",
123
+ "varType": "",
124
+ "addr": "0x44",
125
+ "length": 4,
126
+ "name": "",
127
+ "deviceName": "",
128
+ "busType": 0,
129
+ "directions": 1,
130
+ "nodes": [
131
+ {
132
+ "name": "鑺傜偣1",
133
+ "rtAddr": "",
134
+ "subAddr": "",
135
+ "id": "row_299"
136
+ },
137
+ {
138
+ "name": "鑺傜偣2",
139
+ "rtAddr": "",
140
+ "subAddr": "",
141
+ "id": "row_300"
142
+ }
143
+ ],
144
+ "fields": [
145
+ {
146
+ "name": "field1",
147
+ "dataType": 0,
148
+ "defaultValue": 4,
149
+ "dataRange": [],
150
+ "desc": "this is field1",
151
+ "id": "ef2b8873-516c-a338-a8d0-5e8eda5fa08b"
152
+ }
153
+ ]
154
+ },
155
+ "dataFormat": 0,
156
+ "value": "8",
157
+ "fields": [
158
+ {
159
+ "name": "field1",
160
+ "dataType": 0,
161
+ "defaultValue": 4,
162
+ "dataRange": [],
163
+ "desc": "this is field1",
164
+ "id": "379506c9-33d2-167d-6c22-8e0ca8559c0a"
165
+ }
166
+ ],
167
+ "_X_ROW_KEY": "row_297"
168
+ }
169
+ ]
170
+ },
171
+ "select": true
172
+ }
173
+ ],
174
+ "settings": {
175
+ "timeout": ""
176
+ },
177
+ "createdAt": "2024-06-05T02:18:27.630Z",
178
+ "updatedAt": "2024-06-11T06:37:05.487Z",
179
+ "results": []
180
+ }
181
+
182
+
183
+
8
184
  async function test() {
9
- const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
185
+
10
186
  // console.log("Connected to SkyEye server");
11
187
  // await client.getDeviceList();
12
188
  // await client.getCurrentCpuMips();
@@ -24,27 +200,88 @@ async function test() {
24
200
  // const response = await client.getMemoryValue("c7s",0,16);
25
201
  // console.log("结果response:", response)
26
202
 
27
- const pathSkyEye = "D:/data/case/c6713_demo";
28
- const fileName = "c6713_demo.skyeye";
29
- const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
30
- const port = "50051"
203
+
31
204
  // await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
32
205
 
33
- await client.initSkyEyeAndRun2(pathSkyEye,fileName,port,skyeyeDir)
34
- const res = await client.getCurrentRunningState()
35
- console.log("state:",res.state)
36
206
 
37
-
38
- // setTimeout(async ()=>{
39
- // const quitResponse = await client.quitCommand()
40
- // console.log("quitResponse",quitResponse)
41
- // const response = await client.stopGrpcService("")
42
- // console.log("stopGrpcService",response)
43
- // },6000)
44
207
 
45
- // GrpcUtil.initAndRunExample();
46
208
 
47
- // const bean:string = '{"id":"33d209da-2459-4e49-97c3-5b1509bc638c","steps":[{"condition":{"type":10,"value":"123"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}},{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":2,"addr":"1222"},"data":"0101011101"}}],"expects":[{"condition":{"type":0,"value":"0xff"},"send":{"target":{"type":3,"addr":"2221"}}}]}';
48
-
209
+ // const pathSkyEye = "D:/data/case/c6713_demo";
210
+ // const fileName = "c6713_demo.skyeye";
211
+ // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
212
+
213
+
214
+ // const port = "50051"
215
+ // const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
216
+ // await client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir)
217
+
218
+ // const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
219
+ // const fileName = "c6713_fc_1553b.skyeye";
220
+ // const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
221
+
222
+
223
+ const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
224
+
225
+ // const response =await client.getCurrentRunningState()
226
+ // const response = await client.getMemoryValueDefault("128","4")
227
+ const response = await client.getGlobalVarValueDefault("number_a","int")
228
+ // const response = await client.setGlobalVarValueDefault("number_a", "int", "12")
229
+
230
+
231
+
232
+ // const response = await client.getMemoryValueDefault("10001", "1")
233
+ console.log("response:", response)
234
+
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
+
256
+
257
+
258
+
259
+
260
+
261
+ // setTimeout(async () => {
262
+ // // await map.get(50051).stopGrpcService("")
263
+ // await map.get(50051).quitCommand()
264
+ // }, 2000)
265
+
266
+ // setTimeout(async () => {
267
+ // // await map.get(50052).stopGrpcService("")
268
+ // await map.get(50052).quitCommand()
269
+ // }, 5000)
270
+
271
+ // setTimeout(async () => {
272
+ // // await map.get(50053).stopGrpcService("")
273
+ // await map.get(50053).quitCommand()
274
+ // }, 8000)
275
+
276
+ // setTimeout(async () => {
277
+ // // await map.get(50054).stopGrpcService("")
278
+ // await map.get(50054).quitCommand()
279
+ // }, 11000)
280
+
281
+
49
282
  }
50
283
  test();
284
+
285
+
286
+
287
+