| | |
| | | // 55 53 2C 47 53 20 20 20 20 36 30 2E 35 6B 67 0D 0A HEX |
| | | const parser = serialport.pipe(new DelimiterParser({ delimiter:Buffer.from([13,10]),includeDelimiter:true })) |
| | | parser.on('data', (value: string | any[])=>{ |
| | | console.log(value.toString()) |
| | | // console.log(value.toString()) |
| | | const str=value.toString() |
| | | const list=str.split(' ') |
| | | console.log(list) |
| | | // console.log(list) |
| | | if(list.length>=4&&list[0].search('ST,GS')!==-1){ |
| | | const re=list[list.length-1].trim() |
| | | const res=re.substring(0,re.length-2) |
| | | console.log(res,'获取到的体重') |
| | | // console.log(res,'获取到的体重') |
| | | if(Number(res)>=20){ |
| | | sockteStore().setweightSockte( |
| | | { |
| | |
| | | } |
| | | |
| | | }else{ |
| | | console.log('数据格式不对') |
| | | // console.log('数据格式不对') |
| | | } |
| | | }) // all data after READY is received |
| | | } |