Beispiel #1
0
 private static bool set_OnReceive_timeout_from_baud_rate()
 {
     byte[] array = new byte[65];
     if (Utilities.m_flags.HID_DeviceReady != false)            //(Utilities.m_flags.HID_read_handle != IntPtr.Zero)
     {
         Array.Clear(array, 0, array.Length);
         if (!Basic.Get_Status_Packet(ref array))
         {
             return(false);
         }
         int p_baud = (int)LIN.calculate_baud_rate((ushort)((int)array[50] + ((int)array[51] << 8)));
         LIN.calculate_new_baud_dependent_onreceive_timeout(p_baud);
     }
     return(true);
 }
Beispiel #2
0
        public static ushort Get_LIN_BAUD_Rate()
        {
            byte[] array = new byte[65];
            ushort num   = 0;

            if (Utilities.m_flags.HID_DeviceReady != false)            //(Utilities.m_flags.HID_read_handle != IntPtr.Zero)
            {
                Array.Clear(array, 0, array.Length);
                if (Basic.Get_Status_Packet(ref array))
                {
                    num = LIN.calculate_baud_rate((ushort)((int)array[50] + ((int)array[51] << 8)));
                    LIN.m_last_master_baud_rate = num;
                }
            }
            return(num);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        private static void finish_this_frame()
        {
            LIN.m_we_are_finishing_a_frame = true;
            LIN.m_working_frame.BuildState.we_are_building_a_frame = false;
            LIN.m_FrameStartTimer.Change(-1, -1);
            bool flag = false;

            if (LIN.this_is_a_valid_frame())
            {
                if (LIN.m_next_frame_is_first_frame)
                {
                    LIN.m_working_frame.FrameInfo.time = 0.0;
                    LIN.m_next_frame_is_first_frame    = false;
                    flag = !USBRead.reset_timer_params();
                }
                if (LIN.m_working_frame.FrameInfo.baud != 0)
                {
                    LIN.m_working_frame.FrameInfo.baud = LIN.calculate_baud_rate(LIN.m_working_frame.FrameInfo.baud);
                }
                else
                {
                    LIN.m_working_frame.FrameInfo.baud = LIN.m_last_master_baud_rate;
                }
                LIN.m_OnReceive_error = 0;
                uint num = 0u;
                if (Status.There_Is_A_Status_Error(ref num))
                {
                    LIN.m_OnReceive_error = 4;
                    Device.Clear_Status_Errors();
                }
                if (LIN.m_OnReceive_error == 0 && LIN.m_working_frame.BuildState.we_had_a_status_error)
                {
                    LIN.m_OnReceive_error = 5;
                }
                else if (LIN.m_working_frame.BuildState.we_timed_out)
                {
                    LIN.m_OnReceive_error = 1;
                }
                else if (flag)
                {
                    LIN.m_OnReceive_error = 3;
                }
                else if (LIN.m_working_frame.BuildState.next_frame_header_received)
                {
                    LIN.m_OnReceive_error = 6;
                }
                if ((LIN.this_frame_is_different_than_last() && LIN.m_opmode == LIN.OPMODE.LISTEN) || LIN.m_opmode == LIN.OPMODE.DISPLAY_ALL)
                {
                    if (LIN.m_working_frame.BuildState.we_have_transmitted && LIN.m_working_frame.BuildState.transmit_data_byte_count_zero)
                    {
                        OnAnswer(LIN.m_working_frame.FrameInfo.FrameID, LIN.m_working_frame.FrameInfo.FrameData, LIN.m_working_frame.FrameInfo.bytecount, LIN.m_OnReceive_error, LIN.m_working_frame.FrameInfo.baud, LIN.m_working_frame.FrameInfo.time);
                    }
                    else if ((!LIN.m_working_frame.BuildState.we_have_transmitted || !LIN.m_working_frame.BuildState.transmit_data_byte_count_zero) && LIN.OnReceive != null)
                    {
                        if (LIN.m_OnReceive_error == 6)
                        {
                            LIN.m_OnReceive_error = 0;
                        }
                        OnReceive(LIN.m_working_frame.FrameInfo.FrameID, LIN.m_working_frame.FrameInfo.FrameData, LIN.m_working_frame.FrameInfo.bytecount, LIN.m_OnReceive_error, LIN.m_working_frame.FrameInfo.baud, LIN.m_working_frame.FrameInfo.time);
                    }
                }
                LIN.copy_this_frame_into_array();
            }
            LIN.reset_working_frame();
            LIN.m_working_frame_is_done.Set();
            LIN.m_we_are_finishing_a_frame = false;
        }