skyeye-sdk-js 1.1.1 → 1.1.3
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.
- package/dist/src/RequestFactory.d.ts +6 -6
- package/dist/src/RequestFactory.js +5 -5
- package/dist/src/SkyEyeClient.d.ts +16 -16
- package/dist/src/SkyEyeClient.js +15 -4
- package/dist/src/models/FaultInjectItem.d.ts +2 -2
- package/dist/src/models/FaultInjectItemInterface.d.ts +2 -2
- package/dist/src/models/Register.d.ts +4 -4
- package/dist/src/models/RegisterInterface.d.ts +4 -4
- package/dist/test.js +30 -13
- package/package.json +1 -1
- package/src/GrpcUtil.js +91 -0
- package/src/RequestFactory.js +259 -0
- package/src/RequestFactory.ts +11 -13
- package/src/SkyEyeClient.js +1272 -0
- package/src/SkyEyeClient.ts +34 -23
- package/src/models/FaultInjectItem.ts +2 -2
- package/src/models/FaultInjectItemInterface.ts +2 -2
- package/src/models/Register.ts +4 -4
- package/src/models/RegisterInterface.ts +4 -4
- package/src/requests/BaseRequest.js +19 -0
- package/src/response/BaseResponse.js +27 -0
- package/test.ts +24 -6
package/src/SkyEyeClient.ts
CHANGED
|
@@ -43,20 +43,20 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
public async RunTestcase(json:string) {
|
|
46
|
+
public async RunTestcase(json: string) {
|
|
47
47
|
try {
|
|
48
48
|
const request = new JSONRequest();
|
|
49
49
|
request.setRequest(json);
|
|
50
50
|
const stream = super.runTestcase(request);
|
|
51
51
|
return stream;
|
|
52
52
|
} catch (error) {
|
|
53
|
-
console.error("Error during
|
|
53
|
+
console.error("Error during RunTestcas2e:", error);
|
|
54
54
|
throw error;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
public async Monitor(json:string) {
|
|
59
|
+
public async Monitor(json: string) {
|
|
60
60
|
try {
|
|
61
61
|
const request = new JSONRequest();
|
|
62
62
|
request.setRequest(json);
|
|
@@ -350,7 +350,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
|
|
353
|
-
public async getGlobalVarValue(cpuName: string, varName: string, bytesNum:
|
|
353
|
+
public async getGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType) {
|
|
354
354
|
try {
|
|
355
355
|
return await this.call(RequestFactory.getInstance().getGlobalVarValue(cpuName, varName, bytesNum, valueType))
|
|
356
356
|
} catch (error) {
|
|
@@ -366,7 +366,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
366
366
|
const cpuList = (await this.getCpuList()).getCpuList();
|
|
367
367
|
if (cpuList != null && cpuList.length > 0) {
|
|
368
368
|
try {
|
|
369
|
-
return await this.call(RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, 4, valueType));
|
|
369
|
+
return await this.call(RequestFactory.getInstance().getGlobalVarValue(cpuList[0].getName(), varName, "4", valueType));
|
|
370
370
|
} catch (error) {
|
|
371
371
|
console.error("Error during getGlobalVarValueDefault:", error);
|
|
372
372
|
throw error;
|
|
@@ -381,7 +381,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
381
381
|
|
|
382
382
|
|
|
383
383
|
|
|
384
|
-
public async setGlobalVarValue(cpuName: string, varName: string, bytesNum:
|
|
384
|
+
public async setGlobalVarValue(cpuName: string, varName: string, bytesNum: string, valueType: GlobalVarType, value: string) {
|
|
385
385
|
try {
|
|
386
386
|
return await this.call(RequestFactory.getInstance().setGlobalVarValue(cpuName, varName, bytesNum, valueType, value))
|
|
387
387
|
} catch (error) {
|
|
@@ -394,7 +394,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
394
394
|
const cpuList = (await this.getCpuList()).getCpuList();
|
|
395
395
|
if (cpuList != null && cpuList.length > 0) {
|
|
396
396
|
try {
|
|
397
|
-
return await this.call(RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, 4, valueType, value));
|
|
397
|
+
return await this.call(RequestFactory.getInstance().setGlobalVarValue(cpuList[0].getName(), varName, "4", valueType, value));
|
|
398
398
|
} catch (error) {
|
|
399
399
|
console.error("Error during setGlobalVarValueDefault:", error);
|
|
400
400
|
throw error;
|
|
@@ -406,7 +406,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
|
|
409
|
-
public async getMemoryValue(cpuName: string, baseAddr:
|
|
409
|
+
public async getMemoryValue(cpuName: string, baseAddr: string, length: string) {
|
|
410
410
|
try {
|
|
411
411
|
return this.getAddressingSpace(cpuName, baseAddr, length);
|
|
412
412
|
} catch (error) {
|
|
@@ -416,7 +416,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
|
|
419
|
-
public async getAddressingSpace(cpuName: string, baseAddr:
|
|
419
|
+
public async getAddressingSpace(cpuName: string, baseAddr: string, length: string) {
|
|
420
420
|
try {
|
|
421
421
|
return await this.call(RequestFactory.getInstance().getMemoryValue(cpuName, baseAddr, length));
|
|
422
422
|
} catch (error) {
|
|
@@ -427,7 +427,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
427
427
|
|
|
428
428
|
|
|
429
429
|
|
|
430
|
-
public async getMemoryValueDefault(baseAddr:
|
|
430
|
+
public async getMemoryValueDefault(baseAddr: string, length: string) {
|
|
431
431
|
try {
|
|
432
432
|
return this.getAddressingSpaceDefault(baseAddr, length);
|
|
433
433
|
} catch (error) {
|
|
@@ -437,7 +437,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
|
|
440
|
-
public async getAddressingSpaceDefault(baseAddr:
|
|
440
|
+
public async getAddressingSpaceDefault(baseAddr: string, length: string) {
|
|
441
441
|
const cpuList = (await this.getCpuList()).getCpuList();
|
|
442
442
|
if (cpuList != null && cpuList.length > 0) {
|
|
443
443
|
try {
|
|
@@ -478,7 +478,18 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
478
478
|
if (r1.offset === r2.offset) {
|
|
479
479
|
return 0;
|
|
480
480
|
}
|
|
481
|
-
|
|
481
|
+
|
|
482
|
+
let numOffset1: number = parseInt(r1.offset);
|
|
483
|
+
let numOffset2: number = parseInt(r2.offset);
|
|
484
|
+
let result: number = 0;
|
|
485
|
+
if (!isNaN(numOffset1) && !isNaN(numOffset2)) {
|
|
486
|
+
result = numOffset1 - numOffset2;
|
|
487
|
+
console.log("Result:", result);
|
|
488
|
+
} else {
|
|
489
|
+
console.log("Invalid offset values.");
|
|
490
|
+
}
|
|
491
|
+
return result > 0 ? 1 : -1;
|
|
492
|
+
// return r1.offset! - r2.offset! > 0 ? 1 : -1;
|
|
482
493
|
});
|
|
483
494
|
});
|
|
484
495
|
} else {
|
|
@@ -508,7 +519,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
508
519
|
}
|
|
509
520
|
|
|
510
521
|
|
|
511
|
-
public async setCpuRegisterValueDefault(register: Register, value:
|
|
522
|
+
public async setCpuRegisterValueDefault(register: Register, value: string) {
|
|
512
523
|
try {
|
|
513
524
|
return await this.setCpuRegisterValue(register.getParent().getParent().getName(), register.getParent().getName(), register.getName(), value);
|
|
514
525
|
} catch (error) {
|
|
@@ -518,7 +529,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
518
529
|
}
|
|
519
530
|
|
|
520
531
|
|
|
521
|
-
public async setCpuRegisterValue(boardName: string, cpuName: string, registerName: string, value:
|
|
532
|
+
public async setCpuRegisterValue(boardName: string, cpuName: string, registerName: string, value: string) {
|
|
522
533
|
const deviceTree = await this.getDeviceTree();
|
|
523
534
|
if (!deviceTree.boardMap.has(boardName)) {
|
|
524
535
|
throw new SkyEyeSDKException("未能找到该板卡");
|
|
@@ -612,7 +623,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
612
623
|
}
|
|
613
624
|
|
|
614
625
|
|
|
615
|
-
public async getRamAddrInfo(machName: string, addr:
|
|
626
|
+
public async getRamAddrInfo(machName: string, addr: string) {
|
|
616
627
|
const response = new GetRamAddrInfoResponse();
|
|
617
628
|
try {
|
|
618
629
|
const call = await this.call(RequestFactory.getInstance().getRamAddrInfo(machName, addr))
|
|
@@ -631,7 +642,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
631
642
|
}
|
|
632
643
|
|
|
633
644
|
|
|
634
|
-
public async setRamFaultInjectDefault(device: Device, addr:
|
|
645
|
+
public async setRamFaultInjectDefault(device: Device, addr: string, bit: string, mode: FaultInjectType) {
|
|
635
646
|
try {
|
|
636
647
|
return await this.setRamFaultInject(device.getParent().getName(), device.getName(), addr, bit, mode);
|
|
637
648
|
} catch (error) {
|
|
@@ -641,7 +652,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
641
652
|
|
|
642
653
|
|
|
643
654
|
|
|
644
|
-
public async setRamFaultInject(boardName: string, deviceName: string, addr:
|
|
655
|
+
public async setRamFaultInject(boardName: string, deviceName: string, addr: string, bit: string, mode: FaultInjectType) {
|
|
645
656
|
try {
|
|
646
657
|
return await this.call(RequestFactory.getInstance().setFaultInject(boardName, deviceName, String(addr), String(bit), mode))
|
|
647
658
|
} catch (error) {
|
|
@@ -651,7 +662,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
651
662
|
|
|
652
663
|
|
|
653
664
|
|
|
654
|
-
public async setRegisterFaultInjectDefault(register: Register, bit:
|
|
665
|
+
public async setRegisterFaultInjectDefault(register: Register, bit: string, mode: FaultInjectType) {
|
|
655
666
|
try {
|
|
656
667
|
return await this.setRegisterFaultInject(register.getParent().getParent().getName(), register.getParent().getName(), register.baseAddr, bit, mode)
|
|
657
668
|
} catch (error) {
|
|
@@ -660,7 +671,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
660
671
|
}
|
|
661
672
|
|
|
662
673
|
|
|
663
|
-
public async setRegisterFaultInject(boardName: string, deviceName: string, addr:
|
|
674
|
+
public async setRegisterFaultInject(boardName: string, deviceName: string, addr: string, bit: string, mode: FaultInjectType) {
|
|
664
675
|
try {
|
|
665
676
|
return await this.call(RequestFactory.getInstance().setFaultInject(boardName, deviceName, "0x" + String(addr), String(bit), mode))
|
|
666
677
|
} catch (error) {
|
|
@@ -680,7 +691,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
680
691
|
}
|
|
681
692
|
|
|
682
693
|
|
|
683
|
-
public async deleteFaultInject(boardName: string, deviceName: string, addr:
|
|
694
|
+
public async deleteFaultInject(boardName: string, deviceName: string, addr: string, bit: string, mode: FaultInjectType) {
|
|
684
695
|
try {
|
|
685
696
|
return await this.call(RequestFactory.getInstance().deleteFaultInject(boardName, deviceName, "0x" + String(addr), String(bit), mode))
|
|
686
697
|
} catch (error) {
|
|
@@ -726,7 +737,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
726
737
|
}
|
|
727
738
|
|
|
728
739
|
|
|
729
|
-
public async getDisassembleInfo(cpuName: string, startAddr:
|
|
740
|
+
public async getDisassembleInfo(cpuName: string, startAddr: string, nums: string) {
|
|
730
741
|
const response = new GetDisassembleInfoResponse();
|
|
731
742
|
try {
|
|
732
743
|
const call = await this.call(RequestFactory.getInstance().getDisassembleInfo(cpuName, startAddr, nums))
|
|
@@ -751,7 +762,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
751
762
|
}
|
|
752
763
|
|
|
753
764
|
|
|
754
|
-
public async getDisassembleInfoDefault(startAddr:
|
|
765
|
+
public async getDisassembleInfoDefault(startAddr: string, nums: string) {
|
|
755
766
|
const cpuList = (await this.getCpuList()).getCpuList;
|
|
756
767
|
if (cpuList != null && cpuList.length > 0) {
|
|
757
768
|
return this.getDisassembleInfo(cpuList[0].name, startAddr, nums);
|
|
@@ -816,7 +827,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
816
827
|
client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
|
|
817
828
|
console.log("run_script res:" + response + error);
|
|
818
829
|
|
|
819
|
-
this.runCommand()
|
|
830
|
+
// this.runCommand()
|
|
820
831
|
|
|
821
832
|
return "1";
|
|
822
833
|
});
|
package/src/models/Register.ts
CHANGED
|
@@ -15,22 +15,22 @@ export class Register implements Node {
|
|
|
15
15
|
/**
|
|
16
16
|
* 寄存器的基地址
|
|
17
17
|
*/
|
|
18
|
-
public baseAddr:
|
|
18
|
+
public baseAddr: string | null;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 寄存器位数
|
|
22
22
|
*/
|
|
23
|
-
public bits:
|
|
23
|
+
public bits: string | null;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* 寄存器值
|
|
27
27
|
*/
|
|
28
|
-
public value:
|
|
28
|
+
public value: string | null;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* 寄存器偏移值
|
|
32
32
|
*/
|
|
33
|
-
public offset:
|
|
33
|
+
public offset: string | null;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* 寄存器描述
|
|
@@ -6,9 +6,9 @@ import { DeviceInterface } from './DeviceInterface';
|
|
|
6
6
|
export interface RegisterInterface{
|
|
7
7
|
name: string,
|
|
8
8
|
parent: Node | null,
|
|
9
|
-
baseAddr:
|
|
10
|
-
bits:
|
|
11
|
-
value:
|
|
12
|
-
offset:
|
|
9
|
+
baseAddr: string | null,
|
|
10
|
+
bits: string | null,
|
|
11
|
+
value: string | null,
|
|
12
|
+
offset: string | null,
|
|
13
13
|
description: string
|
|
14
14
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseRequest = void 0;
|
|
4
|
+
var BaseRequest = /** @class */ (function () {
|
|
5
|
+
function BaseRequest(name) {
|
|
6
|
+
this.request = {
|
|
7
|
+
name: name,
|
|
8
|
+
args: null
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
BaseRequest.prototype.toJSONString = function () {
|
|
12
|
+
return JSON.stringify({ request: this.request });
|
|
13
|
+
};
|
|
14
|
+
BaseRequest.prototype.setArgs = function (args) {
|
|
15
|
+
this.request.args = args;
|
|
16
|
+
};
|
|
17
|
+
return BaseRequest;
|
|
18
|
+
}());
|
|
19
|
+
exports.BaseRequest = BaseRequest;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.BaseResponse = void 0;
|
|
19
|
+
var skyeye_rpc_pb_1 = require("../proto/skyeye_rpc_pb");
|
|
20
|
+
var BaseResponse = /** @class */ (function (_super) {
|
|
21
|
+
__extends(BaseResponse, _super);
|
|
22
|
+
function BaseResponse() {
|
|
23
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
}
|
|
25
|
+
return BaseResponse;
|
|
26
|
+
}(skyeye_rpc_pb_1.JSONResponse));
|
|
27
|
+
exports.BaseResponse = BaseResponse;
|
package/test.ts
CHANGED
|
@@ -7,12 +7,12 @@ const { SkyEyeClient } = require('./src/SkyEyeClient')
|
|
|
7
7
|
|
|
8
8
|
async function test() {
|
|
9
9
|
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
10
|
-
console.log("Connected to SkyEye server");
|
|
10
|
+
// console.log("Connected to SkyEye server");
|
|
11
11
|
// await client.getDeviceList();
|
|
12
12
|
// await client.getCurrentCpuMips();
|
|
13
13
|
// await client.runCommand();
|
|
14
14
|
|
|
15
|
-
const response = await client.getCurrentRunningState();
|
|
15
|
+
// const response = await client.getCurrentRunningState();
|
|
16
16
|
|
|
17
17
|
// const response = await client.getGlobalVarValueDefault("a",GlobalVarType.DOUBLE);
|
|
18
18
|
// const response = await client.getGlobalVarValue("cx53123","a",16,GlobalVarType.DOUBLE);
|
|
@@ -22,7 +22,7 @@ async function test() {
|
|
|
22
22
|
|
|
23
23
|
// const response = await client.getMemoryValueDefault(1, 16);
|
|
24
24
|
// const response = await client.getMemoryValue("c7s",0,16);
|
|
25
|
-
console.log("结果response:", response)
|
|
25
|
+
// console.log("结果response:", response)
|
|
26
26
|
|
|
27
27
|
// const pathSkyEye = "D:/data/case/c6713_demo";
|
|
28
28
|
// const fileName = "c6713_demo.skyeye";
|
|
@@ -32,10 +32,28 @@ async function test() {
|
|
|
32
32
|
|
|
33
33
|
// GrpcUtil.initAndRunExample();
|
|
34
34
|
|
|
35
|
-
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"}}}]}';
|
|
36
|
-
const
|
|
35
|
+
// 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"}}}]}';
|
|
36
|
+
const json = {
|
|
37
|
+
id: "memory_test",
|
|
38
|
+
steps: [
|
|
39
|
+
{
|
|
40
|
+
condition: { type: 5, addr: "0x1800000", length: 8 },
|
|
41
|
+
send: { target: { type: 3, addr: "0x4", length: 4 }, data: 50 }
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
condition: { type: 3, addr: "0x1900000", length: 8 },
|
|
45
|
+
send: { target: { type: 3, addr: "0x4", length: 4 }, data: 50 }
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
expects: [
|
|
49
|
+
{ condition: { type: 0 }, expect: { target: { type: 3, addr: "0x8", length: 4 } } }
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const jsonString = JSON.stringify(json);
|
|
54
|
+
const stream = await client.RunTestcase(jsonString);
|
|
37
55
|
stream.on('data', (response: JSONResponse) => {
|
|
38
|
-
console.log('Received response:',
|
|
56
|
+
console.log('Received response:',response);
|
|
39
57
|
});
|
|
40
58
|
stream.on('end', () => {
|
|
41
59
|
console.log('Stream ended');
|