示例#1
0
        /// <summary>
        /// Open the CAN hardware device via the CanFestival driver, NB this is currently a simple version that will
        /// not work with drivers that have more complex bus ids so only supports com port (inc usb serial) devices for the moment
        /// </summary>
        /// <param name="comport">COM PORT number</param>
        /// <param name="speed">CAN Bit rate</param>
        /// <param name="drivername">Driver to use</param>
        public void open(string comport, BUSSPEED speed, string drivername)
        {
            driver = loader.loaddriver(drivername);
            driver.open(string.Format("{0}", comport), speed);

            driver.rxmessage += Driver_rxmessage;

            threadrun = true;
            Thread thread = new Thread(new ThreadStart(asyncprocess));

            thread.Name = "CAN Open worker";
            thread.Start();

            if (connectionevent != null)
            {
                connectionevent(this, new ConnectionChangedEventArgs(true));
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            DriverLoader   loader = new libCanopenSimple.DriverLoader();
            DriverInstance driver = loader.loaddriver("can_usb_win32");

            driver.open("COM4", BUSSPEED.BUS_500Kbit);
            driver.rxmessage += Driver_rxmessage;

            while (true)
            {
                System.Threading.Thread.Sleep(10);
            }
        }
示例#3
0
        /// <summary>
        /// Open the CAN hardware device via the CanFestival driver, NB this is currently a simple version that will
        /// not work with drivers that have more complex bus ids so only supports com port (inc usb serial) devices for the moment
        /// </summary>
        /// <param name="comport">COM PORT number</param>
        /// <param name="speed">CAN Bit rate</param>
        /// <param name="drivername">Driver to use</param>
        public void open(int comport, BUSSPEED speed, string drivername)
        {
            driver = loader.loaddriver(drivername);
            driver.open(string.Format("COM{0}", comport), speed);

            driver.rxmessage += Driver_rxmessage;

            threadrun = true;
            Thread thread = new Thread(new ThreadStart(asyncprocess));

            thread.Name = "CAN Open worker";
            thread.Start();
        }