1. Jens Reimann
  2. org.openscada.oxygen

Commits

Jens Reimann  committed a15eed7

add some debugging and add a specific checksum exception

  • Participants
  • Parent commits c5ea7bf
  • Branches 1.2

Comments (0)

Files changed (4)

File org.openscada.protocol.modbus/src/org/openscada/protocol/modbus/codec/ModbusRtuDecoder.java

View file
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 import org.openscada.protocol.modbus.Checksum;
 import org.openscada.protocol.modbus.Constants;
+import org.openscada.protocol.modbus.io.ChecksumProtocolException;
 import org.openscada.protocol.modbus.io.ModbusProtocolError;
 import org.openscada.protocol.modbus.io.TimedEndDecoder;
 import org.openscada.protocol.modbus.message.Pdu;
         if ( receivedCrc != actualCrc )
         {
             logger.info ( "CRC error - received: {}, calculated: {}", receivedCrc, actualCrc );
-            throw new ModbusProtocolError ( String.format ( "CRC error. received: %04x, but actually was: %04x", receivedCrc, actualCrc ) );
+            throw new ChecksumProtocolException ( String.format ( "CRC error. received: %04x, but actually was: %04x", receivedCrc, actualCrc ) );
         }
 
         currentFrame.position ( 0 );

File org.openscada.protocol.modbus/src/org/openscada/protocol/modbus/io/ChecksumProtocolException.java

View file
+package org.openscada.protocol.modbus.io;
+
+public class ChecksumProtocolException extends RuntimeException
+{
+
+    private static final long serialVersionUID = 1L;
+
+    public ChecksumProtocolException ()
+    {
+        super ();
+    }
+
+    public ChecksumProtocolException ( final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace )
+    {
+        super ( message, cause, enableSuppression, writableStackTrace );
+    }
+
+    public ChecksumProtocolException ( final String message, final Throwable cause )
+    {
+        super ( message, cause );
+    }
+
+    public ChecksumProtocolException ( final String message )
+    {
+        super ( message );
+    }
+
+    public ChecksumProtocolException ( final Throwable cause )
+    {
+        super ( cause );
+    }
+
+}

File org.openscada.protocol.modbus/src/org/openscada/protocol/modbus/message/BaseMessage.java

View file
 
 public class BaseMessage
 {
-    private final byte unitIdentifier;
+    protected final byte unitIdentifier;
 
-    private final byte functionCode;
+    protected final byte functionCode;
 
     public BaseMessage ( final byte unitIdentifier, final byte functionCode )
     {

File org.openscada.protocol.modbus/src/org/openscada/protocol/modbus/message/ErrorResponse.java

View file
     @Override
     public String toString ()
     {
-        return "ErrorResponse [functionCode=" + ( getFunctionCode () - (byte)0x80 ) + ", exceptionCode=" + this.exceptionCode + "]";
+        return "ErrorResponse [unitIdentifier=" + this.unitIdentifier + ", functionCode=" + ( this.functionCode - (byte)0x80 ) + ", exceptionCode=" + this.exceptionCode + "]";
     }
 }