Java Code Examples for org.apache.mina.core.buffer.IoBuffer#getHexDump()
The following examples show how to use
org.apache.mina.core.buffer.IoBuffer#getHexDump() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModbusRtuDecoder.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void decodeTimeoutFrame ( final IoSession session, final IoBuffer currentFrame, final ProtocolDecoderOutput out ) { logger.trace ( "timeout () frame = {}", currentFrame.getHexDump () ); if ( currentFrame.limit () <= Constants.RTU_HEADER_SIZE ) { throw new ModbusProtocolError ( "frame must be at least 4 bytes long (address + data[] + crc low + crc high" ); } currentFrame.order ( ByteOrder.LITTLE_ENDIAN ); final int receivedCrc = currentFrame.getUnsignedShort ( currentFrame.limit () - 2 ); currentFrame.order ( ByteOrder.BIG_ENDIAN ); final int actualCrc = Checksum.crc16 ( currentFrame.array (), 0, currentFrame.limit () - 2 ); if ( receivedCrc != actualCrc ) { final String hd = currentFrame.getHexDump (); logger.info ( "CRC error - received: {}, calculated: {} - data: {}", receivedCrc, actualCrc, hd ); throw new ChecksumProtocolException ( String.format ( "CRC error. received: %04x, but actually was: %04x - Data: %s", receivedCrc, actualCrc, hd ) ); } currentFrame.position ( 0 ); // get unit id final byte unitIdentifier = currentFrame.get (); final int len = currentFrame.limit () - ( 2 /*crc*/+ 1/*unit id*/); final IoBuffer pdu = IoBuffer.allocate ( len ); for ( int i = 0; i < len; i++ ) { pdu.put ( currentFrame.get () ); } pdu.flip (); // decode and send logger.trace ( "Decoded PDU - data: {}", pdu.getHexDump () ); out.write ( new Pdu ( 0, unitIdentifier, pdu ) ); }
Example 2
Source File: RTMPProtocolDecoder.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * Decodes ping event. * * @param in * IoBuffer * @return Ping event */ public Ping decodePing(IoBuffer in) { Ping ping = null; if (log.isTraceEnabled()) { // gets the raw data as hex without changing the data or pointer String hexDump = in.getHexDump(); log.trace("Ping dump: {}", hexDump); } // control type short type = in.getShort(); switch (type) { case Ping.CLIENT_BUFFER: ping = new SetBuffer(in.getInt(), in.getInt()); break; case Ping.PING_SWF_VERIFY: // only contains the type (2 bytes) ping = new Ping(type); break; case Ping.PONG_SWF_VERIFY: byte[] bytes = new byte[42]; in.get(bytes); ping = new SWFResponse(bytes); break; default: //STREAM_BEGIN, STREAM_PLAYBUFFER_CLEAR, STREAM_DRY, RECORDED_STREAM //PING_CLIENT, PONG_SERVER //BUFFER_EMPTY, BUFFER_FULL ping = new Ping(type, in.getInt()); break; } return ping; }
Example 3
Source File: AbstractTest.java From game-server with MIT License | 4 votes |
protected static String toString(IoBuffer buf) { return buf.getHexDump(); }