{"action":"created","issue":{"url":"https://api.github.com/repos/daynix/UsbDk/issues/48","repository_url":"https://api.github.com/repos/daynix/UsbDk","labels_url":"https://api.github.com/repos/daynix/UsbDk/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/daynix/UsbDk/issues/48/comments","events_url":"https://api.github.com/repos/daynix/UsbDk/issues/48/events","html_url":"https://github.com/daynix/UsbDk/issues/48","id":252525333,"number":48,"title":"ReadPipe example","user":{"login":"nikola-matic","id":4415530,"avatar_url":"https://avatars1.githubusercontent.com/u/4415530?v=4","gravatar_id":"","url":"https://api.github.com/users/nikola-matic","html_url":"https://github.com/nikola-matic","followers_url":"https://api.github.com/users/nikola-matic/followers","following_url":"https://api.github.com/users/nikola-matic/following{/other_user}","gists_url":"https://api.github.com/users/nikola-matic/gists{/gist_id}","starred_url":"https://api.github.com/users/nikola-matic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikola-matic/subscriptions","organizations_url":"https://api.github.com/users/nikola-matic/orgs","repos_url":"https://api.github.com/users/nikola-matic/repos","events_url":"https://api.github.com/users/nikola-matic/events{/privacy}","received_events_url":"https://api.github.com/users/nikola-matic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"sameehj","id":9149751,"avatar_url":"https://avatars2.githubusercontent.com/u/9149751?v=4","gravatar_id":"","url":"https://api.github.com/users/sameehj","html_url":"https://github.com/sameehj","followers_url":"https://api.github.com/users/sameehj/followers","following_url":"https://api.github.com/users/sameehj/following{/other_user}","gists_url":"https://api.github.com/users/sameehj/gists{/gist_id}","starred_url":"https://api.github.com/users/sameehj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameehj/subscriptions","organizations_url":"https://api.github.com/users/sameehj/orgs","repos_url":"https://api.github.com/users/sameehj/repos","events_url":"https://api.github.com/users/sameehj/events{/privacy}","received_events_url":"https://api.github.com/users/sameehj/received_events","type":"User","site_admin":false},"assignees":[{"login":"sameehj","id":9149751,"avatar_url":"https://avatars2.githubusercontent.com/u/9149751?v=4","gravatar_id":"","url":"https://api.github.com/users/sameehj","html_url":"https://github.com/sameehj","followers_url":"https://api.github.com/users/sameehj/followers","following_url":"https://api.github.com/users/sameehj/following{/other_user}","gists_url":"https://api.github.com/users/sameehj/gists{/gist_id}","starred_url":"https://api.github.com/users/sameehj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameehj/subscriptions","organizations_url":"https://api.github.com/users/sameehj/orgs","repos_url":"https://api.github.com/users/sameehj/repos","events_url":"https://api.github.com/users/sameehj/events{/privacy}","received_events_url":"https://api.github.com/users/sameehj/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2017-08-24T08:29:47Z","updated_at":"2017-08-28T07:34:30Z","closed_at":null,"body":"I'm trying to read data from a 3D mouse after acquiring (redirecting) the device. The device redirection is successful and disables the device, until I release it back. However, when attempting to read data, I get INVALID_HANDLE (0x6) error from GetLastError(). I've been looking through the libusb source code for example reads - however, I'm not sure I'm configuring the packets correctly. It would seem there are no read/write examples in UsbDk (controller).\r\n\r\nThis is my device endpoint descriptor:\r\n`bEndpointAddress:     0x81  IN`\r\n`Transfer Type:   Interrupt`\r\n`wMaxPacketSize:     0x0008 (8)`\r\n`bInterval:            0x0A`\r\n\r\nAnd this is my code:\r\n```c++\r\nvoid Device::ReadPipe()\r\n{\r\n\tPUSB_DK_TRANSFER_REQUEST transferRequest = (PUSB_DK_TRANSFER_REQUEST)malloc(sizeof(tag_USB_DK_TRANSFER_REQUEST));\r\n\tLPOVERLAPPED overlapped = (LPOVERLAPPED)malloc(sizeof(_OVERLAPPED));\r\n\tDWORD error;\r\n\r\n\ttransferRequest->TransferType = InterruptTransferType;\r\n\ttransferRequest->EndpointAddress = 0x81;\r\n\ttransferRequest->Buffer = (PVOID64)malloc(8);\r\n\ttransferRequest->BufferLength = 0x08;\r\n\ttransferRequest->IsochronousPacketsArraySize = NULL;\r\n\ttransferRequest->IsochronousPacketsArraySize = 0;\r\n\r\n\tTransferResult result = Device::api.ReadPipe()(deviceHandle_, transferRequest, overlapped);\r\n\r\n\tswitch (result)\r\n\t{\r\n\tcase TransferSuccess:\r\n\t\tstd::cout << \"success\" << std::endl;\r\n\t\tbreak;\r\n\tcase TransferSuccessAsync:\r\n\t\tstd::cout << \"success async\" << std::endl;\r\n\t\tbreak;\r\n\tcase TransferFailure:\r\n\t\terror = GetLastError();\r\n\t\tstd::cout << \"failure with error code: \" << error << std::endl;\r\n\t\tbreak;\r\n\tdefault:\r\n\t\tstd::cout << \"no result\" << std::endl;\r\n\t}\r\n\r\n\tfree(transferRequest->Buffer);\r\n\tfree(transferRequest);\r\n\tfree(overlapped);\r\n}\r\n```\r\nI have to mention that I'm very new to such low level device interaction, so it may be that I'm doing something stupid, but I've been attempting to read from the device for a couple of days now without success. I'd be happy to do a pull request and write some examples - perhaps by extending the UsbDkController class. Thanks.\r\n\r\nEdit: Note that I haven't sent a control transfer, which I'm guessing I should have?\r\n"},"comment":{"url":"https://api.github.com/repos/daynix/UsbDk/issues/comments/325281983","html_url":"https://github.com/daynix/UsbDk/issues/48#issuecomment-325281983","issue_url":"https://api.github.com/repos/daynix/UsbDk/issues/48","id":325281983,"user":{"login":"sameehj","id":9149751,"avatar_url":"https://avatars2.githubusercontent.com/u/9149751?v=4","gravatar_id":"","url":"https://api.github.com/users/sameehj","html_url":"https://github.com/sameehj","followers_url":"https://api.github.com/users/sameehj/followers","following_url":"https://api.github.com/users/sameehj/following{/other_user}","gists_url":"https://api.github.com/users/sameehj/gists{/gist_id}","starred_url":"https://api.github.com/users/sameehj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameehj/subscriptions","organizations_url":"https://api.github.com/users/sameehj/orgs","repos_url":"https://api.github.com/users/sameehj/repos","events_url":"https://api.github.com/users/sameehj/events{/privacy}","received_events_url":"https://api.github.com/users/sameehj/received_events","type":"User","site_admin":false},"created_at":"2017-08-28T07:34:30Z","updated_at":"2017-08-28T07:34:30Z","body":"@nikola-matic,\r\n\r\nThe log that you provided seems like a successful run, what I suspect is that you have a bug lying somewhere in your code where you mess the device handle somehow. In order to debug this I suggest that you print the value of the device handle just after you receive it from StartRedirect function and print it's value once again just before providing it to the ReadPipe function.\r\n\r\nIn case this doesn't help you solve the issue, please post the whole code somewhere (maybe github) and I'll take a look."}}
{"actor":{"display_login":"sameehj"}}