chenyc
2024-07-11 b7b73d339a42d09ecc3f0115c49e23dc46893d5e
src/samples/deviceApi/RBP-9000c.ts
@@ -26,26 +26,42 @@
        console.log('端口异常端口链接断开')
        console.log(err)
    })
    //                 AA E0 03 28 64 02 71 06 44 51 A2 01 84 40 40 C0 5D D0
    // 解析分割数据流   AA 80 09 0F 01 06 00 17 05 0E 10 11 0F 00 8D 00 44 00 56 8C
    //AA 80 09 0F 01 06 00 17 05 0E 0F 37 37 00 74 00 46 00 50 70
    const parser = serialport.pipe(new ByteLengthParser({ length: 20 }))
    // parser.on('data', (value: string | any[])=>{
    //     console.log(value.toString())
    //     const str=value.toString()
    //     const list=str.split(',')
    //     console.log(list)
    //     if(list.length===11){
    //         sockteStore().setxyjSockte(
    //           {
    //               deviceName:'HBP-9030',
    //               type:"血压计",
    //               result:list[14]+','+list[16]+','+list[18],
    //               resultTime:new Date().toString(),
    //               state:2
    //           }
    //       )
    //     }
    // })
    parser.on('data', (value: string | any[])=>{
        console.log(value.toString())
        const str=value.toString()
        const list=str.split(',')
        console.log(list)
        if(list.length===11){
        console.log('-----------------')
        if(value.length>=20){
            sockteStore().setxyjSockte(
              {
                  deviceName:'HBP-9030',
                  type:"血压计",
                  result:list[14]+','+list[16]+','+list[18],
                    result:value[14]+','+value[16]+','+value[18],
                  resultTime:new Date().toString(),
                  state:2
              }
          )
        }
        console.log(value,'血压计数据')
    })
}