Exemple #1
0
        private bool ConfigCAN()
        {
            INIT_CONFIG config = channel.Config;

            CAN_MODE mode     = (CAN_MODE)Enum.ToObject(typeof(CAN_MODE), this.cbxCANMode.SelectedIndex);
            int      baudRate = Convert.ToInt32(cbxCANBaudRate.SelectedItem);

            if (m_IsConfigured && mode == channel.Mode && baudRate == channel.BaudRate)
            {
                // already configured, no need to update
                return(true);
            }

            CAN.ConfigMode(mode, ref config);
            CAN.ConfigBaudRate(baudRate, ref config);

            if (channel.InitCAN(baudRate, ref config) != (uint)CAN_RESULT.SUCCESSFUL)
            {
                m_IsConfigured = false;
                return(false);
            }
            m_IsConfigured = true;
            return(true);
        }
Exemple #2
0
 public static void ConfigMode(CAN_MODE mode, ref INIT_CONFIG pInitConfig)
 {
     pInitConfig.Mode = (byte)mode;
 }
Exemple #3
0
 public static string FindCANModeKey(CAN_MODE mode)
 {
     return(FindKey(mode, CAN_MODE_LIST));
 }