public static bool Set_I2C_Bit_Rate(double p_Bit_Rate) { bool flag = false; byte num = 0; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if ((p_Bit_Rate < 39.1) || (p_Bit_Rate > 5000.0)) { return(flag); } 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); } num = (byte)(Math.Round((double)((20000.0 / p_Bit_Rate) / 4.0)) - 1.0); buffer2[30] = num; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str)); }
public static bool Set_Source_Voltage(double p_voltage) { 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)) { return(flag); } if ((p_voltage < 0.0) || (p_voltage > 5.0)) { return(flag); } 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)(((p_voltage * 1000.0) + 43.53) / 21.191)); buffer2[0x13] = (byte)num; buffer2[20] = (byte)(num / 4); buffer2[0x10] = (byte)(buffer2[0x10] | 0x20); buffer2[0x10] = (byte)(buffer2[0x10] | 0x40); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }
public static bool Configure_PICkitSerial_For_I2CSlave_Interactive_Mode(byte p_slave_addr, byte p_slave_mask) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (!Basic.Get_Status_Packet(ref array2)) { return(false); } byte b = array2[28]; byte b2 = array2[27]; if (Basic.Configure_PICkitSerial(7, true) && (Utilities.m_flags.HID_DeviceReady != false)) { Array.Clear(array, 0, array.Length); Array.Clear(array2, 0, array2.Length); if (!Basic.Get_Status_Packet(ref array2)) { return(false); } array2[23] = 1; array2[27] = b2; array2[28] = b; array2[29] = p_slave_addr; array2[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } return(result); }
private static void flash_the_busy_led() { byte num = 0xc1; 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 (Get_Status_Packet(ref buffer2)) { buffer2[7] = (byte)(buffer2[7] | 0x20); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str); if (USBWrite.Send_LED_State_Cmd(1, num)) { buffer2[7] = (byte)(buffer2[7] & 0xdf); Thread.Sleep(0x7d0); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str); } } } }
public static bool Set_Pullup_State(bool p_enable) { 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_enable) { buffer2[0x10] = (byte)(buffer2[0x10] | 0x10); } else { buffer2[0x10] = (byte)(buffer2[0x10] & 0xef); } USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }
private static void Reset_Control_Block_Thread() { m_reset_cb.WaitOne(); string str = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; string str2 = ""; Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); I2CS.reset_buffers(); if (USBWrite.Update_Status_Packet()) { Utilities.m_flags.g_status_packet_mutex.WaitOne(); for (int i = 0; i < array.Length; i++) { array[i] = Constants.STATUS_PACKET_DATA[i]; } Utilities.m_flags.g_status_packet_mutex.ReleaseMutex(); USBWrite.configure_outbound_control_block_packet(ref buffer2, ref str, ref array); USBWrite.write_and_verify_config_block(ref buffer2, ref str, true, ref str2); } m_reset_cb.ReleaseMutex(); }
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 Configure_PICkitSerial_For_I2CSlave_Auto_Mode(byte p_slave_addr, byte p_slave_mask, byte p_array_byte_count, ref byte[] p_profile_array, ref string p_result_str) { byte[] array = new byte[65]; byte[] array2 = new byte[255]; byte[] array3 = new byte[65]; bool result = false; string text = ""; Array.Clear(array, 0, array.Length); Array.Clear(array3, 0, array3.Length); Mode.update_status_packet_data(7, ref array3); array3[23] = 2; array3[29] = p_slave_addr; array3[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array3); USBWrite.Send_Cold_Reset_Cmd(); bool flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); Array.Clear(array2, 0, array2.Length); array2[0] = 0; array2[1] = 5; array2[2] = p_array_byte_count; for (int i = 3; i < (int)(p_array_byte_count + 3); i++) { array2[i] = p_profile_array[i - 3]; } USBWrite.Send_Script_To_PICkitS(ref array2); USBWrite.Send_Warm_Reset_Cmd(); if (flag) { if (USBWrite.Update_Status_Packet()) { Utilities.m_flags.g_status_packet_mutex.WaitOne(); int j; for (j = 7; j < 31; j++) { if (Constants.STATUS_PACKET_DATA[j] != array[j - 5]) { p_result_str = string.Format("Byte {0} failed verification in config block write.\n Value reads {1:X2}, but should be {2:X2}.", j - 7, Constants.STATUS_PACKET_DATA[j], array[j - 5]); break; } } if (j == 31) { result = true; p_result_str = string.Format("PICkit Serial Analyzer correctly updated.", new object[0]); } Utilities.m_flags.g_status_packet_mutex.ReleaseMutex(); } else { p_result_str = string.Format("Error requesting config verification - Config Block may not be updated correctly", new object[0]); } } else { p_result_str = string.Format("Error sending config packet - Config Block may not be updated correctly", new object[0]); } return(result); }
public static bool Set_I2CSlave_Address_and_Mask(byte p_slave_addr, byte p_slave_mask) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (!Basic.Get_Status_Packet(ref array2)) { return(false); } 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); } array2[29] = p_slave_addr; array2[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } return(result); }
public static bool Set_Baud_Rate(ushort p_baud) { 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); } int num = ((int)Math.Round((double)((20000000.0 / ((double)p_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); return(USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str)); }
private static void flash_the_busy_led() { byte p_value = 193; 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; } byte[] expr_66_cp_0 = array2; int expr_66_cp_1 = 7; expr_66_cp_0[expr_66_cp_1] |= 32; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); if (USBWrite.Send_LED_State_Cmd(1, p_value)) { byte[] expr_9E_cp_0 = array2; int expr_9E_cp_1 = 7; expr_9E_cp_0[expr_9E_cp_1] &= 223; Thread.Sleep(2000); USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } } }
public static bool Set_Source_Voltage(double p_voltage) { 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) { if (p_voltage < 0.0 || p_voltage > 5.0) { return(result); } 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((p_voltage * 1000.0 + 43.53) / 21.191); array2[19] = (byte)num; array2[20] = (byte)(num / 4); byte[] expr_BA_cp_0 = array2; int expr_BA_cp_1 = 16; expr_BA_cp_0[expr_BA_cp_1] |= 32; byte[] expr_D2_cp_0 = array2; int expr_D2_cp_1 = 16; expr_D2_cp_0[expr_D2_cp_1] |= 64; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Configure_PICkitSerial_For_I2CSlave_Default_Mode(byte p_slave_addr, byte p_slave_mask, byte p_read_byte_0_data, byte p_read_bytes_1_N_data) { bool result = false; if (Basic.Configure_PICkitSerial(7, true)) { 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); } array2[23] = 0; array2[27] = p_read_bytes_1_N_data; array2[28] = p_read_byte_0_data; array2[29] = p_slave_addr; array2[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } } return(result); }
public static bool Set_Pullup_State(bool p_enable) { 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_enable) { byte[] expr_64_cp_0 = array2; int expr_64_cp_1 = 16; expr_64_cp_0[expr_64_cp_1] |= 16; } else { byte[] expr_7E_cp_0 = array2; int expr_7E_cp_1 = 16; expr_7E_cp_0[expr_7E_cp_1] &= 239; } USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Set_I2C_Bit_Rate(double p_Bit_Rate) { bool result = false; string text = ""; string text2 = ""; byte[] array = new byte[65]; byte[] array2 = new byte[65]; if (p_Bit_Rate < 39.1 || p_Bit_Rate > 5000.0) { return(result); } 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); } byte b = (byte)(Math.Round(20000.0 / p_Bit_Rate / 4.0) - 1.0); array2[30] = b; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text); } return(result); }
public static bool Configure_PICkitSerial_For_I2CSlave_Default_Mode(byte p_slave_addr, byte p_slave_mask, byte p_read_byte_0_data, byte p_read_bytes_1_N_data) { bool flag = false; if (!Basic.Configure_PICkitSerial(7, true)) { return(flag); } 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); } buffer2[0x17] = 0; buffer2[0x1b] = p_read_bytes_1_N_data; buffer2[0x1c] = p_read_byte_0_data; buffer2[0x1d] = p_slave_addr; buffer2[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str)); }
public static bool Set_I2CSlave_Address_and_Mask(byte p_slave_addr, byte p_slave_mask) { bool flag = false; string str = ""; string str2 = ""; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0x41]; if (!Basic.Get_Status_Packet(ref buffer2)) { return(false); } 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); } buffer2[0x1d] = p_slave_addr; buffer2[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str)); }
public static bool Configure_PICkitSerial_For_I2CSlave_Auto_Mode(byte p_slave_addr, byte p_slave_mask, byte p_array_byte_count, ref byte[] p_profile_array, ref string p_result_str) { bool flag = false; byte[] array = new byte[0x41]; byte[] buffer2 = new byte[0xff]; byte[] buffer3 = new byte[0x41]; bool flag2 = false; string str = ""; int index = 0; Array.Clear(array, 0, array.Length); Array.Clear(buffer3, 0, buffer3.Length); Mode.update_status_packet_data(7, ref buffer3); buffer3[0x17] = 2; buffer3[0x1d] = p_slave_addr; buffer3[30] = p_slave_mask; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer3); USBWrite.Send_Cold_Reset_Cmd(); flag = USBWrite.Send_Data_Packet_To_PICkitS(ref array); Array.Clear(buffer2, 0, buffer2.Length); buffer2[0] = 0; buffer2[1] = 5; buffer2[2] = p_array_byte_count; for (int i = 3; i < (p_array_byte_count + 3); i++) { buffer2[i] = p_profile_array[i - 3]; } USBWrite.Send_Script_To_PICkitS(ref buffer2); USBWrite.Send_Warm_Reset_Cmd(); if (!flag) { p_result_str = string.Format("Error sending config packet - Config Block may not be updated correctly", new object[0]); return(flag2); } if (!USBWrite.Update_Status_Packet()) { p_result_str = string.Format("Error requesting config verification - Config Block may not be updated correctly", new object[0]); return(flag2); } Utilities.m_flags.g_status_packet_mutex.WaitOne(); index = 7; while (index < 0x1f) { if (Constants.STATUS_PACKET_DATA[index] != array[index - 5]) { p_result_str = string.Format("Byte {0} failed verification in config block write.\n Value reads {1:X2}, but should be {2:X2}.", index - 7, Constants.STATUS_PACKET_DATA[index], array[index - 5]); break; } index++; } if (index == 0x1f) { flag2 = true; p_result_str = string.Format("PICkit Serial Analyzer correctly updated.", new object[0]); } Utilities.m_flags.g_status_packet_mutex.ReleaseMutex(); return(flag2); }
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 Configure_PICkitSerial_For_LIN(bool p_chip_select_hi, bool p_receive_enable, bool p_autobaud) { bool flag = false; if ((Utilities.m_flags.HID_read_handle != IntPtr.Zero) && Basic.Configure_PICkitSerial(10, true)) { 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); flag = USBWrite.write_and_verify_config_block(ref array, ref str2, true, ref str); if (flag) { Get_LIN_BAUD_Rate(); } } return(flag); }
public static bool Set_Buffer_Flush_Parameters(bool p_flush_on_count, bool p_flush_on_time, byte p_flush_byte_count, double p_flush_interval) { 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_flush_on_count) { byte[] expr_66_cp_0 = array2; int expr_66_cp_1 = 7; expr_66_cp_0[expr_66_cp_1] |= 64; } else { byte[] expr_7F_cp_0 = array2; int expr_7F_cp_1 = 7; expr_7F_cp_0[expr_7F_cp_1] &= 191; } if (p_flush_on_time) { byte[] expr_9C_cp_0 = array2; int expr_9C_cp_1 = 7; expr_9C_cp_0[expr_9C_cp_1] |= 128; } else { byte[] expr_B8_cp_0 = array2; int expr_B8_cp_1 = 7; expr_B8_cp_0[expr_B8_cp_1] &= 127; } array2[10] = p_flush_byte_count; byte b = (byte)Math.Round(p_flush_interval / 0.409); array2[11] = b; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Configure_PICkitSerial(int p_mode, bool p_reset) { 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) { Array.Clear(array, 0, array.Length); Array.Clear(buffer2, 0, buffer2.Length); Mode.update_status_packet_data(p_mode, ref buffer2); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); flag = USBWrite.write_and_verify_config_block(ref array, ref str2, p_reset, ref str); } return(flag); }
public static bool Configure_PICkitSerial(int p_mode, bool p_reset) { 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); Mode.update_status_packet_data(p_mode, ref array2); USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, p_reset, ref text); } return(result); }
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); }
public static bool Set_Buffer_Flush_Parameters(bool p_flush_on_count, bool p_flush_on_time, byte p_flush_byte_count, double p_flush_interval) { 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_flush_on_count) { buffer2[7] = (byte)(buffer2[7] | 0x40); } else { buffer2[7] = (byte)(buffer2[7] & 0xbf); } if (p_flush_on_time) { buffer2[7] = (byte)(buffer2[7] | 0x80); } else { buffer2[7] = (byte)(buffer2[7] & 0x7f); } buffer2[10] = p_flush_byte_count; byte num = (byte)Math.Round((double)(p_flush_interval / 0.409)); buffer2[11] = num; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }
public static bool Tell_PKSA_To_Use_External_Voltage_Source() { 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); } buffer2[0x10] = (byte)(buffer2[0x10] & 0xdf); USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, 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 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); }
public static bool Set_Buffer_Flush_Time(double p_time) { 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); } byte b = (byte)Math.Round(p_time / 0.409); array2[11] = b; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Tell_PKSA_To_Power_My_Device() { 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); } byte[] expr_61_cp_0 = array2; int expr_61_cp_1 = 16; expr_61_cp_0[expr_61_cp_1] |= 32; USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2); result = USBWrite.write_and_verify_config_block(ref array, ref text2, false, ref text); } return(result); }
public static bool Set_Buffer_Flush_Time(double p_time) { 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); } byte num = (byte)Math.Round((double)(p_time / 0.409)); buffer2[11] = num; USBWrite.configure_outbound_control_block_packet(ref array, ref str, ref buffer2); return(USBWrite.write_and_verify_config_block(ref array, ref str2, false, ref str)); }