summaryrefslogtreecommitdiff
path: root/gusb/gusb-device.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix BulkTransfer out-of-order replyHEADmainFrédéric Danis2023-04-271-0/+1
| | | | | | | | | | | | | | | | | | | | | The reply to an out-of-order outgoing BulkTransfer may be also out-of-order Currently we can get: found in-order BulkTransfer:Endpoint=0x01,Data=…,Length=0x25 at position 315 found in-order BulkTransfer:Endpoint=0x82,Data=…,Length=0x25 at position 316 … found out-of-order BulkTransfer:Endpoint=0x01,Data=…,Length=0x25 at position 312 found in-order BulkTransfer:Endpoint=0x82,Data=…,Length=0x25 at position 320 while expecting: found in-order BulkTransfer:Endpoint=0x01,Data=…,Length=0x25 at position 315 found in-order BulkTransfer:Endpoint=0x82,Data=…,Length=0x25 at position 316 … found out-of-order BulkTransfer:Endpoint=0x01,Data=…,Length=0x25 at position 312 found in-order BulkTransfer:Endpoint=0x82,Data=…,Length=0x25 at position 314 … found in-order BulkTransfer:Endpoint=0x01,Data=…,Length=0x25 at position 319 found in-order BulkTransfer:Endpoint=0x82,Data=…,Length=0x25 at position 320
* Add json_object_get_*_member_with_default() helpersFrédéric Danis2023-04-261-8/+1
| | | | | json library previous to version 1.6.0 doesn't provide the json_object_get_*_member_with_default() functions.
* Store the config-index as a GUsbDeviceEventRichard Hughes2023-02-061-3/+24
| | | | This allows emulating the Google Servo Micro.
* Reset the in-order event index when clearing the event arrayRichard Hughes2023-02-031-0/+1
|
* Do not emit spurious ::device-removed events when emulatingRichard Hughes2023-02-031-0/+10
| | | | | | | | | If we load new emulation data we have to do horrible tricks in the caller to avoid handling the remove event when loading new event data. Make the caller (fwupd) much simpler by emitting the correct signals. Also add a ::device-changed signal that we can use to reload the device events.
* Save the libusb error if libusb_submit_transfer() failsRichard Hughes2023-02-011-9/+33
| | | | If the return code is LIBUSB_ERROR_NO_DEVICE we want to record that.
* trivial: Add some debugging when resetting the event indexRichard Hughes2023-02-011-1/+4
|
* Add g_usb_device_get_created() to better detect emulated replugRichard Hughes2023-02-011-0/+37
|
* Reduce the debugging level when emulating firmwareRichard Hughes2023-01-271-4/+8
|
* Add g_usb_device_clear_events() for future useRichard Hughes2023-01-251-0/+16
|
* Add g_usb_device_get_tags() for future useRichard Hughes2023-01-241-0/+18
|
* Add g_usb_device_is_emulated() for future useRichard Hughes2023-01-241-0/+17
|
* Add g_usb_device_remove_tag() for future useRichard Hughes2023-01-231-0/+26
|
* trivial: Fix up a gtk-doc commentRichard Hughes2022-10-261-1/+1
|
* Export g_usb_device_has_tag()Richard Hughes2022-10-261-2/+13
|
* trivial: Fix up clang-format issueRichard Hughes2022-09-131-1/+1
|
* Allow adding tags to the JSON device eventRichard Hughes2022-09-131-0/+65
| | | | This allows us to see which phase of the emulation should be used.
* Include the created time in the JSON eventRichard Hughes2022-09-131-0/+10
|
* Allow emulating failed eventsRichard Hughes2022-09-121-0/+34
| | | | | This is required to emulate devices that just reset (without completing the current transfer) when asked to reset.
* Do not copy event data when not-requiredRichard Hughes2022-09-101-3/+48
| | | | | This will prevent crashes if the caller is casting from a const buffer to a mutable buffer.
* Save device events when requiredRichard Hughes2022-09-081-5/+407
| | | | | | This allows us to simulate an entire context of devices, simulating responses as if the hardware is connected. This allows building rich device-specific unit tests in programs like fwupd, without having to have the hardware attached.
* trivial: Ignore more requests when emulating a deviceRichard Hughes2022-09-061-0/+20
|
* trivial: Use a unique JSON key name for the IDRichard Hughes2022-09-061-4/+5
|
* trivial: Use a boolean flag for cache controlRichard Hughes2022-09-061-2/+10
| | | | There's no point keep asking the device for BOS descriptors when it has none.
* trivial: Check the handle before getting BOS descriptorsRichard Hughes2022-09-061-0/+4
|
* trivial: Fix up some docgen headersRichard Hughes2022-09-061-24/+0
|
* Skip some functionality when emulatingRichard Hughes2022-09-051-0/+12
|
* Include the platform ID in the JSON fileRichard Hughes2022-09-051-0/+10
|
* Serialize the GUsbDevice to and from JSON formatRichard Hughes2022-09-051-10/+236
| | | | This allows us to write tests that mock up entire devices.
* Cache the list of interfaces and descriptorsRichard Hughes2022-09-051-94/+101
| | | | | This can speed up device enumeration, and also allows us to emulate the interfaces or descriptors in the future.
* trivial: Use @self for instance dataRichard Hughes2022-09-051-247/+243
|
* Use G_DECLARE_DERIVABLE_TYPE to reduce boilerplateRichard Hughes2022-09-051-96/+125
|
* Reformat the code using clang-formatRichard Hughes2022-09-041-650/+624
| | | | | This frees up mental energy when reviewing patches and is something I should have done a long time ago.
* Add support for getting BOS descriptorsRichard Hughes2022-09-041-0/+103
|
* Use g_autoptr() in a lot more placesRichard Hughes2022-09-041-14/+7
| | | | We started using this several months ago and nobody even noticed.
* trivial: Remove some duplicate header includesRichard Hughes2022-06-161-2/+0
|
* Only include the start year in the copyright headerRichard Hughes2022-06-161-1/+1
| | | | | The end year is legally and functionally redundant, and more importantly causes cherry-pick conflicts when trying to maintain old branches.
* Add g_usb_device_get_string_descriptor_bytes_fullmasterRicardo Cañuelo2021-09-301-8/+39
| | | | | | | Some devices won't answer to a request with a 128-byte data buffer, this allows the user to specify the size of the request data buffer. g_usb_device_get_string_descriptor_bytes still uses the default buffer size (128 bytes).
* Do not depend on libusb_get_port_number() to fix DragonFlyBSD compileRichard Hughes2021-05-211-1/+10
|
* Do not depend on libusb_get_parent() to fix FreeBSD compileRichard Hughes2021-05-211-0/+9
|
* device: Reference the libusb device when setMarco Trevisan (Treviño)2021-04-131-3/+13
| | | | | | | | | We used to reference a device during the initable init vfunc, however it's better to do it when the device is actually set as an object property. In this way, the device is always unreffed when the object is disposed, without having to care about the ordering.
* device: Do not double-reference USB devicesMarco Trevisan (Treviño)2021-04-131-2/+0
| | | | | | | | | | | Currently gusb-device adds two references to an internal libusb device, causing a memory leak on destruction. In fact, we add a reference when the device is constructed and when the device is inited. To avoid this and ensure that libusb will cleanup all the devices on context destruction, only reference on device initialization.
* Add g_usb_device_get_string_descriptor_bytes()Richard Hughes2021-01-271-0/+41
| | | | This is requried for the GD32VF103 device.
* device: Fix cancellation if cancellable is already cancelledBenjamin Berg2020-10-011-27/+42
| | | | | | | | | | | libusb can only handle cancellation if the transfer is already in-flight. However, g_cancellable_connect will immediately call the callback and then libusb_cancel_transfer when the cancellable is already cancelled at the time the transfer is submitted. Move the cancellation registration to after transfer submission to avoid ordering issues. Also avoid even submitting the transfer if the cancellable is already cancelled to begin with.
* trivial: Fix up typos spotted by codespellRichard Hughes2020-09-241-6/+6
|
* Add a way to get iConfigurationBenson Leung2020-07-291-0/+30
| | | | | Adds a getter for a gusb_device to get the string index for the active configuration's description.
* trivial: Add some missing 'Since: ' valuesRichard Hughes2020-02-201-0/+4
|
* Include the USB bus in the generated platform_idRichard Hughes2020-02-141-11/+6
| | | | | | | | | | | The existing logic here was unsound; the recursion only checked the string for length 0 after it had gone up the tree to the parent, and so would never match. This meant if you had identical devices with the same port hierarchy on different USB busses they had the *same* physical ID. This really upsets projects like fwupd which use the physical ID to stay the same on device replug (which worked fine), but also dedupe devices with the same physical ID, which is what broke here.
* trivial: Use spaces and tabs consistentlyRichard Hughes2020-01-211-156/+156
|
* trivial: Use SPDX-License-Identifier tagsRichard Hughes2020-01-211-14/+1
|