Example #1
0
File: Api.cs Project: serialbus/NGK
 public static extern F_CAN_RESULT fw_can_set_timeouts(
     SafeFileHandle hDev,
     ref F_CAN_TIMEOUTS pTimeouts);
Example #2
0
        /// <summary>
        /// Конструктор для десериализации
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public CanPort(SerializationInfo info, StreamingContext context)
        {
            this._InputBufferMessages = new Queue<Frame>(100);

            // Инициализируем дескриптор устройства
            this._DeviceHandle = new SafeFileHandle(IntPtr.Zero, true);
            this._DeviceHandle.Close();

            this._PortName = info.GetString("PortName");
            this._BitRate = (BaudRate)info.GetValue("BitRate", typeof(BaudRate));
            this._OpMode = (PortMode)info.GetValue("Mode", typeof(PortMode));
            this._ErrorFrameEnable = info.GetBoolean("ErrorFrameEnable");
            this._FrameFormat = (FrameFormat)info.GetValue("FrameFormat", typeof(FrameFormat));
            this._Timeouts = (F_CAN_TIMEOUTS)info.GetValue("Timeouts", typeof(F_CAN_TIMEOUTS));
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="portName"></param>
        /// <param name="bitRate"></param>
        /// <param name="frameFormat"></param>
        /// <param name="mode"></param>
        public CanPort(String portName, BaudRate bitRate, FrameFormat frameFormat,
            PortMode mode)
        {
            // Инициализируем буфер входящих сообщений
            this._InputBufferMessages = new Queue<Frame>(100);

            // Инициализируем дескриптор устройства
            this._DeviceHandle = new SafeFileHandle(IntPtr.Zero, true);
            this._DeviceHandle.Close();

            // Номер порта
            PortName = portName;
            _BitRate = bitRate;
            _FrameFormat = frameFormat;
            _OpMode = mode;

            // Структура таймаутов
            _Timeouts = new F_CAN_TIMEOUTS();
        }
Example #4
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="portNumber">Номер CAN-порта</param>
        public CanPort(Int32 portNumber)
        {
            // Инициализируем буфер входящих сообщений
            this._InputBufferMessages = new Queue<Frame>(100);

            // Инициализируем дескриптор устройства
            this._DeviceHandle = new SafeFileHandle(IntPtr.Zero, true);
            this._DeviceHandle.Close();

            // Номер порта
            if (portNumber <= 0)
            {
                throw new ArgumentOutOfRangeException(
                    "portNumber", 
                    "Недопустимое значение. Допускаются только положительные значения, больше нуля");
            }
            else
            {
                this.PortName = String.Format("CAN{0}", portNumber);
            }

            // Структура таймаутов
            _Timeouts = new F_CAN_TIMEOUTS();
        }
Example #5
0
        /// <summary>
        /// Конструктор
        /// </summary>
        public CanPort()
        {
            // Инициализируем бужер входящих сообщений
            this._InputBufferMessages = new Queue<Frame>(100);

            // Инициализируем дескриптор устройства
            this._DeviceHandle = new SafeFileHandle(IntPtr.Zero, true);
            this._DeviceHandle.Close();

            // Структура таймаутов
            _Timeouts = new F_CAN_TIMEOUTS();
        }
Example #6
0
File: Api.cs Project: serialbus/NGK
 public static extern F_CAN_RESULT fw_can_set_timeouts(
     SafeFileHandle hDev,
     ref F_CAN_TIMEOUTS pTimeouts);