Arti3DPlayer / USBDeviceSwift

wrapper for IOKit.usb and IOKit.hid written on pure Swift that allows you convenient work with USB devices
MIT License
296 stars 57 forks source link

CleanFlight Serial Demo always selects the 1st device in the combo box. #23

Open CartBlanche opened 2 years ago

CartBlanche commented 2 years ago

I believe there is a slight bug on lines 20-21 in the ViewController here... https://github.com/Arti3DPlayer/USBDeviceSwift/blob/master/CleanFlightSerialExample/CleanFlightSerialExample/ViewController.swift#L20-L21

Instead I think it should be

if (self.devices.count > 0 && self.devicesComboBox.indexOfSelectedItem > -1) {
                let device = self.devices[self.devicesComboBox.indexOfSelectedItem]

I'm new to Swift (and IOKit), so there may be a better way to do this.

CartBlanche commented 2 years ago

@Arti3DPlayer In one of your SO posts about IOKit you mentioned using C#. I'm mainly a C# developer and due to another project requiring Serial Modem Detection, I created this project https://github.com/CartBlanche/IOKit-Sharp . Some of the ideas in that lib are based on (but not exactly like) your Swift lib, but made more C# friendly, obviously. I have Serial detection (adding and removing devices) working. The rest I'll probably leave to the community or will flesh it out myself, when needed. If you have any suggestions, let me know :)

Arti3DPlayer commented 2 years ago

@CartBlanche that's great !