package art.servers.asfserver.protocols.dgt; import art.library.utils.common.ArrayUtils; import java.util.ArrayList; import java.util.List; public class AsfDgtPDU { public int stx; public int etx; public int crc1; public int crc2; public int function; public int address; public boolean ack = false; public int[] information = new int[0]; private int index = 0; public void checkOrder(AsfDgtPDU request) throws Exception { } public int readByte() throws Exception { return information[index++]; } public int readShort() throws Exception { return (readByte() << 8) + readByte(); } public int readInt() throws Exception { return (readByte() << 24) + (readByte() << 16) + (readByte() << 8) + readByte(); } public long readLong() throws Exception { long res = ((long) readByte() << 56); res = res + ((long) readByte() << 48); res = res + ((long) readByte() << 40); res = res + ((long) readByte() << 32); res = res + ((long) readByte() << 24); res = res + ((long) readByte() << 16); res = res + ((long) readByte() << 8); res = res + (long) readByte(); return (res); } public int[] readFully() throws Exception { int[] resultado = new int[information.length - index]; System.arraycopy(information, index, resultado, 0, resultado.length); return resultado; } public int[] readIntArray(int count) throws Exception { int[] resultado = new int[count]; System.arraycopy(information, index, resultado, 0, resultado.length); index = index + count; return resultado; } public int[] readIntArrayUntilValue(int limit) throws Exception { List list = new ArrayList(); int value = readByte(); while (value != limit) { list.add(value); value = readByte(); } int[] result = new int[list.size()]; for (int i=0; i0;j--) { if(((dato^acum) & 0x8000) != 0) acum =(short)((acum<<1)^0x1021); else acum<<=1; dato<<=1; } crc=acum; } long aux = acum; if (aux < 0) aux += (Short.MAX_VALUE*2 + 2); crc=aux; byte[] res = new byte[2]; res[0]=(byte) crc; crc=(long)(crc/256); res[1]=(byte) crc; return(res); } catch (Exception e) { throw e; } } public int[] addStuffing(int[] trama) throws Exception { try { int[] aux = new int[100096]; int apuntador = 0; for (int i=0; i=1) && (i