const {Controller} = require("ee-core"); const Ps = require("ee-core/ps"); const koffi = require('koffi'); const path = require("path"); class IcrfController extends Controller{ hcicrf =null; constructor(ctx) { super(ctx); const dllPath = path.join(Ps.getExtraResourcesDir(),'dll','hc_icrf32.dll'); this.hcicrf =koffi.load(dllPath); } async hc_init(params){ const hc_init = this.hcicrf.func('int __stdcall hc_init(short port, uint32_t baud)'); let hcInit = hc_init(2, 115200); console.log(hcInit); if (hcInit <=0){ // let errMsg = this.getErrMsg(hcInit); //console.log(errMsg) } return hcInit; } getErrMsg(st){ let getErrMsg = this.hcicrf.func("int getErrMsg(short st,short lg, char errMsg)"); let errMsg = getErrMsg(st, 0, 1024); console.log(errMsg) return errMsg; } } IcrfController.toString = ()=> '[class IcrfController]'; module.exports =IcrfController;