mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Resolved issue in CRC-CCITT correction method. Added CRC error detection to PDU header block in the message framer, so that we're sure that the number of follow blocks is correct while we're capturing symbols/bits. Set the TDU message error correction to Pass since the CRC is calculated within the message framer and no errant NIDs (TDU) are passed.
This commit is contained in:
@@ -105,7 +105,7 @@ public class CRCP25
|
||||
|
||||
if( errorLocation >= 0 )
|
||||
{
|
||||
message.flip( errorLocation );
|
||||
message.flip( errorLocation + NID_MESSAGE_START );
|
||||
|
||||
return CRC.CORRECTED;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class CRCP25
|
||||
|
||||
if( errorLocation >= 0 )
|
||||
{
|
||||
message.flip( errorLocation );
|
||||
message.flip( errorLocation + messageStart );
|
||||
|
||||
return CRC.CORRECTED;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class CRCP25
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
String raw = "0010011000000111100010111111001111100001111010011110000100010010000001011001000000000000000000000000000000000000000000000000000000000000000000001101000111000011";
|
||||
String raw = "0010011000000111101010111111001111100001111010011110000100010010000010011001000000101101110000000000000000000000000000000000000000000000000000000001011011001100";
|
||||
|
||||
BitSetBuffer message = BitSetBuffer.load( raw );
|
||||
|
||||
@@ -220,6 +220,8 @@ public class CRCP25
|
||||
|
||||
CRC results = correctCCITT80( message, 64, 144 );
|
||||
|
||||
mLog.debug( "COR:" + message.toString() );
|
||||
|
||||
mLog.debug( "Results: " + results.getDisplayText() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,15 +59,6 @@ public class P25MessageProcessor implements Listener<Message>
|
||||
mIdentifierMap.put( identifierUpdate.getIdentifier(), identifierUpdate );
|
||||
}
|
||||
|
||||
// if( message instanceof TSBKMessage )
|
||||
// {
|
||||
// mLog.debug( message.getMessage() );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mLog.debug( message.getMessage() + "\t" + message.getBinaryMessage() );
|
||||
// }
|
||||
|
||||
mBroadcaster.broadcast( message );
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package decode.p25.message.pdu;
|
||||
|
||||
import alias.AliasList;
|
||||
import bits.BitSetBuffer;
|
||||
import crc.CRC;
|
||||
import decode.p25.message.P25Message;
|
||||
import decode.p25.reference.DataUnitID;
|
||||
import decode.p25.reference.Opcode;
|
||||
@@ -28,6 +29,10 @@ public class PDUMessage extends P25Message
|
||||
public PDUMessage( BitSetBuffer message, DataUnitID duid, AliasList aliasList )
|
||||
{
|
||||
super( message, duid, aliasList );
|
||||
|
||||
/* Setup a CRC array to hold the header CRC and the multi-block CRC */
|
||||
mCRC = new CRC[ 2 ];
|
||||
mCRC[ 0 ] = CRC.PASSED;
|
||||
}
|
||||
|
||||
protected String getMessageStub()
|
||||
|
||||
@@ -2,6 +2,7 @@ package decode.p25.message.tdu;
|
||||
|
||||
import alias.AliasList;
|
||||
import bits.BitSetBuffer;
|
||||
import crc.CRC;
|
||||
import decode.p25.message.P25Message;
|
||||
import decode.p25.reference.DataUnitID;
|
||||
|
||||
@@ -11,5 +12,10 @@ public class TDUMessage extends P25Message
|
||||
AliasList aliasList )
|
||||
{
|
||||
super( message, duid, aliasList );
|
||||
|
||||
/* NID CRC is checked in the message framer, thus a constructed message
|
||||
* means it passed the CRC */
|
||||
mCRC = new CRC[ 1 ];
|
||||
mCRC[ 0 ] = CRC.PASSED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MotorolaTSBKMessage extends TSBKMessage
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "SYS:" );
|
||||
sb.append( "NAC:" );
|
||||
sb.append( getNAC() ); /* NAC is the system id for TSBK messages */
|
||||
sb.append( " " );
|
||||
sb.append( getDUID().getLabel() );
|
||||
|
||||
@@ -37,6 +37,7 @@ public class P25MessageFramer implements Listener<Dibit>
|
||||
public static final int TSBK_DECODED_END = 160;
|
||||
|
||||
public static final int PDU0_BEGIN = 64;
|
||||
public static final int PDU0_CRC_BEGIN = 144;
|
||||
public static final int PDU0_END = 260;
|
||||
public static final int PDU1_BEGIN = 160;
|
||||
public static final int PDU1_END = 356;
|
||||
@@ -262,9 +263,19 @@ public class P25MessageFramer implements Listener<Dibit>
|
||||
* unsuccessful decode due to excessive errors */
|
||||
if( mHalfRate.decode( mMessage, PDU0_BEGIN, PDU0_END ) )
|
||||
{
|
||||
setDUID( DataUnitID.PDU1 );
|
||||
CRC pduCRC = CRCP25.correctCCITT80( mMessage,
|
||||
PDU0_BEGIN, PDU0_CRC_BEGIN );
|
||||
|
||||
mMessage.setPointer( PDU1_BEGIN );
|
||||
if( pduCRC != CRC.FAILED_CRC )
|
||||
{
|
||||
setDUID( DataUnitID.PDU1 );
|
||||
|
||||
mMessage.setPointer( PDU1_BEGIN );
|
||||
}
|
||||
else
|
||||
{
|
||||
mComplete = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user