Abdelhak NASSEUR
Abdelhak NASSEUR

Reputation: 1

CRC codes calculation for GT06n OpenGTS platform

Good morning everyone,

I am writing a device communication server for OpenGTS ( concox gt06n device ). I am not receiving the GPS data packet after the login packet is treated. I think the issue is with my CRC calculation could anybody help make sure my CRC calculation is correct.

// this is the response from the server using data treatment coming from the device

if(b[3]==0x01 || b[3]==0x13){
tdata[0]=0x05;
tdata[1]=b[3];
tdata[2]=b[b[2]-6+5];
tdata[3]=b[b[2]-5+5];

// recieved packet

// 78 78 0D 01 03 53 70 10 97 16 60 58 00 01 20 FE 0D 0A

// response from server 

// 78 78 05 01 00 01 D9 DC 0D 0A

`

crcc.set(tdata);    
short x=crcc.get();

fdata[0]=0x78;
fdata[1]=0x78;
fdata[2]=0x05;
fdata[3]=b[3];
fdata[4]=b[b[2]-6+5];
fdata[5]=b[b[2]-5+5];
fdata[6]=(byte)((x >> 8) & 0xff);
fdata[7]=(byte)(x & 0xff);
fdata[8]=0x0d;
fdata[9]=0x0a;

// below you find the CRC calculation table

public short get() { 
  short c;
  int y;
  y=~crc;
  c = (short)y;
  return c;
 }

public void set(byte[] bytes) { 
  crc = 0xffff;
  for (byte b : bytes) {
  crc = (crc >> 8) ^ table[(crc ^ b) & 0xff];

  }
 }

Upvotes: 0

Views: 185

Answers (1)

Abdelhak NASSEUR
Abdelhak NASSEUR

Reputation: 1

i have already found the answer to the issue here, the GT06N device sends undocumented protocols to the servers that will result in resetting the device over and over again, make sure to white list only the required protocols to avoid your device being stuck in a loop

Upvotes: 0

Related Questions