skyeye-sdk-js 1.4.5 → 1.4.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.
@@ -146,6 +146,8 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
146
146
  // console.log("res:",res)
147
147
  const ackObj = JSON.parse(response.toString()).ack;
148
148
  // this.printResponseLog(ackObj)
149
+ if (ackObj.result === 'false')
150
+ ackObj.result = false;
149
151
  return ackObj;
150
152
  }
151
153
  catch (error) {
@@ -712,10 +714,11 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
712
714
  }
713
715
  setCpuRegisterValue(boardName, cpuName, registerName, value) {
714
716
  return __awaiter(this, void 0, void 0, function* () {
715
- const deviceTree = yield this.getDeviceTree();
716
- if (!deviceTree.boardMap.has(boardName)) {
717
- throw new SkyEyeSDKException_1.SkyEyeSDKException("未能找到该板卡");
718
- }
717
+ // 设置寄存器 无需板卡名称
718
+ // const deviceTree = await this.getDeviceTree();
719
+ // if (!deviceTree.boardMap.has(boardName)) {
720
+ // throw new SkyEyeSDKException("未能找到该板卡");
721
+ // }
719
722
  // const board: Board = boardMap.get(boardName);
720
723
  // const deviceMap = board.deviceMap;
721
724
  // if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu)) {
@@ -1095,10 +1098,22 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1095
1098
  try {
1096
1099
  console.log('runExample');
1097
1100
  this.childProcess = yield this.startSkyEye(port, skyeyeDir);
1101
+ let response;
1102
+ let ackObj;
1098
1103
  yield this.checkState();
1099
1104
  yield this.checkModule();
1100
- yield this.setWorkingDirectory(pathSkyEye, port);
1101
- yield this.runScript(fileName, port);
1105
+ response = yield this.setWorkingDirectory(pathSkyEye, port);
1106
+ ackObj = JSON.parse(response.toString()).ack;
1107
+ if (ackObj.result === "false") {
1108
+ ackObj.result = false;
1109
+ throw new Error(ackObj.error);
1110
+ }
1111
+ response = yield this.runScript(fileName, port);
1112
+ ackObj = JSON.parse(response.toString()).ack;
1113
+ if (ackObj.result === "false") {
1114
+ ackObj.result = false;
1115
+ throw new Error(ackObj.error);
1116
+ }
1102
1117
  return true;
1103
1118
  }
1104
1119
  catch (error) {
@@ -1209,7 +1224,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1209
1224
  }
1210
1225
  else {
1211
1226
  console.log("chdir res:", response);
1212
- resolve();
1227
+ resolve(response);
1213
1228
  }
1214
1229
  });
1215
1230
  });
@@ -1226,7 +1241,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
1226
1241
  }
1227
1242
  else {
1228
1243
  console.log("run_script res:", response);
1229
- resolve();
1244
+ resolve(response);
1230
1245
  }
1231
1246
  });
1232
1247
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyeye-sdk-js",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "description": "gRPC to SkyEye",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -111,6 +111,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
111
111
  // console.log("res:",res)
112
112
  const ackObj = JSON.parse(response.toString()).ack;
113
113
  // this.printResponseLog(ackObj)
114
+ if (ackObj.result === 'false') ackObj.result = false
114
115
  return ackObj;
115
116
  } catch (error) {
116
117
  // console.error("Error during gRPC request:", JSON.stringify(request));
@@ -632,10 +633,11 @@ export class SkyEyeClient extends JSONTransmissionClient {
632
633
 
633
634
 
634
635
  public async setCpuRegisterValue(boardName: string, cpuName: string, registerName: string, value: string) {
635
- const deviceTree = await this.getDeviceTree();
636
- if (!deviceTree.boardMap.has(boardName)) {
637
- throw new SkyEyeSDKException("未能找到该板卡");
638
- }
636
+ // 设置寄存器 无需板卡名称
637
+ // const deviceTree = await this.getDeviceTree();
638
+ // if (!deviceTree.boardMap.has(boardName)) {
639
+ // throw new SkyEyeSDKException("未能找到该板卡");
640
+ // }
639
641
  // const board: Board = boardMap.get(boardName);
640
642
  // const deviceMap = board.deviceMap;
641
643
  // if (!deviceMap.has(cpuName) || !(deviceMap.get(cpuName) instanceof Cpu)) {
@@ -1012,11 +1014,24 @@ export class SkyEyeClient extends JSONTransmissionClient {
1012
1014
  public async initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string) {
1013
1015
  try {
1014
1016
  console.log('runExample');
1017
+
1015
1018
  this.childProcess = await this.startSkyEye(port, skyeyeDir);
1019
+ let response
1020
+ let ackObj
1016
1021
  await this.checkState();
1017
1022
  await this.checkModule();
1018
- await this.setWorkingDirectory(pathSkyEye, port);
1019
- await this.runScript(fileName, port);
1023
+ response = await this.setWorkingDirectory(pathSkyEye, port);
1024
+ ackObj = JSON.parse(response.toString()).ack;
1025
+ if (ackObj.result === "false") {
1026
+ ackObj.result = false
1027
+ throw new Error(ackObj.error)
1028
+ }
1029
+ response = await this.runScript(fileName, port);
1030
+ ackObj = JSON.parse(response.toString()).ack;
1031
+ if (ackObj.result === "false") {
1032
+ ackObj.result = false
1033
+ throw new Error(ackObj.error)
1034
+ }
1020
1035
  return true;
1021
1036
  } catch (error) {
1022
1037
  console.error("initSkyEyeAndRun error:", error);
@@ -1126,7 +1141,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
1126
1141
  }
1127
1142
 
1128
1143
 
1129
- private setWorkingDirectory(pathSkyEye: string, port: string): Promise<void> {
1144
+ private setWorkingDirectory(pathSkyEye: string, port: string): Promise<JSONResponse> {
1130
1145
  const client = new JSONTransmissionClient(`127.0.0.1:${port}`, grpc.credentials.createInsecure());
1131
1146
  const Jr = new JSONRequest();
1132
1147
  Jr.setRequest(`{"request": {"name": "chdir", "args": {"path":"${pathSkyEye}"}}}`);
@@ -1138,25 +1153,25 @@ export class SkyEyeClient extends JSONTransmissionClient {
1138
1153
  reject(error);
1139
1154
  } else {
1140
1155
  console.log("chdir res:", response);
1141
- resolve();
1156
+ resolve(response);
1142
1157
  }
1143
1158
  });
1144
1159
  });
1145
1160
  }
1146
1161
 
1147
- private runScript(fileName: string, port: string): Promise<void> {
1162
+ private runScript(fileName: string, port: string): Promise<JSONResponse> {
1148
1163
  const client = new JSONTransmissionClient(`127.0.0.1:${port}`, grpc.credentials.createInsecure());
1149
1164
  const Jr = new JSONRequest();
1150
1165
  Jr.setRequest(`{"request": {"name": "run_script", "args": {"filename":"${fileName}"}}}`);
1151
1166
 
1152
- return new Promise((resolve, reject) => {
1167
+ return new Promise<JSONResponse>((resolve, reject) => {
1153
1168
  client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
1154
1169
  if (error) {
1155
1170
  console.log("run_script error res:", error);
1156
1171
  reject(error);
1157
1172
  } else {
1158
1173
  console.log("run_script res:", response);
1159
- resolve();
1174
+ resolve(response);
1160
1175
  }
1161
1176
  });
1162
1177
  });