scanMachine.js 753 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as ASCIIUtils from "@/uni_modules/wrs-js-modbusCRCHex/js_sdk/wrs-ASCIIUtils";
  2. // import {logs} from "@/utils/util";
  3. import {Base} from "@/utils/usbSerial/base";
  4. import {logs} from "@/utils/util";
  5. export class ScanMachine extends Base {
  6. constructor(topClass, usbSerial) {
  7. super(topClass, usbSerial)
  8. this.id = 'scan'
  9. this.title = '扫码器'
  10. this.config = {
  11. baudRate: 115200,
  12. dataBits: 8,
  13. stopBits: 1,
  14. }
  15. }
  16. read(resp) {
  17. logs('read', this.id, resp)
  18. let resArr = this.packetManager(resp.data)
  19. resArr.forEach(it => {
  20. let data = it.slice(2, -2);
  21. it = ASCIIUtils.decodeUtf8(data)
  22. logs('scan usbSerial.read', it)
  23. if (this.notifyFun) this.notifyFun(it)
  24. })
  25. }
  26. }