chenyc
2024-07-11 b7b73d339a42d09ecc3f0115c49e23dc46893d5e
src/samples/deviceApi/XK3190A12.ts
@@ -40,12 +40,17 @@
    //
    //
    // 77 6E 30 30 30 30 30 2E 30 6B 67 0D 0A
    // 77 6E 30 30 30 30 32 38 2E 36 6B 67 0D 0A
    // 77 6E 30 30 30 30 32 38 2E 36 6B 67 0D 0A
    //wn000016.6kg
    const parser = serialport.pipe(new DelimiterParser({ delimiter:Buffer.from([107,103,13,10]),includeDelimiter:true }))
    parser.on('data', (value: string | any[])=>{
        console.log(value.toString())
        const str=value.toString()
        // 截取结果
        const list=str.substring(2,10)
        // const list=str.substring(2,10)
        const list = parseFloat(str.replace(/[^\d.]/g, '')).toString();
        console.log(list)
        if(Number(list)>20){
            // 判断是否相等 相等加一
            if(list===lisijieguo){