public static unsafe IntPtr[] GetDeviceList(int vendor, int product) { ArrayList ar = new ArrayList(); ftdi_device_list *devlist, d; ftdi_context ftdi = new ftdi_context(); ftdi_init(ref ftdi); if (ftdi_usb_find_all(ref ftdi, &devlist, vendor, product) < 0) { throw new Exception("ftdi_usb_find_all failed"); } for (d = devlist; d != null; d = d->next) { ar.Add(d->dev); } ftdi_deinit(ref ftdi); ftdi_list_free(&devlist); return((IntPtr[])ar.ToArray(typeof(IntPtr))); }
[DllImport("libftdi.so.0")] internal static extern int ftdi_read_pins(ref ftdi_context ftdi, out byte pins);
[DllImport("libftdi.so.0")] internal static extern int ftdi_set_interface(ref ftdi_context ftdi, Interface iface);
[DllImport("libftdi.so.0")] internal static extern int ftdi_write_data(ref ftdi_context ftdi, byte[] buf, int size);
[DllImport("libftdi.so.0")] internal static extern int ftdi_erase_eeprom(ref ftdi_context ftdi);
[DllImport("libftdi.so.0")] internal static extern int ftdi_usb_open(ref ftdi_context ftdi, int vendor, int product);
[DllImport("libftdi.so.0")] internal unsafe static extern int ftdi_usb_find_all(ref ftdi_context ftdi, ftdi_device_list **devlist, int vendor, int product);
[DllImport("libftdi.so.0")] internal static extern int ftdi_set_bitmode(ref ftdi_context ftdi, byte bitmask, byte mode);
[DllImport("libftdi.so.0")] internal static extern int ftdi_write_data_get_chunksize(ref ftdi_context ftdi, out uint chunksize);
[DllImport("libftdi.so.0")] internal static extern int ftdi_read_data_set_chunksize(ref ftdi_context ftdi, uint chunksize);
[DllImport("libftdi.so.0")] internal static extern int ftdi_usb_purge_buffers(ref ftdi_context ftdi);
[DllImport("libftdi.so.0")] internal static extern int ftdi_usb_close(ref ftdi_context ftdi);
[DllImport("libftdi.so.0")] internal static extern int ftdi_set_baudrate(ref ftdi_context ftdi, int baudrate);
[DllImport("libftdi.so.0")] internal static extern int ftdi_usb_open_dev(ref ftdi_context ftdi, IntPtr dev);
[DllImport("libftdi.so.0")] internal static extern int ftdi_usb_open_desc(ref ftdi_context ftdi, int vendor, int product, string description, string serial);
[DllImport("libftdi.so.0")] internal static extern int ftdi_enable_bitbang(ref ftdi_context ftdi, byte bitmask);
[DllImport("libftdi.so.0")] internal static extern int ftdi_disable_bitbang(ref ftdi_context ftdi);
[DllImport("libftdi.so.0")] internal static extern int ftdi_get_latency_timer(ref ftdi_context ftdi, out byte latency);
[DllImport("libftdi.so.0")] internal static extern int ftdi_set_line_property(ref ftdi_context ftdi, BitsType bits, StopBitsType sbit, ParityType parity);
[DllImport("libftdi.so.0")] internal static extern IntPtr ftdi_get_error_string(ref ftdi_context ftdi);
[DllImport("libftdi.so.0")] internal static extern int ftdi_write_eeprom(ref ftdi_context ftdi, ref byte[] eeprom);
[DllImport("libftdi.so.0")] internal static extern void ftdi_deinit(ref ftdi_context ftdi);