//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #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); }
public MainWindow() { mot1 = new C_Motor(1); InitializeComponent(); INIT_logger(); INIT_spi(); }
public C_cmdin(string _strHex, string _del, string _cmdStr) { //num = _num; byCmdin = C_Motor.strHex2byteArray(_strHex, _del); cmdStr = _cmdStr; }
public C_cmdin(string _strHex_concatenated, string _cmdStr) { //num = _num; byCmdin = C_Motor.strHex2byteArray(_strHex_concatenated); cmdStr = _cmdStr; }
private void SEND_cmdInner(Byte[] inner, Byte id) { SEND_cmd(C_Motor.CREATE_cmdFromInner(inner, id)); }