List of usage examples for io.netty.buffer ByteBuf readUnsignedByte
public abstract short readUnsignedByte();
From source file:buildcraft.robotics.ZoneChunk.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { int flags = stream.readUnsignedByte(); if ((flags & 1) != 0) { property = BitSetUtils.fromByteArray(NetworkUtils.readByteArray(stream)); }//w ww . j a v a 2s .co m fullSet = (flags & 2) != 0; }
From source file:buildcraft.silicon.TileAssemblyTable.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { super.readData(stream); currentRecipeId = Utils.readUTF(stream); plannedOutput.clear();/*w ww . j a v a 2 s . c o m*/ int size = stream.readUnsignedByte(); for (int i = 0; i < size; i++) { plannedOutput.add(Utils.readUTF(stream)); } currentRecipe = AssemblyRecipeManager.INSTANCE.getRecipe(currentRecipeId); }
From source file:buildcraft.silicon.TileProgrammingTable.java
License:Minecraft Mod Public
@Override public void readData(ByteBuf stream) { super.readData(stream); currentRecipeId = Utils.readUTF(stream); optionId = stream.readUnsignedByte(); updateRecipe();/*from www. jav a2s .c o m*/ }
From source file:buildcraft.silicon.TileProgrammingTable.java
License:Minecraft Mod Public
@Override public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) { if (side.isServer() && "select".equals(command)) { optionId = stream.readUnsignedByte(); if (optionId >= options.size()) { optionId = 0;/*from ww w . j a v a 2 s . c o m*/ } queueNetworkUpdate(); } }
From source file:com.cloudhopper.smpp.pdu.BaseSm.java
License:Apache License
@Override public void readBody(ByteBuf buffer) throws UnrecoverablePduException, RecoverablePduException { this.serviceType = ChannelBufferUtil.readNullTerminatedString(buffer); this.sourceAddress = ChannelBufferUtil.readAddress(buffer); this.destAddress = ChannelBufferUtil.readAddress(buffer); this.esmClass = buffer.readByte(); this.protocolId = buffer.readByte(); this.priority = buffer.readByte(); this.scheduleDeliveryTime = ChannelBufferUtil.readNullTerminatedString(buffer); this.validityPeriod = ChannelBufferUtil.readNullTerminatedString(buffer); this.registeredDelivery = buffer.readByte(); this.replaceIfPresent = buffer.readByte(); this.dataCoding = buffer.readByte(); this.defaultMsgId = buffer.readByte(); // this is always an unsigned version of the short message length short shortMessageLength = buffer.readUnsignedByte(); this.shortMessage = new byte[shortMessageLength]; buffer.readBytes(this.shortMessage); }
From source file:com.digitalpetri.modbus.codec.MbapHeader.java
License:Apache License
public static MbapHeader decode(ByteBuf buffer) { return new MbapHeader(buffer.readShort(), buffer.readUnsignedShort(), buffer.readUnsignedShort(), buffer.readUnsignedByte()); }
From source file:com.digitalpetri.modbus.codec.ModbusRequestDecoder.java
License:Apache License
private WriteMultipleCoilsRequest decodeWriteMultipleCoils(ByteBuf buffer) { int address = buffer.readUnsignedShort(); int quantity = buffer.readUnsignedShort(); int byteCount = buffer.readUnsignedByte(); ByteBuf values = buffer.readSlice(byteCount).retain(); return new WriteMultipleCoilsRequest(address, quantity, values); }
From source file:com.digitalpetri.modbus.codec.ModbusResponseDecoder.java
License:Apache License
@Override public ModbusPdu decode(ByteBuf buffer) throws DecoderException { int code = buffer.readUnsignedByte(); if (FunctionCode.isExceptionCode(code)) { FunctionCode functionCode = FunctionCode.fromCode(code - 0x80); if (functionCode == null) { throw new DecoderException("invalid function code: " + (code - 0x80)); }//from w ww .java2 s .com return decodeException(functionCode, buffer); } else { FunctionCode functionCode = FunctionCode.fromCode(code); if (functionCode == null) { throw new DecoderException("invalid function code: " + code); } return decodeResponse(functionCode, buffer); } }
From source file:com.digitalpetri.modbus.codec.ModbusResponseDecoder.java
License:Apache License
private ModbusPdu decodeException(FunctionCode functionCode, ByteBuf buffer) throws DecoderException { int code = buffer.readUnsignedByte(); ExceptionCode exceptionCode = ExceptionCode.fromCode(code); if (exceptionCode == null) { throw new DecoderException("invalid exception code: " + code); }/*from www . j ava 2 s .c om*/ return new ExceptionResponse(functionCode, exceptionCode); }
From source file:com.digitalpetri.modbus.codec.ModbusResponseDecoder.java
License:Apache License
public ReadCoilsResponse decodeReadCoils(ByteBuf buffer) { int byteCount = buffer.readUnsignedByte(); ByteBuf coilStatus = buffer.readSlice(byteCount).retain(); return new ReadCoilsResponse(coilStatus); }