static void Main(string[] args) { //Change these to load correct driver and connect it to correct bus string driver = "can_usb_win32"; string bus = "COM4"; BUSSPEED bitrate = BUSSPEED.BUS_500Kbit; try { DriverLoader loader = new DriverLoader(); DriverInstance instance = loader.loaddriver(driver); Console.WriteLine("Opening CAN device "); instance.open(bus, bitrate); instance.rxmessage += Instance_rxmessage; Console.WriteLine("listening for any traffic, press any key to exit .."); while (!Console.KeyAvailable) { } instance.close(); } catch (Exception e) { Console.WriteLine("That did not work out, exception message was \n" + e.ToString()); } Console.WriteLine("Press any key to exit"); while (!Console.KeyAvailable) { } }
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); } }