private void process_can_data(Can_Data can) { for (int i = 0; i < can_buf_len; i++) { if (can_buf[i].id < 0) { can_buf[i].id = can.id; can_buf[i].period = can.period; can_buf[i].len = can.len; for (int j = 0; j < can.len; j++) { can_buf[i].data[j] = can.data[j]; } return; } else if (can_buf[i].id == can.id) { can_buf[i].id = can.id; can_buf[i].period += can.period; can_buf[i].len = can.len; for (int j = 0; j < can.len; j++) { can_buf[i].data[j] = can.data[j]; } return; } } flag_overflow = true; }
private void Can_Data_Change(ref Can_Data c1, ref Can_Data c2) { Can_Data tmp = new Can_Data(); tmp.data = new byte[8]; Can_Data_Copy(c1, ref tmp); Can_Data_Copy(c2, ref c1); Can_Data_Copy(tmp, ref c2); }
private void Can_Data_Copy(Can_Data src, ref Can_Data des) { des.id = src.id; des.period = src.period; des.len = src.len; for (int i = 0; i < src.len; i++) { des.data[i] = src.data[i]; } }
private Can_Data getRxData(string info) { Can_Data tmp = can_tmp; string[] arr = info.Split(','); tmp.id = StrFormat.AsciiHexToInt(arr[0]); tmp.period = StrFormat.AsciiHexToULong(arr[1]); tmp.len = StrFormat.AsciiHexToInt(arr[2]); for (int i = 0; i < tmp.len; i++) { tmp.data[i] = (byte)StrFormat.AsciiHexToInt(arr[3 + i]); } return(tmp); }
//---------------------------- private string CanDataToTxCmd(Can_Data can) { StringBuilder buffer = new StringBuilder(); buffer.Append("msg "); buffer.Append(can.id.ToString("X")); buffer.Append(","); buffer.Append(can.period.ToString("D")); buffer.Append(","); buffer.Append(can.len.ToString("D")); buffer.Append(","); for (int i = 0; i < can.len; i++) { buffer.Append(can.data[i].ToString("X")); buffer.Append(","); } return(buffer.ToString()); }