New file |
| | |
| | | package com.dev.btse.data;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | |
|
| | | public class FBS9100S_TmpHumSensor {
|
| | | //温湿度传感器信息 |
| | | |
| | | private final int BYTE_LEN = 18;
|
| | | |
| | | public float[] tempValue = new float[FBS9100_ComBase.BattGroupCountMax];
|
| | | public float[] sdValue = new float[FBS9100_ComBase.BattGroupCountMax];
|
| | | public int CRC;
|
| | | |
| | | |
| | | |
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BYTE_LEN){
|
| | | return false;
|
| | | }
|
| | | |
| | | ByteBuffer tmpbuf = bf;
|
| | | int Crc16 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
|
| | | int crc1 = FBS9100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
| | | if(Crc16 != crc1){
|
| | | System.err.println(Crc16+ "==="+crc1+"@@@@@@@@@@@@@@"+bf.limit());
|
| | | return false;
|
| | | }
|
| | | tmpbuf.position(0);
|
| | | for(int i = 0;i < FBS9100_ComBase.BattGroupCountMax;i++) {
|
| | | tempValue[i] = (float)FBS9100_ComBase.changeShortToInt(tmpbuf.getShort())/10;
|
| | | }
|
| | | |
| | | for(int i = 0;i < FBS9100_ComBase.BattGroupCountMax;i++) {
|
| | | sdValue[i] = (float)FBS9100_ComBase.changeShortToInt(tmpbuf.getShort())/10;
|
| | | }
|
| | | |
| | | System.err.println("读取温湿度信息成功");
|
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | return true;
|
| | | }
|
| | | }
|