{"action":"opened","issue":{"url":"https://api.github.com/repos/nonolith/node-usb/issues/111","repository_url":"https://api.github.com/repos/nonolith/node-usb","labels_url":"https://api.github.com/repos/nonolith/node-usb/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/nonolith/node-usb/issues/111/comments","events_url":"https://api.github.com/repos/nonolith/node-usb/issues/111/events","html_url":"https://github.com/nonolith/node-usb/issues/111","id":131490595,"number":111,"title":"Does node-usb support bi-directional endpoints?","user":{"login":"adjavaherian","id":3650448,"avatar_url":"https://avatars.githubusercontent.com/u/3650448?v=3","gravatar_id":"","url":"https://api.github.com/users/adjavaherian","html_url":"https://github.com/adjavaherian","followers_url":"https://api.github.com/users/adjavaherian/followers","following_url":"https://api.github.com/users/adjavaherian/following{/other_user}","gists_url":"https://api.github.com/users/adjavaherian/gists{/gist_id}","starred_url":"https://api.github.com/users/adjavaherian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adjavaherian/subscriptions","organizations_url":"https://api.github.com/users/adjavaherian/orgs","repos_url":"https://api.github.com/users/adjavaherian/repos","events_url":"https://api.github.com/users/adjavaherian/events{/privacy}","received_events_url":"https://api.github.com/users/adjavaherian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-04T22:21:08Z","updated_at":"2016-02-04T22:21:08Z","closed_at":null,"body":"I'm trying to write a bulk transfer for the [crazy radio dongle](https://wiki.bitcraze.io/doc:crazyradio:usb:index) and they say that their endpoint 1 supports in and out, which seems to be valid in chrome.usb's bulkTransfer mechanism.  Does node-usb take this directional argument?  Perhaps in the data packet?  I know you say that isosynchronous is not supported, but this is different, right?  It looks like chrome.usb supports endpoint direction in its bulkTransfer and isosync is totally different.\r\n\r\nIn the following tests, you should be able to see that the endpoint is labeled with out, but the first test succeeds in reading.  The second test fails because the endpoint \"in\" needs to be read so the buffer can be cleared, however, I'm not sure how to do that in this scenario.  Any ideas, or is this even supported?\r\n\r\nThanks!\r\n\r\n```javascript\r\ndescribe.only('Packet tests', function() {\r\n\r\n        var iface = null;\r\n\r\n        beforeEach(function() {\r\n            radio = new Crazyradio();\r\n            radio.debugLevel(4);\r\n            device = radio.find();\r\n        });\r\n\r\n        afterEach(function(done){\r\n            iface.release(true, function(err){\r\n                console.log('releasing', err);\r\n                radio.close(device, function(err, data){\r\n                    console.log('after', err);\r\n                    done();\r\n                });\r\n            });\r\n        });\r\n\r\n        it('should read a packet', function(done){\r\n            radio.open(device, function(){\r\n\r\n                iface = device.interface(0);\r\n                iface.claim();\r\n\r\n                var radioIn = iface.endpoints[1];\r\n\r\n                console.log('radioIn', radioIn.direction, radioIn.transferType, radioIn.descriptor);\r\n\r\n                radioIn.transfer(64, function(err, data){\r\n                    console.log('in err / data', err, data);\r\n                    done();\r\n                });\r\n            });\r\n        });\r\n\r\n        it('should send a packet', function(){\r\n\r\n            radio.open(device, function(){\r\n\r\n                iface = device.interface(0);\r\n                iface.claim();\r\n\r\n                var radioOut = iface.endpoints[1];\r\n\r\n                console.log('radioOut', radioOut.direction, radioOut.transferType, radioOut.descriptor);\r\n\r\n                //Preparing commander packet\r\n                var packet = new ArrayBuffer(15);\r\n                var dv = new DataView(packet);\r\n\r\n                dv.setUint8(0, 0x30, true);      // CRTP header\r\n                dv.setFloat32(1, 0.0, true);    // Roll\r\n                dv.setFloat32(5, 0.0, true);   // Pitch\r\n                dv.setFloat32(9, 0.0, true);     // Yaw\r\n                dv.setUint16(13, 0.0, true);  // Thrust\r\n\r\n                radioOut.transfer(packet, function(error){\r\n                    console.log('out transfer callback', error);\r\n                    done();\r\n                });\r\n            });\r\n        });\r\n    });\r\n```\r\n\r\nand here's the debug logs\r\n\r\n```\r\n\r\n> crazyradio-node-driver@0.0.1 test /Users/4m1r/Desktop/Crazyflie/crazyradio-node-driver\r\n> mocha test.js\r\n\r\n\r\n\r\n  CrazyRadio tests\r\n    Packet tests\r\n[timestamp] [threadID] facility level [function call] <message>\r\n--------------------------------------------------------------------------------\r\n[ 0.092762] [00000513] libusb: debug [libusb_get_device_list] \r\n[ 0.092881] [00000513] libusb: debug [libusb_get_device_descriptor] \r\n[ 0.092952] [00000513] libusb: debug [libusb_get_device_descriptor] \r\n[ 0.092993] [00000513] libusb: debug [libusb_get_device_descriptor] \r\n[ 0.094703] [00000513] libusb: debug [libusb_open] open 20.7\r\n[ 0.094889] [00000513] libusb: debug [usbi_add_pollfd] add fd 22 events 1\r\n[ 0.094903] [00000513] libusb: debug [darwin_open] device open for access\r\n[ 0.094952] [00003f03] libusb: debug [handle_events] poll() returned 1\r\n[ 0.094990] [00003f03] libusb: debug [handle_events] caught a fish on the control pipe\r\n[ 0.095009] [00003f03] libusb: debug [libusb_get_next_timeout] no URBs, no timeout!\r\n[ 0.095015] [00003f03] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling\r\n[ 0.095020] [00003f03] libusb: debug [handle_events] poll fds modified, reallocating\r\n[ 0.095026] [00003f03] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms\r\nopening\r\n[ 0.095904] [00000513] libusb: debug [libusb_claim_interface] interface 0\r\n[ 0.096790] [00000513] libusb: debug [get_endpoints] building table of endpoints.\r\n[ 0.096814] [00000513] libusb: debug [get_endpoints] interface: 0 pipe 1: dir: 1 number: 1\r\n[ 0.096821] [00000513] libusb: debug [get_endpoints] interface: 0 pipe 2: dir: 0 number: 1\r\n[ 0.096864] [00000513] libusb: debug [darwin_claim_interface] interface opened\r\nradioIn out 2 { bLength: 7,\r\n  bDescriptorType: 5,\r\n  bEndpointAddress: 1,\r\n  bmAttributes: 2,\r\n  wMaxPacketSize: 64,\r\n  bInterval: 6,\r\n  bRefresh: 0,\r\n  bSynchAddress: 0,\r\n  extra: <Buffer > }\r\n[ 0.099095] [00000513] libusb: debug [ep_to_pipeRef] converting ep address 0x01 to pipeRef and interface\r\n[ 0.099108] [00000513] libusb: debug [ep_to_pipeRef] pipe 2 on interface 0 matches\r\n[ 0.099325] [0000230f] libusb: debug [darwin_async_io_callback] an async io operation has completed\r\n[ 0.099359] [00003f03] libusb: debug [handle_events] poll() returned 1\r\n[ 0.099366] [00003f03] libusb: debug [op_handle_events] checking fd 22 with revents = 1\r\n[ 0.099370] [00003f03] libusb: debug [darwin_handle_callback] handling bulk completion with kernel status 0\r\n[ 0.099375] [00003f03] libusb: debug [usbi_handle_transfer_completion] transfer 0x10120d808 has callback 0x102b8b935\r\n[ 0.099389] [00003f03] libusb: debug [libusb_get_next_timeout] no URBs, no timeout!\r\n[ 0.099393] [00003f03] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling\r\n[ 0.099397] [00003f03] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms\r\nin err / data undefined undefined\r\n      ✓ should read a packet \r\n[ 0.101937] [00004603] libusb: debug [libusb_release_interface] interface 0\r\nreleasing undefined\r\n[ 0.102882] [00000513] libusb: debug [libusb_close] \r\n[ 0.102910] [00003f03] libusb: debug [handle_events] poll() returned 1\r\n[ 0.102921] [00003f03] libusb: debug [handle_events] caught a fish on the control pipe\r\n[ 0.102931] [00003f03] libusb: debug [libusb_get_next_timeout] no URBs, no timeout!\r\n[ 0.102937] [00003f03] libusb: debug [libusb_try_lock_events] someone else is modifying poll fds\r\n[ 0.102942] [00003f03] libusb: debug [libusb_event_handler_active] someone else is modifying poll fds\r\n[ 0.102947] [00003f03] libusb: debug [libusb_handle_events_timeout_completed] another thread is doing event handling\r\n[ 0.102998] [00000513] libusb: debug [usbi_remove_pollfd] remove fd 22\r\n[ 0.103053] [00003f03] libusb: debug [libusb_get_next_timeout] no URBs, no timeout!\r\n[ 0.103065] [00003f03] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling\r\n[ 0.103070] [00003f03] libusb: debug [handle_events] poll fds modified, reallocating\r\n[ 0.103076] [00003f03] libusb: debug [handle_events] poll() 2 fds with timeout in 60000ms\r\nafter false\r\n[ 0.103715] [00000513] libusb: debug [libusb_get_device_list] \r\n[ 0.104119] [00000513] libusb: debug [libusb_open] open 20.7\r\n[ 0.104220] [00000513] libusb: debug [usbi_add_pollfd] add fd 22 events 1\r\n[ 0.104232] [00000513] libusb: debug [darwin_open] device open for access\r\n[ 0.104257] [00003f03] libusb: debug [handle_events] poll() returned 1\r\n[ 0.104272] [00003f03] libusb: debug [handle_events] caught a fish on the control pipe\r\n[ 0.104283] [00003f03] libusb: debug [libusb_get_next_timeout] no URBs, no timeout!\r\n[ 0.104289] [00003f03] libusb: debug [libusb_try_lock_events] someone else is modifying poll fds\r\n[ 0.104294] [00003f03] libusb: debug [libusb_handle_events_timeout_completed] event handler was active but went away, retrying\r\n[ 0.104299] [00003f03] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling\r\n[ 0.104304] [00003f03] libusb: debug [handle_events] poll fds modified, reallocating\r\n[ 0.104311] [00003f03] libusb: debug [handle_events] poll() 3 fds with timeout in 60000ms\r\nopening\r\n[ 0.104699] [00000513] libusb: debug [libusb_claim_interface] interface 0\r\n[ 0.105099] [00000513] libusb: debug [get_endpoints] building table of endpoints.\r\n[ 0.105114] [00000513] libusb: debug [get_endpoints] interface: 0 pipe 1: dir: 1 number: 1\r\n[ 0.105124] [00000513] libusb: debug [get_endpoints] interface: 0 pipe 2: dir: 0 number: 1\r\n[ 0.105168] [00000513] libusb: debug [darwin_claim_interface] interface opened\r\nradioOut out 2 { bLength: 7,\r\n  bDescriptorType: 5,\r\n  bEndpointAddress: 1,\r\n  bmAttributes: 2,\r\n  wMaxPacketSize: 64,\r\n  bInterval: 6,\r\n  bRefresh: 0,\r\n  bSynchAddress: 0,\r\n  extra: <Buffer > }\r\n[ 0.106232] [00000513] libusb: debug [ep_to_pipeRef] converting ep address 0x01 to pipeRef and interface\r\n[ 0.106248] [00000513] libusb: debug [ep_to_pipeRef] pipe 2 on interface 0 matches\r\n      ✓ should send a packet \r\n[ 0.107096] [00004503] libusb: debug [libusb_release_interface] interface 0\r\nreleasing undefined\r\n      1) \"after each\" hook\r\n\r\n  2 passing (22ms)\r\n  1 failing\r\n\r\n  1) CrazyRadio tests Packet tests \"after each\" hook:\r\n     Uncaught Error: Can't close device with a pending request\r\n      at Error (native)\r\n      at Device.usb.Device.close (/Users/4m1r/Desktop/Crazyflie/crazyradio-node-driver/node_modules/usb/usb.js:43:7)\r\n      at Crazyradio.close (/Users/4m1r/Desktop/Crazyflie/crazyradio-node-driver/index.js:61:12)\r\n      at Interface.<anonymous> (/Users/4m1r/Desktop/Crazyflie/crazyradio-node-driver/test.js:463:23)\r\n      at Device.<anonymous> (/Users/4m1r/Desktop/Crazyflie/crazyradio-node-driver/node_modules/usb/usb.js:200:7)\r\n\r\n\r\n\r\nnpm ERR! Test failed.  See above for more details.\r\n[4m1r@Korgi:14:12:28 ~/Desktop/Crazyflie/crazyradio-node-driver]\r\n$ \r\n\r\n```\r\n\r\nHere's the driver and the rest of the tests, which work fine for configuration\r\nhttps://github.com/adjavaherian/crazyradio-node-driver"}}