#!/usr/bin/env python

from array import array

allDescriptors = {
  "digital-in": {
    "description": "This is a digital sensor.  It can be used to get the " + \
                   "state of up to four switches.",
    "chunksNumer": 0xFF,  # TODO(cduck): What is this?
    "chunksDenom": 0xFF,
    "channels": [
      { "description": "This is the only digital channel.",
        "type": 0x00,
        "additional": array('B', [0x01, 0xFF, 0xFF])
      },
    ]
  },

  "analog-in": {
    "description": "This is a digital sensor.  It can be used to get the " + \
                   "state of up to four switches.",
    "chunksNumer": 0xFF,
    "chunksDenom": 0xFF,
    "channels": [
      { "description": "This is the only analog channel.",
        "type"  : 0x01,
        "additional": array('B', [0xFF, 0xFF, 0xFF, 0xFF])
        # "additional" value should also contain n bytes of calibration data
      },
    ]
  },

  "grizzly": {
    "description": "This is a digital sensor.  It can be used to get the " + \
                  "state of up to four switches.",
    "chunksNumer": 0xFF,
    "chunksDenom": 0xFF,
    "channels": [
      # TODO (tobinsarah): get this from Casey's grizzly protocol
      { "description": "This is the only grizzly channel.",
        "type": 0x80,
        "additional": array('B', [0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
      },
    ]
  },

  "buzzer": {
    "description": "This is a battery buzzer. For now its channel has the " + \
                   "same format as analog in.",
    "chunksNumer": 0xFF,
    "chunksDenom": 0xFF,
    "channels": [
      { "description": "This is the only buzzer channel.",
        "type": 0x81,
        "additional": array('B', [0xFF, 0xFF, 0xFF, 0xFF])
        # "additional" value should also contain n bytes of calibration data
      },
    ]
  },

  "flag": {
    "description": "This is a team flag. For now its channel has the same " + \
                   "format as digital.",
    "chunksNumer": 0xFF,  # TODO(cduck): What is this?
    "chunksDenom": 0xFF,
    "channels": [
      { "description": "This is the only digital channel.",
        "type": 0x82,
        "additional": array('B', [0x01, 0xFF, 0xFF])
      },
    ]
  }
}

def allTypes():
  return allDescriptors.keys()
def descriptor(sensorConfig):
  return allDescriptors[sensorConfig]


@@ -41,16 +41,145 @@
  array%0A%0A
+gameModeChannel = %7B %22description%22: %22The game mode channel.%22,%0A        %22type%22: 0xFE,%0A        %22additional%22: array('B', %5B%5D)%0A      %7D%0A%0A
 allDescr
@@ -428,32 +428,55 @@
   %22channels%22: %5B%0A
+      gameModeChannel,%0A
       %7B %22descrip
@@ -823,32 +823,55 @@
   %22channels%22: %5B%0A
+      gameModeChannel,%0A
       %7B %22descrip
@@ -1373,16 +1373,39 @@
 rotocol%0A
+      gameModeChannel,%0A
       %7B 
@@ -1766,32 +1766,55 @@
   %22channels%22: %5B%0A
+      gameModeChannel,%0A
       %7B %22descrip
@@ -2240,32 +2240,32 @@
 ksDenom%22: 0xFF,%0A
-
     %22channels%22: 
@@ -2262,24 +2262,47 @@
 hannels%22: %5B%0A
+      gameModeChannel,%0A
       %7B %22des

Add game mode channel to descriptor for all sensors