static void Main(string[] args) { AccessPort accessPort = null; ServicePort servicePort = null; try { Logger.SetConsoleChannel(); Logger.SetLevels(Logger.Level.Information); // USB (first available USB port) accessPort = new AccessPort(); accessPort.EnumerateUsb(); accessPort.OpenUsb(0); servicePort = new ServicePort(accessPort); /* * Set the device services to connection-oriented or * connection-less (depending on the value of connection_oriented) */ servicePort.SetConnectionOriented(isConnectionOriented); // read property value : serial number PropertyValueRead(servicePort); // write property value : programming mode PropertyValueWrite(servicePort); // switch the programming mode on SwitchProgMode(servicePort, true); // read the programming mode ReadProgMode(servicePort); // read the individual address of devices which are in programming mode IndividualAddressProgModeRead(servicePort); // write the individual address of devices which are in programming mode IndividualAddressProgModeWrite(servicePort); // switch the programming mode off SwitchProgMode(servicePort, false); // read the programming mode ReadProgMode(servicePort); // Close the service port servicePort.Close(); // Close the service port accessPort.Close(); } catch (kdrive.KdriveException exception) { Console.WriteLine(exception.Message); } finally { if (servicePort != null) { servicePort.Dispose(); } if (accessPort != null) { accessPort.Dispose(); } Logger.Shutdown(); } }