Exemplo n.º 1
0
        public SpheroCommandPacket(SpheroCommand commandId,
                                   byte sequenceNumber, params byte[] packetData)
            : base()
        {
            this.data = new byte[7 + (packetData != null ? packetData.Length : 0)];

            this.data[0] = 0xFF;                      // SOP1
            this.data[1] = 0xFF;                      // SOP2
            this.data[2] = (byte)DeviceID.DID_SPHERO; // Device ID
            this.data[3] = (byte)commandId;           // Command ID
            this.data[4] = sequenceNumber;

            if (packetData != null)
            {
                this.data[5] = (byte)(packetData.Length + 1);
                Array.Copy(packetData, 0, this.data, 6, packetData.Length);
            }
            else
            {
                this.data[5] = 0x01;
            }

            this.data[this.data.Length - 1] = CalculateChecksum(this.data);
        }
Exemplo n.º 2
0
        public static string FullName(this SpheroCommand code)
        {
            switch (code)
            {
            case SpheroCommand.CMD_ABORT_MACRO:
                return("Abort Macro");

            case SpheroCommand.CMD_ABORT_ORBBAS:
                return("Abort orbBasic Program");

            case SpheroCommand.CMD_ANSWER_INPUT:
                return("Return Answer Input");

            case SpheroCommand.CMD_APPEND_FRAG:
                return("Append orbBasic Fragment");

            case SpheroCommand.CMD_APPEND_TEMP_MACRO_CHUNK:
                return("Append Macro Chunk");

            case SpheroCommand.CMD_BOOST:
                return("Boost");

            case SpheroCommand.CMD_COMMIT_TO_FLASH:
                return("Commit Program to Flash");

            case SpheroCommand.CMD_ERASE_ORBBAS:
                return("Erase orbBasic Code");

            case SpheroCommand.CMD_EXEC_ORBBAS:
                return("Execute orbBasic Program");

            case SpheroCommand.CMD_GET_CHASSIS_ID:
                return("Get Chassis ID");

            case SpheroCommand.CMD_GET_CONFIG_BLK:
                return("Get Config Block");

            case SpheroCommand.CMD_GET_DEVICE_MODE:
                return("Get Device Mode");

            case SpheroCommand.CMD_GET_OPTIONS_FLAG:
                return("Get Options");

            case SpheroCommand.CMD_GET_PW_SEED:
                return("Set PW Seed");

            case SpheroCommand.CMD_GET_RGB_LED:
                return("Get RGB LED");

            case SpheroCommand.CMD_GET_SSB:
                return("Get SSB");

            case SpheroCommand.CMD_GET_TEMP_OPTIONS_FLAG:
                return("Get Temp Options");

            case SpheroCommand.CMD_INIT_MACRO_EXECUTIVE:
                return("Init Macro Executive");

            case SpheroCommand.CMD_LOCATOR:
                return("Locator");

            case SpheroCommand.CMD_MACRO_STATUS:
                return("Macro Status");

            case SpheroCommand.CMD_MOVE:
                return("Move");

            case SpheroCommand.CMD_READ_LOCATOR:
                return("Read Locator");

            case SpheroCommand.CMD_REENABLE_DEMO:
                return("Re-enable Demo");

            case SpheroCommand.CMD_ROLL:
                return("Roll");

            case SpheroCommand.CMD_RUN_MACRO:
                return("Run Macro");

            case SpheroCommand.CMD_SAVE_MACRO:
                return("Save Macro");

            case SpheroCommand.CMD_SAVE_TEMP_MACRO:
                return("Save Temp Macro");

            case SpheroCommand.CMD_SELF_LEVEL:
                return("Self Level");

            case SpheroCommand.CMD_SET_ACCELERO:
                return("Set Accelerometer");

            case SpheroCommand.CMD_SET_BACK_LED:
                return("Set Back LED");

            case SpheroCommand.CMD_SET_CAL:
                return("Set Heading");

            case SpheroCommand.CMD_SET_CFG_BLOCK:
                return("Set Config Block");

            case SpheroCommand.CMD_SET_CHASSIS_ID:
                return("Set Chassis ID");

            case SpheroCommand.CMD_SET_COLLISION_DET:
                return("Set Collision Detection");

            case SpheroCommand.CMD_SET_CREATION_DATE:
                return("Set Creation Date");

            case SpheroCommand.CMD_SET_DATA_STREAMING:
                return("Set Data Streaming");

            case SpheroCommand.CMD_SET_DEVICE_MODE:
                return("Set Device Mode");

            case SpheroCommand.CMD_SET_MACRO_PARAM:
                return("Set Macro Parameters");

            case SpheroCommand.CMD_SET_MOTION_TO:
                return("Set Motion To");

            case SpheroCommand.CMD_SET_OPTIONS_FLAG:
                return("Set Options");

            case SpheroCommand.CMD_SET_RAW_MOTORS:
                return("Set Raw Motors");

            case SpheroCommand.CMD_SET_RGB_LED:
                return("Set RGB LED");

            case SpheroCommand.CMD_SET_ROTATION_RATE:
                return("Set Rotation Rate");

            case SpheroCommand.CMD_SET_SSB:
                return("Set SSB");

            case SpheroCommand.CMD_SET_SSB_PARAMS:
                return("Set SSB Params");

            case SpheroCommand.CMD_SET_STABILIZ:
                return("Set Stabilization");

            case SpheroCommand.CMD_SET_TEMP_OPTIONS_FLAG:
                return("Set Temp Options");

            case SpheroCommand.CMD_SET_VDL:
                return("Set VDL");

            case SpheroCommand.CMD_SSB_ADD_XP:
                return("SSB Add XP");

            case SpheroCommand.CMD_SSB_BUY:
                return("SSB Buy");

            case SpheroCommand.CMD_SSB_ENABLE_ASYNC:
                return("SSB Enable Async");

            case SpheroCommand.CMD_SSB_GRANT_CORES:
                return("SSB Grant Cores");

            case SpheroCommand.CMD_SSB_LEVEL_UP_ATTR:
                return("SSB Level Up Attribute");

            case SpheroCommand.CMD_SSB_REFILL:
                return("SSB Refill");

            case SpheroCommand.CMD_SSB_USE_CONSUMEABLE:
                return("SSB Use Consumable");

            default:
                return("Unknown Code");
            }
        }