skyeye-sdk-js 1.3.9 → 1.4.0
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 +2 -0
- package/dist/src/RequestFactory.js +19 -0
- package/dist/src/SkyEyeClient.d.ts +2 -0
- package/dist/src/SkyEyeClient.js +22 -0
- package/dist/src/response/RunToTimeResponse.d.ts +4 -0
- package/dist/src/response/RunToTimeResponse.js +10 -0
- package/dist/test.js +23 -380
- package/dist/test_backup1.d.ts +1 -0
- package/dist/test_backup1.js +303 -0
- package/package.json +1 -1
- package/src/RequestFactory.ts +22 -0
- package/src/SkyEyeClient.ts +22 -2
- package/src/response/RunToTimeResponse.ts +9 -0
- package/test.ts +30 -448
- package/test_backup1.ts +365 -0
- package/skyeye-sdk-js-1.3.6.tgz +0 -0
- package/skyeye-sdk-js-1.3.7.tgz +0 -0
- package/skyeye-sdk-js-1.3.8.tgz +0 -0
package/test_backup1.ts
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { JSONResponse } from "./src/proto/skyeye_rpc_pb";
|
|
2
|
+
import { GrpcUtil } from "./src/GrpcUtil";
|
|
3
|
+
import { ServiceError } from "@grpc/grpc-js";
|
|
4
|
+
import { Enum } from "protobufjs";
|
|
5
|
+
|
|
6
|
+
const { SkyEyeClientFactory } = require('./src/SkyEyeClientFactory')
|
|
7
|
+
const { SkyEyeClient } = require('./src/SkyEyeClient')
|
|
8
|
+
|
|
9
|
+
const { Cpu } = require('./src/models/Cpu')
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RegisterItem {
|
|
13
|
+
name: string;
|
|
14
|
+
type: RegisterType; //0 cpu寄存器 1 设备寄存器
|
|
15
|
+
deviceName: string; //设备名称
|
|
16
|
+
boardName: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
enum RegisterType {
|
|
20
|
+
CPU,
|
|
21
|
+
Device
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
async function getAllRegisterList() {
|
|
26
|
+
const allRegister: RegisterItem[] = [];
|
|
27
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
28
|
+
|
|
29
|
+
//通过 getDeviceTree 获取板卡、设备、寄存器层级, 列出所有寄存器列表选择
|
|
30
|
+
const resultTree = await client.getDeviceTree()
|
|
31
|
+
console.log("结果 resultTree:", JSON.stringify(resultTree))
|
|
32
|
+
console.log("结果 keys:", resultTree.boardMap.keys())
|
|
33
|
+
|
|
34
|
+
for (const key of resultTree.boardMap.keys()) {
|
|
35
|
+
const device = resultTree.boardMap.get(key);
|
|
36
|
+
// 在这里对获取到的键值对进行处理
|
|
37
|
+
console.log(`板卡: ${key},设备: ${device.deviceMap}`);
|
|
38
|
+
|
|
39
|
+
if (!device.deviceMap || device.deviceMap.keys().length == 0) {
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const k of device.deviceMap.keys()) {
|
|
44
|
+
const register = device.deviceMap.get(k);
|
|
45
|
+
console.log(`设备: ${k}, 寄存器: ${register}`);
|
|
46
|
+
console.log("寄存器下的寄存器: ", register.registerMap)
|
|
47
|
+
if (!register.registerMap || register.registerMap.keys().length == 0) {
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
getRegisterMap(register, allRegister)
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
console.log("allRegister2:", allRegister.length)
|
|
55
|
+
return allRegister;
|
|
56
|
+
}
|
|
57
|
+
// getAllRegisterList()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function getRegisterMap(bean: any, allRegister: RegisterItem[]) {
|
|
62
|
+
if (!bean.registerMap || bean.registerMap.keys().length == 0) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (const r of bean.registerMap.keys()) {
|
|
67
|
+
const result = bean.registerMap.get(r);
|
|
68
|
+
console.log(`设备: ${r}, 寄存器: ${result}`);
|
|
69
|
+
|
|
70
|
+
const item = new RegisterItem()
|
|
71
|
+
item.name = r.name
|
|
72
|
+
|
|
73
|
+
if (bean instanceof Cpu) {
|
|
74
|
+
console.log(`寄存器类型: ${bean.className}`);
|
|
75
|
+
item.type = RegisterType.CPU
|
|
76
|
+
} else {
|
|
77
|
+
item.type = RegisterType.Device
|
|
78
|
+
}
|
|
79
|
+
allRegister.push(item)
|
|
80
|
+
getRegisterMap(result, allRegister)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
async function setRegister() {
|
|
88
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
89
|
+
const r2 = await client.setDeviceRegisterValue('c6713_0', 'c67x_core_0', 'A7', '34')
|
|
90
|
+
console.log("setRegister:", r2)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function getRegister() {
|
|
94
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
95
|
+
const result = await client.getCpuRegisters("")
|
|
96
|
+
console.log("setRegister:", result)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function getState() {
|
|
100
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
101
|
+
const result = await client.getCurrentRunningState()
|
|
102
|
+
console.log("getState:", result)
|
|
103
|
+
|
|
104
|
+
client.getCurrentCpuMips();
|
|
105
|
+
}
|
|
106
|
+
// getState()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
async function getCurrentSimulationTime() {
|
|
110
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
111
|
+
const result = await client.getCurrentSimulationTime()
|
|
112
|
+
console.log("getCurrentCpuMips:", result)
|
|
113
|
+
}
|
|
114
|
+
// getCurrentSimulationTime()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
async function run() {
|
|
118
|
+
const client = SkyEyeClientFactory.instance.createClient('192.168.0.187', '52589');
|
|
119
|
+
const result = await client.runCommand()
|
|
120
|
+
console.log("run:", result)
|
|
121
|
+
}
|
|
122
|
+
// run()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
async function setMemoryValue() {
|
|
126
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
127
|
+
const result = await client.setMemoryValue('c67x_core_0', '10000', '15', 2)
|
|
128
|
+
console.log("setMemoryValue:", result)
|
|
129
|
+
}
|
|
130
|
+
// setMemoryValue()
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
async function getMemoryValue() {
|
|
135
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
136
|
+
const result = await client.getMemoryValue('c67x_core_0', "10000", 2)
|
|
137
|
+
console.log("setMemoryValue:", result)
|
|
138
|
+
}
|
|
139
|
+
// getMemoryValue()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
async function testSocket() {
|
|
144
|
+
const json = {
|
|
145
|
+
"msgId": "0",
|
|
146
|
+
"msgTime": "2023-12-5 12:00:00",
|
|
147
|
+
"msgType": "2",
|
|
148
|
+
"msgData": {
|
|
149
|
+
"version": "10001",
|
|
150
|
+
"protocol": "0",
|
|
151
|
+
"direction": "0",
|
|
152
|
+
"bigEndian": "0",
|
|
153
|
+
"length": "0",
|
|
154
|
+
"data": "0"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const net = require('net');
|
|
158
|
+
const client = new net.Socket();
|
|
159
|
+
const host = '127.0.0.1';
|
|
160
|
+
const port = 8099;
|
|
161
|
+
client.connect(port, host, () => {
|
|
162
|
+
console.log('Connected');
|
|
163
|
+
|
|
164
|
+
// const str = JSON.stringify(json)
|
|
165
|
+
// // const str = "hhh"
|
|
166
|
+
|
|
167
|
+
// const strBuffer = Buffer.from(str, 'utf8'); // 将字符串转换为 Buffer
|
|
168
|
+
// const strLength = strBuffer.length; // 获取 JSON 数据的长度
|
|
169
|
+
|
|
170
|
+
// // 创建一个新的 Buffer 用于存储长度信息和数据
|
|
171
|
+
// const totalLength = 4 + strLength; // 4 字节长度 + 数据长度
|
|
172
|
+
// const buffer = Buffer.alloc(totalLength);
|
|
173
|
+
|
|
174
|
+
// // 写入前 4 个字节的长度信息
|
|
175
|
+
// buffer.writeUInt32LE(strLength, 0); // 以小端序方式写入 JSON 数据的长度
|
|
176
|
+
|
|
177
|
+
// // 将 JSON 数据复制到 Buffer 中
|
|
178
|
+
// strBuffer.copy(buffer, 4); // 从第 5 个字节开始复制 JSON 数据
|
|
179
|
+
|
|
180
|
+
// console.log("Buffer sent:", buffer);
|
|
181
|
+
|
|
182
|
+
// console.log("String Length:", strLength); // 打印实际的字符串长度
|
|
183
|
+
// console.log("Hex Length:", strLength.toString(16)); // 打印十六进制表示
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
// client.write(buffer); // 发送拼接后的 Buffer
|
|
187
|
+
|
|
188
|
+
// 发送数据
|
|
189
|
+
|
|
190
|
+
//第一阶段0827测试
|
|
191
|
+
// const hexString = "B90000007B0A09226D73674964223A2230222C0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0A09226D736754797065223A2232222C0A09226D736744617461223A7B0A09092276657273696F6E223A2231222C0A09092270726F746F636F6C223A2230222C0A090922646972656374696F6E223A2230222C0A090922626967456E6469616E223A2230222C0A0909226C656E677468223A2230222C0A09092264617461223A2230220A097D0A7D0A";
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
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"
|
|
196
|
+
const s1_1 = s1.replace(/\s+/g, '');
|
|
197
|
+
const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A36340D0A097D0D0A7D" + s1_1
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
//74
|
|
201
|
+
// const hexString = "B90000007B0D0A09226D73674964223A2230222C0D0A09226D736754797065223A2232222C0D0A09226D736754696D65223A22323032332D31322D352031323A30303A3030222C0D0A09226D736744617461223A207B0D0A09092276657273696F6E223A223130303031222C0D0A09092270726F746F636F6C223A2230222C0D0A090922646972656374696F6E223A2230222C0D0A090922626967456E6469616E223A2230222C0D0A0909226C656E677468223A37340D0A097D0D0A7D1201AA11BB220000000000000000000000000000FFFF000000003333000000000000000044440000000000008888664400000000000000000000006576";
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
console.log("hexString:", hexString)
|
|
206
|
+
console.log("hexString:", hexString.length)
|
|
207
|
+
const buffer2 = Buffer.from(hexString, 'hex');
|
|
208
|
+
console.log("buffer2:", buffer2.length)
|
|
209
|
+
client.write(buffer2);
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
});
|
|
213
|
+
client.on('data', (data) => {
|
|
214
|
+
console.log('Received: ' + data);
|
|
215
|
+
client.destroy();
|
|
216
|
+
});
|
|
217
|
+
client.on('close', () => {
|
|
218
|
+
console.log('Connection closed');
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// testSocket()
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
async function testgetGlobalVarValue() {
|
|
227
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50052');
|
|
228
|
+
const response = await client.getGlobalVarValue("cx53123", "a", 16, "double");
|
|
229
|
+
console.log("testgetGlobalVarValue response:", response)
|
|
230
|
+
}
|
|
231
|
+
// testgetGlobalVarValue()
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
async function testsetGlobalVarValue() {
|
|
235
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
236
|
+
const response = await client.setGlobalVarValueDefault("int_test_var_0", "int", 16);
|
|
237
|
+
console.log("testgetGlobalVarValue response:", response)
|
|
238
|
+
}
|
|
239
|
+
// testsetGlobalVarValue()
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
async function getDeviceList(){
|
|
243
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
244
|
+
const response = await client.getDeviceList();
|
|
245
|
+
// console.log("getDeviceList response:", response)
|
|
246
|
+
}
|
|
247
|
+
// getDeviceList()
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
async function getDeviceTree(){
|
|
251
|
+
// const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
252
|
+
const client = SkyEyeClientFactory.instance.createClient('192.168.0.187', '53774');
|
|
253
|
+
const response = await client.getDeviceTree();
|
|
254
|
+
console.log("getDeviceList response:", response)
|
|
255
|
+
}
|
|
256
|
+
// getDeviceTree()
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
async function test() {
|
|
260
|
+
// console.log("Connected to SkyEye server");
|
|
261
|
+
// await client.getDeviceList();
|
|
262
|
+
// await client.getCurrentCpuMips();
|
|
263
|
+
// await client.runCommand();
|
|
264
|
+
|
|
265
|
+
// const response = await client.getCurrentRunningState();
|
|
266
|
+
|
|
267
|
+
// const response = await client.getGlobalVarValueDefault("a",GlobalVarType.DOUBLE);
|
|
268
|
+
// const response = await client.getGlobalVarValue("cx53123","a",16,GlobalVarType.DOUBLE);
|
|
269
|
+
|
|
270
|
+
// const response = await client.getCpuRegistersDefault();
|
|
271
|
+
// const response = await client.getCpuRegisters("c7xx");
|
|
272
|
+
|
|
273
|
+
// const response = await client.getMemoryValueDefault(1, 16);
|
|
274
|
+
// const response = await client.getMemoryValue("c7s",0,16);
|
|
275
|
+
// console.log("结果response:", response)
|
|
276
|
+
|
|
277
|
+
// const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
|
|
278
|
+
// const fileName = "c6713_fc_1553b.skyeye";
|
|
279
|
+
// const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
// const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
283
|
+
|
|
284
|
+
// const response =await client.getCurrentRunningState()
|
|
285
|
+
// const response = await client.getMemoryValueDefault("128","4")
|
|
286
|
+
// const response = await client.getGlobalVarValueDefault("number_a","int")
|
|
287
|
+
// const response = await client.setGlobalVarValueDefault("number_a", "int", "12")
|
|
288
|
+
|
|
289
|
+
// const response = await client.getDeviceTree()
|
|
290
|
+
|
|
291
|
+
// const response = await client.getMemoryValueDefault("10001", "1")
|
|
292
|
+
// console.log("response:", response)
|
|
293
|
+
// console.log("response:", response.boardMap)
|
|
294
|
+
// console.log("response:", response.boardMap.keys[0])
|
|
295
|
+
|
|
296
|
+
// await client.initSkyEyeAndRun(pathSkyEye,fileName,port,skyeyeDir);
|
|
297
|
+
const pathSkyEye = "D:/data/case/FMQL45T900_SylixOS";
|
|
298
|
+
const fileName = "FMQL45T900_SylixOS.skyeye";
|
|
299
|
+
const skyeyeDir = "D:/install/SkyEye/opt/skyeye/bin/skyeye.exe"
|
|
300
|
+
const port = "50066"
|
|
301
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port);
|
|
302
|
+
const t = await client.initSkyEyeAndRun2(pathSkyEye, fileName, port, skyeyeDir)
|
|
303
|
+
client.runCommand();
|
|
304
|
+
console.log("t:",t)
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
test()
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
async function testMutil() {
|
|
317
|
+
|
|
318
|
+
const pathSkyEye = "D:/data/case/workspace_c6713/targets/c6713_fc_1553b";
|
|
319
|
+
const fileName = "c6713_fc_1553b.skyeye";
|
|
320
|
+
const skyeyeDir = "D:/install/skyeye/opt/skyeye/bin/skyeye.exe"
|
|
321
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', '50051');
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
//启动多个skyeye
|
|
325
|
+
const count = 5;
|
|
326
|
+
const map = new Map<number, any>;
|
|
327
|
+
for (let i = 1; i < count; i++) {
|
|
328
|
+
const port = 50050 + i
|
|
329
|
+
const client = SkyEyeClientFactory.instance.createClient('127.0.0.1', port.toString());
|
|
330
|
+
await client.initSkyEyeAndRun2(pathSkyEye, fileName, port.toString(), skyeyeDir)
|
|
331
|
+
// await client.RunTestcase(json)
|
|
332
|
+
await client.runCommand()
|
|
333
|
+
const res = await client.getCurrentRunningState()
|
|
334
|
+
console.log("state3:", res.state)
|
|
335
|
+
map.set(port, client);
|
|
336
|
+
}
|
|
337
|
+
for (let i = 1; i < count; i++) {
|
|
338
|
+
setTimeout(async () => {
|
|
339
|
+
const port = 50050 + i
|
|
340
|
+
const client = map.get(port)
|
|
341
|
+
await client.quitCommand()
|
|
342
|
+
}, i * 5000)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
setTimeout(async () => {
|
|
346
|
+
// await map.get(50051).stopGrpcService("")
|
|
347
|
+
await map.get(50051).quitCommand()
|
|
348
|
+
}, 2000)
|
|
349
|
+
|
|
350
|
+
setTimeout(async () => {
|
|
351
|
+
// await map.get(50052).stopGrpcService("")
|
|
352
|
+
await map.get(50052).quitCommand()
|
|
353
|
+
}, 5000)
|
|
354
|
+
|
|
355
|
+
setTimeout(async () => {
|
|
356
|
+
// await map.get(50053).stopGrpcService("")
|
|
357
|
+
await map.get(50053).quitCommand()
|
|
358
|
+
}, 8000)
|
|
359
|
+
|
|
360
|
+
setTimeout(async () => {
|
|
361
|
+
// await map.get(50054).stopGrpcService("")
|
|
362
|
+
await map.get(50054).quitCommand()
|
|
363
|
+
}, 11000)
|
|
364
|
+
}
|
|
365
|
+
// testMutil()
|
package/skyeye-sdk-js-1.3.6.tgz
DELETED
|
Binary file
|
package/skyeye-sdk-js-1.3.7.tgz
DELETED
|
Binary file
|
package/skyeye-sdk-js-1.3.8.tgz
DELETED
|
Binary file
|