How to “talk” with USB device via my module?
I've written my module for gamepad that plugged by USB. I've already check that my installed module detects my device successfully and even calls "probe" method:
static struct usb_driver driver =
{
.name = "Driver#1",
.id_table = table,
.probe = probe,
.disconnect = disconnect,
};
I have also written special urb function, that should "talk" with my device
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
But I cannot understand how to initialize action of irq_in
. I presume that I need to press something and some information should be written in j->idata
. I also did
usb_submit_urb(j->irq_in, GFP_KERNEL);
But nothing happens! Why?
My probe function:
static void irq_hh(struct urb *urb)
{
struct devicec *j = urb->context;/*В какую структура из всех процессов дб заполнена после приёма данных???*/
char *data = j->idata;
printk(KERN_INFO "irq_hh: %s", data);
}
static int probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev; //!
struct usb_endpoint_descriptor *ep_irq_in;
int ep_irq_in_idx, error;
printk(KERN_INFO "probe...%X",id->idVendor);
j = kzalloc(sizeof(struct devicec), GFP_KERNEL);
udev = interface_to_usbdev(intf);
j->irq_in = usb_alloc_urb(0, GFP_KERNEL);
//--------------------------------------
j->udev = udev;
j->intf = intf;
//--------------------------------------
usb_make_path(udev, j->phys, sizeof(j->phys));
strlcat(j->phys, "/input101", sizeof(j->phys));
printk(KERN_INFO "%s",j->phys);
ep_irq_in_idx = 0;
ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc;
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
j->irq_in->transfer_dma = j->idata_dma;
j->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
error = usb_submit_urb(j->irq_in, GFP_KERNEL);
printk(KERN_INFO "%d",error);
return 0;
}
drivers usb module
add a comment |
I've written my module for gamepad that plugged by USB. I've already check that my installed module detects my device successfully and even calls "probe" method:
static struct usb_driver driver =
{
.name = "Driver#1",
.id_table = table,
.probe = probe,
.disconnect = disconnect,
};
I have also written special urb function, that should "talk" with my device
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
But I cannot understand how to initialize action of irq_in
. I presume that I need to press something and some information should be written in j->idata
. I also did
usb_submit_urb(j->irq_in, GFP_KERNEL);
But nothing happens! Why?
My probe function:
static void irq_hh(struct urb *urb)
{
struct devicec *j = urb->context;/*В какую структура из всех процессов дб заполнена после приёма данных???*/
char *data = j->idata;
printk(KERN_INFO "irq_hh: %s", data);
}
static int probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev; //!
struct usb_endpoint_descriptor *ep_irq_in;
int ep_irq_in_idx, error;
printk(KERN_INFO "probe...%X",id->idVendor);
j = kzalloc(sizeof(struct devicec), GFP_KERNEL);
udev = interface_to_usbdev(intf);
j->irq_in = usb_alloc_urb(0, GFP_KERNEL);
//--------------------------------------
j->udev = udev;
j->intf = intf;
//--------------------------------------
usb_make_path(udev, j->phys, sizeof(j->phys));
strlcat(j->phys, "/input101", sizeof(j->phys));
printk(KERN_INFO "%s",j->phys);
ep_irq_in_idx = 0;
ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc;
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
j->irq_in->transfer_dma = j->idata_dma;
j->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
error = usb_submit_urb(j->irq_in, GFP_KERNEL);
printk(KERN_INFO "%d",error);
return 0;
}
drivers usb module
add a comment |
I've written my module for gamepad that plugged by USB. I've already check that my installed module detects my device successfully and even calls "probe" method:
static struct usb_driver driver =
{
.name = "Driver#1",
.id_table = table,
.probe = probe,
.disconnect = disconnect,
};
I have also written special urb function, that should "talk" with my device
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
But I cannot understand how to initialize action of irq_in
. I presume that I need to press something and some information should be written in j->idata
. I also did
usb_submit_urb(j->irq_in, GFP_KERNEL);
But nothing happens! Why?
My probe function:
static void irq_hh(struct urb *urb)
{
struct devicec *j = urb->context;/*В какую структура из всех процессов дб заполнена после приёма данных???*/
char *data = j->idata;
printk(KERN_INFO "irq_hh: %s", data);
}
static int probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev; //!
struct usb_endpoint_descriptor *ep_irq_in;
int ep_irq_in_idx, error;
printk(KERN_INFO "probe...%X",id->idVendor);
j = kzalloc(sizeof(struct devicec), GFP_KERNEL);
udev = interface_to_usbdev(intf);
j->irq_in = usb_alloc_urb(0, GFP_KERNEL);
//--------------------------------------
j->udev = udev;
j->intf = intf;
//--------------------------------------
usb_make_path(udev, j->phys, sizeof(j->phys));
strlcat(j->phys, "/input101", sizeof(j->phys));
printk(KERN_INFO "%s",j->phys);
ep_irq_in_idx = 0;
ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc;
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
j->irq_in->transfer_dma = j->idata_dma;
j->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
error = usb_submit_urb(j->irq_in, GFP_KERNEL);
printk(KERN_INFO "%d",error);
return 0;
}
drivers usb module
I've written my module for gamepad that plugged by USB. I've already check that my installed module detects my device successfully and even calls "probe" method:
static struct usb_driver driver =
{
.name = "Driver#1",
.id_table = table,
.probe = probe,
.disconnect = disconnect,
};
I have also written special urb function, that should "talk" with my device
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
But I cannot understand how to initialize action of irq_in
. I presume that I need to press something and some information should be written in j->idata
. I also did
usb_submit_urb(j->irq_in, GFP_KERNEL);
But nothing happens! Why?
My probe function:
static void irq_hh(struct urb *urb)
{
struct devicec *j = urb->context;/*В какую структура из всех процессов дб заполнена после приёма данных???*/
char *data = j->idata;
printk(KERN_INFO "irq_hh: %s", data);
}
static int probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev; //!
struct usb_endpoint_descriptor *ep_irq_in;
int ep_irq_in_idx, error;
printk(KERN_INFO "probe...%X",id->idVendor);
j = kzalloc(sizeof(struct devicec), GFP_KERNEL);
udev = interface_to_usbdev(intf);
j->irq_in = usb_alloc_urb(0, GFP_KERNEL);
//--------------------------------------
j->udev = udev;
j->intf = intf;
//--------------------------------------
usb_make_path(udev, j->phys, sizeof(j->phys));
strlcat(j->phys, "/input101", sizeof(j->phys));
printk(KERN_INFO "%s",j->phys);
ep_irq_in_idx = 0;
ep_irq_in = &intf->cur_altsetting->endpoint[ep_irq_in_idx].desc;
usb_fill_int_urb(j->irq_in, udev,
usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), //!
j->idata, 32, irq_hh,
j, ep_irq_in->bInterval);
j->irq_in->transfer_dma = j->idata_dma;
j->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
error = usb_submit_urb(j->irq_in, GFP_KERNEL);
printk(KERN_INFO "%d",error);
return 0;
}
drivers usb module
drivers usb module
asked 15 mins ago
Ayrat ArifullinAyrat Arifullin
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508240%2fhow-to-talk-with-usb-device-via-my-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508240%2fhow-to-talk-with-usb-device-via-my-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown