예제 #1
0
        public static bool Add_LIN_Slave_Profile_To_PKS(byte p_array_byte_count, ref byte[] p_profile_array, ref string p_result_str, ref int p_error_code)
        {
            bool flag = false;

            byte[] array  = new byte[65];
            byte[] array2 = new byte[255];
            byte[] array3 = new byte[65];
            bool   result = false;
            byte   b      = 0;
            byte   b2     = 0;
            string text   = "";

            p_error_code = 0;
            Array.Clear(array, 0, array.Length);
            Array.Clear(array3, 0, array3.Length);
            byte b3 = LIN.Number_Of_Bytes_In_CBUF3(ref b, ref b2);

            if (p_array_byte_count > b3)
            {
                p_result_str = string.Format("Byte count of {0} greater than allowed value of {1}.", p_array_byte_count, b3);
                p_error_code = 1;
                return(flag);
            }
            USBWrite.Clear_CBUF(3);
            if (!Basic.Get_Status_Packet(ref array3))
            {
                p_result_str = string.Format("Error reading status packet.", new object[0]);
                p_error_code = 2;
                return(false);
            }
            byte[] expr_A6_cp_0 = array3;
            int    expr_A6_cp_1 = 23;

            expr_A6_cp_0[expr_A6_cp_1] |= 32;
            USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array3);
            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];
            }
            bool flag2 = USBWrite.Send_Script_To_PICkitS(ref array2);

            if (flag & flag2)
            {
                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_error_code = 3;
                            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_error_code = 2;
                p_result_str = string.Format("Error sending config packet - Config Block may not be updated correctly", new object[0]);
            }
            return(result);
        }
예제 #2
0
 internal static void issue_error()
 {
     Basic.Reset_Control_Block();
     Error();
 }
예제 #3
0
        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_DeviceReady != false) && Basic.Configure_PICkitSerial(10, 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);
                    }
                    if (p_chip_select_hi)
                    {
                        byte[] expr_8D_cp_0 = array2;
                        int    expr_8D_cp_1 = 23;
                        expr_8D_cp_0[expr_8D_cp_1] |= 8;
                    }
                    else
                    {
                        byte[] expr_A6_cp_0 = array2;
                        int    expr_A6_cp_1 = 23;
                        expr_A6_cp_0[expr_A6_cp_1] &= 247;
                    }
                    if (p_receive_enable)
                    {
                        byte[] expr_C4_cp_0 = array2;
                        int    expr_C4_cp_1 = 23;
                        expr_C4_cp_0[expr_C4_cp_1] |= 64;
                    }
                    else
                    {
                        byte[] expr_DE_cp_0 = array2;
                        int    expr_DE_cp_1 = 23;
                        expr_DE_cp_0[expr_DE_cp_1] &= 191;
                    }
                    if (p_autobaud)
                    {
                        byte[] expr_FC_cp_0 = array2;
                        int    expr_FC_cp_1 = 23;
                        expr_FC_cp_0[expr_FC_cp_1] |= 128;
                    }
                    else
                    {
                        byte[] expr_119_cp_0 = array2;
                        int    expr_119_cp_1 = 23;
                        expr_119_cp_0[expr_119_cp_1] &= 127;
                    }
                    USBWrite.configure_outbound_control_block_packet(ref array, ref text, ref array2);
                    flag = USBWrite.write_and_verify_config_block(ref array, ref text2, true, ref text);
                    if (flag)
                    {
                        LIN.Get_LIN_BAUD_Rate();
                    }
                }
            }
            return(flag);
        }