Atom packets

Packet structure

Field Length in bytes Start byte Description
Packet start marker 5   [SOH]ATOM
[SOH] = 0x01
Packet number 1 0 Rolls over ever 256 packets. Multi-packet operations like firmware transfers often hold a constant packet number, using it as a sort of session identifier.
Has payload 1 1 Set bit 0 to indicate that the packet includes a payload.
Sender 2 2 Device number. This is a ushort that identifies the device that sent the packet. Often set to zero. Not terribly important.
Recipient 2 4 Device number. This is a ushort that identifies the device to which the packet is being sent. 0 is self, 1 is broadcast.
Command 2 6 This is a processing command. For example, a command of LongPollRequest when sent to an ATOM will cause it to reply with a command of LongPollResponse and a payload full of positional information and other telemetry. You do not need a separate command for every possible CAS event, because you can include that information in the payload.
Payload length 1 8 The payload length is one byte larger than the value specified in this field, supporting payload lengths of up to 256 bytes.
Header checksum 1 9

  112 int Checksum(byte[] buffer, int startIndex, int length, int m)

  113 {

  114   int c = 0;

  115   for (int i = 0; i < length; i++) c += buffer[startIndex + i];

  116   return c % m;

  117 }

Payload X 10 Payload length (PL).
Payload checksum 1 10 + X Same function as header checksum applied to X payload bytes
Payload XOR 1 11 + X

  119 byte CheckXor(byte[] buffer, int startIndex, int length)

  120 {

  121   byte b = 0;

  122   for (int i = 0; i < length; i++) b ^= buffer[startIndex + i];

  123   return b;

  124 }

Trailer 1 10 or
12 + X
This is a literal [Newline] (0x0A) that follows either the header checksum or the payload XOR, depending on whether there is a payload.

Events and commands

These are the currently defined event and command codes. Atoms have a couple of commands for reading events, and the interpretation of an event depends on the event code within the payload. You could piggyback this or you could create your own parallel mechanism for CAS logs (probably the better idea).

   10 public enum AtomEvent

   11 {

   12   Log = 0,

   13   CalibrationDataAcknowledgement = 1,

   14   PowerupFail = 2,

   15   PositionReport = 3,

   16   DigitalInputChange = 4,

   17   DigitalPulseStart = 5, DigitalPulseStop = 6, //magflo   

   18   AtomStartup = 7,

   19   AlarmSet = 8, AlarmReset = 9,

   20   EquipmentStart = 10, EquipmentStop = 11,

   21   EmergencyRequiresAck = 12,

   22   UserStatusUpdate = 13,

   23   ExternalAlert = 14,

   24   EmergencyNoAck = 15,

   25   AtomShutdown = 16,

   26   MovementHalted = 17, MovementResumed = 18,

   27   CorruptedEvent = 19,

   28   GeofenceEntry = 20, GeofenceExit = 21,

   29   GeofenceSpeedExceeded = 22,

   30   CorruptAtomId = 23,

   31   DigitalAlarmSet1 = 32, DigitalAlarmSet2 = 33,

   32   DigitalAlarmSet3 = 34, DigitalAlarmSet4 = 35,

   33   DigitalAlarmSet5 = 36, DigitalAlarmSet6 = 37,

   34   DigitalAlarmSet7 = 38, DigitalAlarmSet8 = 39,

   35   AnalogAlarmSet1 = 40, AnalogAlarmSet2 = 41,

   36   AnalogAlarmSet3 = 42, AnalogAlarmSet4 = 43,

   37   AnalogAlarmSet5 = 44, AnalogAlarmSet6 = 45,

   38   AnalogAlarmSet7 = 46, AnalogAlarmSet8 = 47,

   39   DigitalAlarmReset1 = 48, DigitalAlarmReset2 = 49,

   40   DigitalAlarmReset3 = 50, DigitalAlarmReset4 = 51,

   41   DigitalAlarmReset5 = 52, DigitalAlarmReset6 = 53,

   42   DigitalAlarmReset7 = 54, DigitalAlarmReset8 = 55,

   43   AnalogAlarmReset1 = 56, AnalogAlarmReset2 = 57,

   44   AnalogAlarmReset3 = 58, AnalogAlarmReset4 = 59,

   45   AnalogAlarmReset5 = 60, AnalogAlarmReset6 = 61,

   46   AnalogAlarmReset7 = 62, AnalogAlarmReset8 = 63,

   47   BandSpeed = 64,

   48   BandRpm = 65,

   49   BandServiceBrakeBySpeed = 66,

   50   BandGear1 = 67, BandGear2 = 68, BandGear3 = 69,

   51   BandTurnG1 = 70, BandTurnG2 = 71, BandTurnG3 = 72, BandTurnG4 = 73,

   52   BandTurnG5 = 74, BandTurnG6 = 75, BandTurnG7 = 76, BandTurnG8 = 77,

   53   HardBrakeAccelerometer = 78,

   54   HardBrakeDeltaVDeltaT = 79,

   55   HardCornering = 80,

   56   DigitalPotCalibrationAcknowledgement = 88,

   57   IButtonScanned = 89,

   58   AnonymousMovement = 90,

   59   GeofenceSpeedExceededDelta = 91,

   60   GeofenceSpeedExceededBoundary = 92,

   61   ManDownDuressActivated = 93,

   62   DistanceTravelled = 94,

   63   Rollover = 100,

   64   ManDownNoMovement = 101,

   65   ManDownOutOfRange = 102,

   66   PumpCounter1Data = 103, PumpCounter2Data = 104,

   67   FuelLevelChanged = 105,

   68   Pump1Start = 106, Pump1End = 107,

   69   Pump2Start = 108, Pump2End = 109,

   70   RpmRunningSeconds = 110,

   71   ExcessiveRpmStart = 111, ExcessiveRpmEnd = 112,

   72   Terrain = 113,

   73   GeofenceSpeedExceededSummary = 114,

   74   RollingInNeutralStart = 25, RollingInNeutralEnd = 115,

   75   LogViaSatellite = 116,

   76   TripSummary = 117,

   77   RunningPeriodEnd = 118,

   78   FirstValidGpsLock = 119,

   79   Seatbelt = 120,

   80   Handbrake = 121,

   81   DriverRestSelected = 122,

   82   DriverResumptionSelected = 123,

   83   DriverLogOutSelected = 124,

   84   DriverFixedMessage = 125,

   85 }

   86 public enum Command

   87 {

   88   DeviceNotResponding = 0xFF00,

   89   FirmwareProgress = 0xFF01,

   90   DestroySession = 0xFF02,

   91   EventsWaiting = 0x0100,

   92   ShortPollRequest = 0x0200,

   93   ShortPollResponse = 0x0300,

   94   LongPollRequest = 0x0400,

   95   LongPollResponse = 0x0500,

   96   EventResponse = 0x0600,

   97   Acknowledge = 0x0700,

   98   LogRequest = 0x0800,

   99   LogResponse = 0x0900,

  100   RequestNextLog = 0x0A00,

  101   WriteParameterBlock = 0x0C00,

  102   ReadParameterBlock = 0x0D00,

  103   BlockMapRequest = 0x1400,

  104   BlockMapResponse = 0x1500,

  105   CommitFirmware = 0x1601,

  106   RebootDevice = 0x1700,

  107   ServerPresenceRequest = 0x7300,

  108   ServerPresenceResponse = 0x7400,

  109   ParameterBlock = 0x0E00,

  110   EventRequest = 0x1B00,

  111   BurstFirmwareBlock = 0x4000,

  112   WriteFirmwareBlock = 0x5000,

  113   AckFirmwareBlock = 0x6000,

  114   WriteString = 0x2400,

  115   ReadString = 0x2500,

  116   ReadStringResponse = 0x2600,

  117   NegativeAcknowledge = 0x2700,

  118   PrimaryDigitalOutHigh = 0x7500,

  119   SatelliteEventResponse = 0x9000,

  120   SatelliteEventResponseRequiresAck = 0x9100,

  121   SatelliteEventAck = 0x9200,

  122 }

Published 04-09-2009 11:24 by peterw