List of usage examples for io.netty.buffer ByteBuf writeByte
public abstract ByteBuf writeByte(int value);
From source file:com.digitalpetri.modbus.codec.ModbusRequestEncoder.java
License:Apache License
public ByteBuf encodeWriteSingleCoil(WriteSingleCoilRequest request, ByteBuf buffer) { buffer.writeByte(request.getFunctionCode().getCode()); buffer.writeShort(request.getAddress()); buffer.writeShort(request.getValue()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusRequestEncoder.java
License:Apache License
public ByteBuf encodeWriteSingleRegister(WriteSingleRegisterRequest request, ByteBuf buffer) { buffer.writeByte(request.getFunctionCode().getCode()); buffer.writeShort(request.getAddress()); buffer.writeShort(request.getValue()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusRequestEncoder.java
License:Apache License
public ByteBuf encodeWriteMultipleCoils(WriteMultipleCoilsRequest request, ByteBuf buffer) { buffer.writeByte(request.getFunctionCode().getCode()); buffer.writeShort(request.getAddress()); buffer.writeShort(request.getQuantity()); int byteCount = (request.getQuantity() + 7) / 8; buffer.writeByte(byteCount);// ww w . jav a2 s.c om buffer.writeBytes(request.getValues(), byteCount); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusRequestEncoder.java
License:Apache License
public ByteBuf encodeWriteMultipleRegisters(WriteMultipleRegistersRequest request, ByteBuf buffer) { buffer.writeByte(request.getFunctionCode().getCode()); buffer.writeShort(request.getAddress()); buffer.writeShort(request.getQuantity()); int byteCount = request.getQuantity() * 2; buffer.writeByte(byteCount);/*from w w w . jav a 2 s . co m*/ buffer.writeBytes(request.getValues(), byteCount); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusRequestEncoder.java
License:Apache License
public ByteBuf encodeMaskWriteRegister(MaskWriteRegisterRequest request, ByteBuf buffer) { buffer.writeByte(request.getFunctionCode().getCode()); buffer.writeShort(request.getAddress()); buffer.writeShort(request.getAndMask()); buffer.writeShort(request.getOrMask()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusResponseEncoder.java
License:Apache License
private ByteBuf encodeExceptionResponse(ExceptionResponse response, ByteBuf buffer) { buffer.writeByte(response.getFunctionCode().getCode() + 0x80); buffer.writeByte(response.getExceptionCode().getCode()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusResponseEncoder.java
License:Apache License
private ByteBuf encodeReadCoils(ReadCoilsResponse response, ByteBuf buffer) { buffer.writeByte(response.getFunctionCode().getCode()); buffer.writeByte(response.getCoilStatus().readableBytes()); buffer.writeBytes(response.getCoilStatus()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusResponseEncoder.java
License:Apache License
private ByteBuf encodeReadDiscreteInputs(ReadDiscreteInputsResponse response, ByteBuf buffer) { buffer.writeByte(response.getFunctionCode().getCode()); buffer.writeByte(response.getInputStatus().readableBytes()); buffer.writeBytes(response.getInputStatus()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusResponseEncoder.java
License:Apache License
private ByteBuf encodeReadHoldingRegisters(ReadHoldingRegistersResponse response, ByteBuf buffer) { buffer.writeByte(response.getFunctionCode().getCode()); buffer.writeByte(response.getRegisters().readableBytes()); buffer.writeBytes(response.getRegisters()); return buffer; }
From source file:com.digitalpetri.modbus.codec.ModbusResponseEncoder.java
License:Apache License
private ByteBuf encodeReadInputRegisters(ReadInputRegistersResponse response, ByteBuf buffer) { buffer.writeByte(response.getFunctionCode().getCode()); buffer.writeByte(response.getRegisters().readableBytes()); buffer.writeBytes(response.getRegisters()); return buffer; }