-
Notifications
You must be signed in to change notification settings - Fork 8
usb: Notify apps about usb device insertion #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3e5b73d
libusb: fix insertion result not being passed to msg sender
adamgreloch 7d50f9a
usb: pass device insertion result from driver to usbhost
adamgreloch eff962b
libusb: move external headers to `include` dir
adamgreloch fe704e7
unify libusb/usb log prints
adamgreloch 9eef8de
usb/usb: replace USB_INTERNAL_ONLY ifdefs to always create /dev/usb
adamgreloch 0a0bc8e
libusb: fix driver name passing if using procdriver
adamgreloch 4884fdb
usb: preserve utf16 value of string descriptors
adamgreloch c1eba41
dev: print vid:pid on device insertion
adamgreloch e1b6dab
usb/drv: fix drivers not being bound to all possible dev interfaces
adamgreloch 31b12c7
usb: add device info retrieval API based on driver's device file oid
adamgreloch d8e07db
usb/drv: reset msg before each msgSend
adamgreloch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| # | ||
| # Makefile for Phoenix-RTOS libusb | ||
| # | ||
| # Copyright 2021 Phoenix Systems | ||
| # Copyright 2025 Phoenix Systems | ||
| # | ||
|
|
||
| NAME := libusb | ||
| LOCAL_PATH := $(call my-dir) | ||
| HEADERS := $(wildcard $(LOCAL_PATH)*.h) | ||
| LOCAL_SRCS := cdc_client.c hid_client.c driver.c procdriver.c | ||
| LOCAL_SRCS := cdc_client.c hid_client.c driver.c procdriver.c internal.c devinfo.c | ||
| LOCAL_CFLAGS := -I$(LOCAL_PATH) | ||
|
|
||
| include $(static-lib.mk) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Phoenix-RTOS | ||
| * | ||
| * Libusb driver interface | ||
| * | ||
| * USB low-level information API for userspace applications | ||
| * | ||
| * Copyright 2025 Phoenix Systems | ||
| * Author: Adam Greloch | ||
| * | ||
| * %LICENSE% | ||
| */ | ||
|
|
||
| #include <usbdriver.h> | ||
|
|
||
| #include <usbdevinfo.h> | ||
|
|
||
| #include "usbinternal.h" | ||
| #include "log.h" | ||
|
|
||
|
|
||
| int usb_devinfoGet(oid_t oid, usb_devinfo_desc_t *desc) | ||
| { | ||
| int err; | ||
| oid_t hostOid; | ||
| msg_t msg = { 0 }; | ||
| usb_msg_t *imsg = (usb_msg_t *)msg.i.raw; | ||
|
|
||
| usb_hostLookup(&hostOid); | ||
|
|
||
| msg.type = mtDevCtl; | ||
| imsg->type = usb_msg_devdesc; | ||
| imsg->devdesc.oid = oid; | ||
| msg.o.data = desc; | ||
| msg.o.size = sizeof(usb_devinfo_desc_t); | ||
|
|
||
| err = msgSend(hostOid.port, &msg); | ||
| if (err < 0) { | ||
| log_error("msgSend failed: %d\n", err); | ||
| return err; | ||
| } | ||
|
|
||
| if (msg.o.err < 0) { | ||
| log_error("msg.o.err=%d\n", msg.o.err); | ||
| return msg.o.err; | ||
| } | ||
|
|
||
| return 0; | ||
| } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Phoenix-RTOS | ||
| * | ||
| * Libusb driver interface | ||
| * | ||
| * USB low-level information API for userspace applications | ||
| * | ||
| * Copyright 2025 Phoenix Systems | ||
| * Author: Adam Greloch | ||
| * | ||
| * %LICENSE% | ||
| */ | ||
|
|
||
|
|
||
| #ifndef _USB_DEVINFO_H_ | ||
| #define _USB_DEVINFO_H_ | ||
|
|
||
| #include <usb.h> | ||
| #include <usbdriver.h> | ||
|
|
||
|
|
||
| int usb_devinfoGet(oid_t oid, usb_devinfo_desc_t *desc); | ||
|
|
||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Phoenix-RTOS | ||
| * | ||
| * libusb/internal.c | ||
| * | ||
| * Copyright 2025 Phoenix Systems | ||
| * Author: Adam Greloch | ||
| * | ||
| * %LICENSE% | ||
| */ | ||
|
|
||
|
|
||
| #include <usbinternal.h> | ||
| #include <unistd.h> | ||
|
|
||
|
|
||
| void usb_hostLookup(oid_t *oid) | ||
| { | ||
| for (;;) { | ||
| if (lookup("devfs/usb", NULL, oid) >= 0) { | ||
| break; | ||
| } | ||
|
|
||
| if (lookup("/dev/usb", NULL, oid) >= 0) { | ||
| break; | ||
| } | ||
|
|
||
| usleep(1000000); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
| /* | ||
| * Phoenix-RTOS | ||
| * | ||
| * Libusb driver interface | ||
| * | ||
| * libusb/log.h | ||
| * | ||
| * Copyright 2025 Phoenix Systems | ||
| * Author: Adam Greloch | ||
| * | ||
| * %LICENSE% | ||
| */ | ||
|
|
||
|
|
||
| #ifndef _LIBUSB_LOG_H_ | ||
| #define _LIBUSB_LOG_H_ | ||
|
|
||
|
|
||
| #define LIBUSB_LOG_TAG "libusb" | ||
| #define LIBUSB_TRACE 0 | ||
|
|
||
| /* clang-format off */ | ||
| #define log_msg(fmt, ...) do { fprintf(stderr, LIBUSB_LOG_TAG ": " fmt, ##__VA_ARGS__); } while (0) | ||
| #define log_trace(fmt, ...) do { if (LIBUSB_TRACE != 0) log_msg("%s: " fmt, __func__ __VA_OPT__(, ) ##__VA_ARGS__); } while (0) | ||
| #define log_error(fmt, ...) log_msg(fmt, ##__VA_ARGS__) | ||
| /* clang-format on */ | ||
|
|
||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.