コード例 #1
0
 private bool SendRobotCommand(byte[] cmd, CONST.CB.CMD_INFO info)
 {
     // Default as standard UBT command with 10 bytes return
     if (info.minBytes < 0)
     {
         throw new Exception(string.Format("Command {0:X2}, expectCnt not configed", info.code));
     }
     return(SendRobotCommand(cmd, (uint)info.minBytes, (info.maxMs <= 0 ? DEFAULT_COMMAND_TIMEOUT : info.maxMs)));
 }
コード例 #2
0
 public bool V2_SaveEventHeader(byte mode, byte count, byte action)
 {
     CONST.CB.CMD_INFO info    = CONST.CB.SAVE_EVENT_HEADER;
     byte[]            command = { 0xA9, 0x9A, 0x0C, info.code, mode, RobotHandler.version, count, action, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xED };
     if (!V2_SendCommandWithSingleReturn(command))
     {
         UpdateInfo(String.Format("Fail saving event header"), MyUtil.UTIL.InfoType.error);
         return(false);
     }
     return(true);
 }
コード例 #3
0
 public byte[] V2_GetEventData(byte mode, byte startIdx)
 {
     CONST.CB.CMD_INFO info    = CONST.CB.GET_EVENT_DATA;
     byte[]            command = { 0xA9, 0x9A, 0x04, info.code, mode, startIdx, 00, 0xED };
     if (!SendRobotCommand(command, info) ||
         (receiveBuffer.Count != info.minBytes) || (receiveBuffer[2] != info.dataLen) ||
         (receiveBuffer[CONST.ED.OFFSET.MODE] != mode) ||
         (receiveBuffer[CONST.ED.OFFSET.START_IDX] != startIdx))
     {
         UpdateInfo(String.Format("Fail getting event header"), MyUtil.UTIL.InfoType.error);
         return(null);
     }
     return(receiveBuffer.ToArray());
 }
コード例 #4
0
        public bool V2_SaveEventData(byte mode, byte startIdx, byte count, byte[] data)
        {
            if (count > 8)
            {
                return(false);
            }
            int startPos = startIdx * BLOCKLY.EVENT.SIZE;
            int size     = count * BLOCKLY.EVENT.SIZE;

            if (startPos > data.Length)
            {
                return(false);
            }
            if (startPos + size > data.Length)
            {
                return(false);
            }

            CONST.CB.CMD_INFO info    = CONST.CB.SAVE_EVENT_DATA;
            byte[]            command = new byte[128];
            for (int i = 0; i < 128; i++)
            {
                command[i] = 0;
            }
            command[2] = 124;
            command[3] = info.code;
            command[4] = mode;
            command[5] = startIdx;
            command[6] = count;
            for (int i = 0; i < size; i++)
            {
                command[16 + i] = data[startPos + i];
            }
            if (!V2_SendCommandWithSingleReturn(command))
            {
                UpdateInfo(String.Format("Fail saving event data"), MyUtil.UTIL.InfoType.error);
                return(false);
            }
            return(true);
        }
コード例 #5
0
 // Some operation has variable result (e.g. lock servo which can lock / unlock multiple servo
 private bool SendRobotCommand(byte[] cmd, CONST.CB.CMD_INFO info, uint expectCnt)
 {
     return(SendRobotCommand(cmd, expectCnt, (info.maxMs <= 0 ? DEFAULT_COMMAND_TIMEOUT : info.maxMs)));
 }