io.netty.buffer.ByteBuf.readUnsignedShortLE()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(753)

本文整理了Java中io.netty.buffer.ByteBuf.readUnsignedShortLE()方法的一些代码示例,展示了ByteBuf.readUnsignedShortLE()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.readUnsignedShortLE()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:readUnsignedShortLE

ByteBuf.readUnsignedShortLE介绍

[英]Gets an unsigned 16-bit short integer at the current readerIndexin the Little Endian Byte Order and increases the readerIndexby 2 in this buffer.
[中]在当前ReaderIndex处以小尾数字节顺序获取一个无符号16位短整数,并在此缓冲区中将ReaderIndex增加2。

代码示例

代码示例来源:origin: netty/netty

@Override
public int readUnsignedShortLE() {
  return buf.readUnsignedShortLE();
}

代码示例来源:origin: redisson/redisson

@Override
public int readUnsignedShortLE() {
  return buf.readUnsignedShortLE();
}

代码示例来源:origin: wildfly/wildfly

@Override
public int readUnsignedShortLE() {
  return buf.readUnsignedShortLE();
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public int readUnsignedShortLE() {
  return byteBuf.readUnsignedShortLE();
}

代码示例来源:origin: netty/netty

@Override
public int readUnsignedShortLE() {
  checkReadableBytes(2);
  return buffer.readUnsignedShortLE();
}

代码示例来源:origin: redisson/redisson

@Override
public int readUnsignedShortLE() {
  checkReadableBytes(2);
  return buffer.readUnsignedShortLE();
}

代码示例来源:origin: wildfly/wildfly

@Override
public int readUnsignedShortLE() {
  checkReadableBytes(2);
  return buffer.readUnsignedShortLE();
}

代码示例来源:origin: netty/netty

int offset = in.readUnsignedShortLE();

代码示例来源:origin: redisson/redisson

int offset = in.readUnsignedShortLE();

代码示例来源:origin: netty/netty

return NOT_ENOUGH_INPUT;
  length = in.readUnsignedShortLE();
  break;
case 62:

代码示例来源:origin: redisson/redisson

return NOT_ENOUGH_INPUT;
  length = in.readUnsignedShortLE();
  break;
case 62:

代码示例来源:origin: traccar/traccar

private Position parseUnitReport(
    DeviceSession deviceSession, ByteBuf buf, int sequenceNumber) {
  Position position = new Position(getProtocolName());
  position.setValid(true);
  position.set(Position.KEY_INDEX, sequenceNumber);
  position.setDeviceId(deviceSession.getDeviceId());
  buf.readUnsignedShortLE(); // report trigger
  position.set(Position.KEY_FLAGS, buf.readUnsignedShortLE());
  position.setLatitude(buf.readIntLE() * 0.0000001);
  position.setLongitude(buf.readIntLE() * 0.0000001);
  position.setAltitude(buf.readUnsignedShortLE());
  position.set(Position.KEY_SATELLITES, buf.readUnsignedShortLE());
  position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShortLE());
  position.set("gpsAntennaState", buf.readUnsignedShortLE());
  position.setSpeed(buf.readUnsignedShortLE() * 0.194384);
  position.setCourse(buf.readUnsignedShortLE());
  position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
  position.set(Position.KEY_DISTANCE, buf.readUnsignedIntLE());
  position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
  position.set(Position.KEY_CHARGE, buf.readUnsignedShortLE());
  position.setTime(convertTimestamp(buf.readUnsignedIntLE()));
  return position;
}

代码示例来源:origin: traccar/traccar

private void decodeTags(Position position, ByteBuf buf) {
  int blockLength = buf.readUnsignedShort();
  int blockEnd = buf.readerIndex() + blockLength;
  if (blockLength > 0) {
    buf.readUnsignedByte(); // tag type
    int count = buf.readUnsignedByte();
    int tagLength = buf.readUnsignedByte();
    for (int i = 1; i <= count; i++) {
      int tagEnd = buf.readerIndex() + tagLength;
      buf.readUnsignedByte(); // status
      buf.readUnsignedShortLE(); // battery voltage
      position.set(Position.PREFIX_TEMP + i, (buf.readShortLE() & 0x3fff) * 0.1);
      buf.readUnsignedByte(); // humidity
      buf.readUnsignedByte(); // rssi
      buf.readerIndex(tagEnd);
    }
  }
  buf.readerIndex(blockEnd);
}

代码示例来源:origin: traccar/traccar

@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
  ByteBuf buf = (ByteBuf) msg;
  buf.readUnsignedShortLE(); // device id
  int size = buf.readUnsignedByte();
  if (size != CMD_RESPONSE_SIZE) {
    int type = buf.readUnsignedByte();
    if (type == MSG_IMEI) {
      getDeviceSession(channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.UTF_8));
    } else {
      return decodeData(channel, remoteAddress, buf, type);
    }
  } else {
    return parseCommandResponse(channel, remoteAddress, buf);
  }
  return null;
}

代码示例来源:origin: traccar/traccar

private void decodeTag(Position position, ByteBuf buf, int tag) {
  if (tag >= 0x50 && tag <= 0x57) {
    position.set(Position.PREFIX_ADC + (tag - 0x50), buf.readUnsignedShortLE());
  } else if (tag >= 0x60 && tag <= 0x62) {
    position.set("fuel" + (tag - 0x60), buf.readUnsignedShortLE());
  } else if (tag >= 0xa0 && tag <= 0xaf) {
    position.set("can8BitR" + (tag - 0xa0 + 15), buf.readUnsignedByte());
  } else if (tag >= 0xb0 && tag <= 0xb9) {
    position.set("can16BitR" + (tag - 0xb0 + 5), buf.readUnsignedShortLE());
  } else if (tag >= 0xc4 && tag <= 0xd2) {
    position.set("can8BitR" + (tag - 0xc4), buf.readUnsignedByte());
  } else if (tag >= 0xd6 && tag <= 0xda) {
    position.set("can16BitR" + (tag - 0xd6), buf.readUnsignedShortLE());
  } else if (tag >= 0xdb && tag <= 0xdf) {
    position.set("can32BitR" + (tag - 0xdb), buf.readUnsignedIntLE());
  } else if (tag >= 0xe2 && tag <= 0xe9) {
    position.set("userData" + (tag - 0xe2), buf.readUnsignedIntLE());
  } else if (tag >= 0xf0 && tag <= 0xf9) {
    position.set("can32BitR" + (tag - 0xf0 + 5), buf.readUnsignedIntLE());
  } else {
    decodeTagOther(position, buf, tag);
  }
}

代码示例来源:origin: traccar/traccar

private Object decodePhoto(
    Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
  int length = buf.readUnsignedShortLE();
  Position position = null;
  if (length > 1) {
    if (photo == null) {
      photo = Unpooled.buffer();
    }
    buf.readUnsignedByte(); // part number
    photo.writeBytes(buf, length - 1);
  } else {
    DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
    String uniqueId = Context.getIdentityManager().getById(deviceSession.getDeviceId()).getUniqueId();
    position = new Position(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    getLastLocation(position, null);
    position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(uniqueId, photo, "jpg"));
    photo.release();
    photo = null;
  }
  sendReply(channel, 0x07, buf.readUnsignedShortLE());
  return position;
}

代码示例来源:origin: traccar/traccar

private void decodeStat(Position position, ByteBuf buf) {
  buf.readUnsignedIntLE(); // ACC ON time
  buf.readUnsignedIntLE(); // UTC time
  position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
  position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedIntLE());
  position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedIntLE());
  buf.readUnsignedShortLE(); // current fuel consumption
  position.set(Position.KEY_STATUS, buf.readUnsignedIntLE());
  buf.skipBytes(8);
}

代码示例来源:origin: traccar/traccar

private void decodeLocation(Position position, ByteBuf buf) {
  DateBuilder dateBuilder = new DateBuilder()
      .setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
      .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
  position.setTime(dateBuilder.getDate());
  int flags = buf.readUnsignedByte();
  position.setValid(BitUtil.to(flags, 2) > 0);
  double lat = buf.readUnsignedIntLE() / 3600000.0;
  double lon = buf.readUnsignedIntLE() / 3600000.0;
  position.setLatitude(BitUtil.check(flags, 2) ? lat : -lat);
  position.setLongitude(BitUtil.check(flags, 3) ? lon : -lon);
  position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShortLE()));
  position.setCourse(buf.readUnsignedShortLE() * 0.1);
  position.setAltitude(buf.readShortLE() * 0.1);
}

代码示例来源:origin: traccar/traccar

private Position parseTrackingData(
    DeviceSession deviceSession, ByteBuf buf, int sequenceNumber, long timestamp) {
  Position position = new Position(getProtocolName());
  position.set(Position.KEY_INDEX, sequenceNumber);
  position.setDeviceId(deviceSession.getDeviceId());
  position.setTime(convertTimestamp(timestamp));
  buf.readUnsignedByte(); // tracking mode
  short flags = buf.readUnsignedByte();
  position.setValid((flags & 0x01) == 0x01);
  buf.readUnsignedShortLE(); // duration
  position.setLatitude(buf.readIntLE() * 0.0000001);
  position.setLongitude(buf.readIntLE() * 0.0000001);
  position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
  position.setCourse(buf.readUnsignedByte() * 2.0);
  position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
  position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
  position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
  return position;
}

代码示例来源:origin: traccar/traccar

private Position readPosition(DeviceSession deviceSession, ByteBuf buf) {
  Position position = new Position(getProtocolName());
  position.setDeviceId(deviceSession.getDeviceId());
  DateBuilder dateBuilder = new DateBuilder()
      .setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
      .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
  position.setTime(dateBuilder.getDate());
  double lat = buf.readUnsignedIntLE() / 3600000.0;
  double lon = buf.readUnsignedIntLE() / 3600000.0;
  position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShortLE()));
  position.setCourse(buf.readUnsignedShortLE() * 0.1);
  int flags = buf.readUnsignedByte();
  if ((flags & 0x02) == 0) {
    lat = -lat;
  }
  if ((flags & 0x01) == 0) {
    lon = -lon;
  }
  position.setLatitude(lat);
  position.setLongitude(lon);
  position.setValid((flags & 0x0C) > 0);
  position.set(Position.KEY_SATELLITES, flags >> 4);
  return position;
}

相关文章

ByteBuf类方法