public static bool Change_LIN_BAUD_Rate(ushort Baud) { bool flag = false; int num = 0; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } num = ((int)Math.Round((double)((20000000.0 / ((double)Baud)) / 4.0))) - 1; buffer2[0x1d] = (byte)num; buffer2[30] = (byte)(num >> 8); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); flag = USBWrite.write_and_verify_LIN_config_block(ref array, ref str2, true, ref str); } if (flag) { Get_LIN_BAUD_Rate(); } return(flag); }
public static bool Change_LIN_BAUD_Rate(ushort Baud) { bool flag = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } int num = (int)Math.Round(20000000.0 / (double)Baud / 4.0) - 1; array2[29] = (byte)num; array2[30] = (byte)(num >> 8); USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); flag = USBWrite.write_and_verify_LIN_config_block(ref array, ref text2, true, ref text); } if (flag) { LIN.Get_LIN_BAUD_Rate(); } return(flag); }
public static bool Set_LIN_Options(bool p_chip_select_hi, bool p_receive_enable, bool p_autobaud) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } if (p_chip_select_hi) { byte[] expr_67_cp_0 = array2; int expr_67_cp_1 = 23; expr_67_cp_0[expr_67_cp_1] |= 8; } else { byte[] expr_80_cp_0 = array2; int expr_80_cp_1 = 23; expr_80_cp_0[expr_80_cp_1] &= 247; } if (p_receive_enable) { byte[] expr_9E_cp_0 = array2; int expr_9E_cp_1 = 23; expr_9E_cp_0[expr_9E_cp_1] |= 64; } else { byte[] expr_B8_cp_0 = array2; int expr_B8_cp_1 = 23; expr_B8_cp_0[expr_B8_cp_1] &= 191; } if (p_autobaud) { byte[] expr_D6_cp_0 = array2; int expr_D6_cp_1 = 23; expr_D6_cp_0[expr_D6_cp_1] |= 128; } else { byte[] expr_F3_cp_0 = array2; int expr_F3_cp_1 = 23; expr_F3_cp_0[expr_F3_cp_1] &= 127; } USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_LIN_config_block(ref array, ref text2, true, ref text); } return(result); }
public static bool Set_LIN_Options(bool p_chip_select_hi, bool p_receive_enable, bool p_autobaud) { bool flag = false; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!(Utilities.m_flags.HID_read_handle != IntPtr.Zero)) { return(flag); } Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } if (p_chip_select_hi) { buffer2[0x17] = (byte)(buffer2[0x17] | 8); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0xf7); } if (p_receive_enable) { buffer2[0x17] = (byte)(buffer2[0x17] | 0x40); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0xbf); } if (p_autobaud) { buffer2[0x17] = (byte)(buffer2[0x17] | 0x80); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0x7f); } USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_LIN_config_block(ref array, ref str2, true, ref str)); }
private static bool Toggle_AutoBaud_Set(bool p_turn_autobaudset_on, ref ushort p_baud, ref string p_error_detail) { bool flag = false; int num = 0; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; p_error_detail = ""; if (Utilities.m_flags.HID_DeviceReady != false) //(Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { p_error_detail = "Could not poll PKSA for status."; return(false); } p_baud = LIN.calculate_baud_rate((ushort)((int)array2[29] + ((int)array2[30] << 8))); if (p_turn_autobaudset_on) { byte[] expr_8F_cp_0 = array2; int expr_8F_cp_1 = 23; expr_8F_cp_0[expr_8F_cp_1] |= 128; } else { byte[] expr_AC_cp_0 = array2; int expr_AC_cp_1 = 23; expr_AC_cp_0[expr_AC_cp_1] &= 127; } USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); while (!flag && num < 3) { num++; flag = USBWrite.write_and_verify_LIN_config_block(ref array, ref text2, false, ref text); p_error_detail += text2; } } return(flag); }
private static bool Toggle_AutoBaud_Set(bool p_turn_autobaudset_on, ref ushort p_baud, ref string p_error_detail) { bool flag = false; int num = 0; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; p_error_detail = ""; if (Utilities.m_flags.HID_read_handle != IntPtr.Zero) { Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); if (!Basic.Get_Status_Packet(ref buffer2)) { p_error_detail = "Could not poll PKSA for status."; return(false); } p_baud = calculate_baud_rate((ushort)(buffer2[0x1d] + (buffer2[30] << 8))); if (p_turn_autobaudset_on) { buffer2[0x17] = (byte)(buffer2[0x17] | 0x80); } else { buffer2[0x17] = (byte)(buffer2[0x17] & 0x7f); } USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); while (!flag && (num < 3)) { num++; flag = USBWrite.write_and_verify_LIN_config_block(ref array, ref str2, false, ref str); p_error_detail = p_error_detail + str2; } } return(flag); }