示例#1
0
        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        #endregion Sending
        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        #region static functions
        //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        public static Byte[] CREATE_cmdFromInner(Byte[] byCmdin, Byte id)
        {
            // Instruction Packet = from pc to servo
            // OXFF 0XFF ID LENGTH INSTRUCTION PARAMETER1 …PARAMETER N CHECK SUM
            // inner contains only these bytes:
            // INSTRUCTION, PARAMETER_1, ..., PARAMETER_N

            // this function adds first two startBytes [0xFF,0xFF], its id Byte, length Byte and Checksum Byte

            // make it into ArrayList
            Byte[] cmd = new Byte[5 + byCmdin.Length];
            //ArrayList a_cmd = new ArrayList();
            //a_cmd.Add({0xFF, 0xFF})

            //{ 0xFF, 0xFF, id, len, inner, 0x00 };
            //{ 0   , 1   , 2 , 3  , 4...., last };
            cmd[2] = id;
            int q = 4;

            foreach (Byte by in byCmdin)
            {
                cmd[q] = by;
                q++;
            }
            cmd[3] = (Byte)(byCmdin.Length + 1); // = paramN+Instruction + 1 = paramN + 2 = len
            cmd[q] = C_Motor.GET_checkSum(cmd);
            cmd[0] = cmd[1] = 0xFF;
            return(cmd);
        }
示例#2
0
        public MainWindow()
        {
            mot1 = new C_Motor(1);
            InitializeComponent();

            INIT_logger();
            INIT_spi();
        }
示例#3
0
 public C_cmdin(string _strHex, string _del, string _cmdStr)
 {
     //num = _num;
     byCmdin = C_Motor.strHex2byteArray(_strHex, _del);
     cmdStr  = _cmdStr;
 }
示例#4
0
 public C_cmdin(string _strHex_concatenated, string _cmdStr)
 {
     //num = _num;
     byCmdin = C_Motor.strHex2byteArray(_strHex_concatenated);
     cmdStr  = _cmdStr;
 }
示例#5
0
 private void SEND_cmdInner(Byte[] inner, Byte id)
 {
     SEND_cmd(C_Motor.CREATE_cmdFromInner(inner, id));
 }