File tree Expand file tree Collapse file tree 13 files changed +49
-25
lines changed
Expand file tree Collapse file tree 13 files changed +49
-25
lines changed Original file line number Diff line number Diff line change 2222
2323const hid = require ( "node-hid" ) ;
2424const common = require ( "./common" ) ;
25- const hidTransport = require ( "../../lib/transport/hid " ) ;
25+ const DAPjs = require ( "../../" ) ;
2626
2727// Allow user to select a device
2828function selectDevice ( vendorID ) {
@@ -50,7 +50,7 @@ common.getFile()
5050 common . setupEmitter ( ) ;
5151 return selectDevice ( 0xD28 )
5252 . then ( device => {
53- const transport = new hidTransport . HID ( device ) ;
53+ const transport = new DAPjs . HID ( device ) ;
5454 return common . flash ( transport , program ) ;
5555 } ) ;
5656} )
Original file line number Diff line number Diff line change 2222
2323const usb = require ( "usb" ) ;
2424const common = require ( "./common" ) ;
25- const usbTransport = require ( "../../lib/transport/usb " ) ;
25+ const DAPjs = require ( "../../" ) ;
2626
2727// Read USB device descriptor
2828function getStringDescriptor ( device , index ) {
@@ -69,7 +69,7 @@ common.getFile()
6969 common . setupEmitter ( ) ;
7070 return selectDevice ( 0xD28 )
7171 . then ( device => {
72- const transport = new usbTransport . USB ( device ) ;
72+ const transport = new DAPjs . USB ( device ) ;
7373 return common . flash ( transport , program ) ;
7474 } ) ;
7575} )
Original file line number Diff line number Diff line change 2222
2323const hid = require ( "node-hid" ) ;
2424const common = require ( "./common" ) ;
25- const hidTransport = require ( "../../lib/transport/hid " ) ;
25+ const DAPjs = require ( "../../" ) ;
2626
2727// Allow user to select a device
2828function selectDevice ( vendorID ) {
@@ -56,7 +56,7 @@ function selectDevice(vendorID) {
5656
5757selectDevice ( 0xD28 )
5858. then ( device => {
59- const transport = new hidTransport . HID ( device ) ;
59+ const transport = new DAPjs . HID ( device ) ;
6060 return common . listen ( transport ) ;
6161} )
6262. catch ( error => {
Original file line number Diff line number Diff line change 2222
2323const usb = require ( "usb" ) ;
2424const common = require ( "./common" ) ;
25- const usbTransport = require ( "../../lib/transport/usb " ) ;
25+ const DAPjs = require ( "../../" ) ;
2626
2727// Read USB device descriptor
2828function getStringDescriptor ( device , index ) {
@@ -75,7 +75,7 @@ function selectDevice(vendorID) {
7575
7676selectDevice ( 0xD28 )
7777. then ( device => {
78- const transport = new usbTransport . USB ( device ) ;
78+ const transport = new DAPjs . USB ( device ) ;
7979 return common . listen ( transport ) ;
8080} )
8181. catch ( error => {
Original file line number Diff line number Diff line change 2222
2323const hid = require ( "node-hid" ) ;
2424const common = require ( "./common" ) ;
25- const hidTransport = require ( "../../lib/transport/hid " ) ;
25+ const DAPjs = require ( "../../" ) ;
2626
2727// Allow user to select a device
2828function selectDevice ( vendorID ) {
@@ -48,7 +48,7 @@ function selectDevice(vendorID) {
4848
4949selectDevice ( 0xD28 )
5050. then ( device => {
51- const transport = new hidTransport . HID ( device ) ;
51+ const transport = new DAPjs . HID ( device ) ;
5252 return common . readRegisters ( transport ) ;
5353} )
5454. then ( ( ) => {
Original file line number Diff line number Diff line change 2222
2323const usb = require ( "usb" ) ;
2424const common = require ( "./common" ) ;
25- const usbTransport = require ( "../../lib/transport/usb " ) ;
25+ const DAPjs = require ( "../../" ) ;
2626
2727// Read USB device descriptor
2828function getStringDescriptor ( device , index ) {
@@ -66,7 +66,7 @@ function selectDevice(vendorID) {
6666
6767selectDevice ( 0xD28 )
6868. then ( device => {
69- const transport = new usbTransport . USB ( device ) ;
69+ const transport = new DAPjs . USB ( device ) ;
7070 return common . readRegisters ( transport ) ;
7171} )
7272. then ( ( ) => {
Original file line number Diff line number Diff line change 3434 " webusb"
3535 ],
3636 "scripts" : {
37- "build" : " rollup -c && typedoc src" ,
37+ "build" : " rollup -c && typedoc --tsconfig ./typedoc.tsconfig.json src" ,
3838 "watch" : " rollup -c -w"
3939 },
4040 "engines" : {
Original file line number Diff line number Diff line change @@ -58,8 +58,11 @@ export class HID implements Transport {
5858 }
5959
6060 try {
61- this . device = new nodeHID ( this . path ) ;
62- resolve ( ) ;
61+ return import ( "node-hid" )
62+ . then ( hid => {
63+ this . device = new hid . HID ( this . path ) ;
64+ resolve ( ) ;
65+ } ) ;
6366 } catch ( ex ) {
6467 reject ( ex ) ;
6568 }
Original file line number Diff line number Diff line change @@ -56,4 +56,6 @@ export interface Transport {
5656 write ( data : BufferSource ) : Promise < void > ;
5757}
5858
59+ export * from "./hid" ;
60+ export * from "./usb" ;
5961export * from "./webusb" ;
Original file line number Diff line number Diff line change 2121* SOFTWARE.
2222*/
2323
24- import {
25- LIBUSB_REQUEST_TYPE_CLASS ,
26- LIBUSB_RECIPIENT_INTERFACE ,
27- LIBUSB_ENDPOINT_IN ,
28- LIBUSB_ENDPOINT_OUT ,
29- Device ,
30- InEndpoint ,
31- OutEndpoint
32- } from "usb" ;
24+ import { Device , InEndpoint , OutEndpoint } from "usb" ;
3325import { Transport } from "./" ;
3426
27+ /**
28+ * @hidden
29+ */
30+ const LIBUSB_REQUEST_TYPE_CLASS = ( 0x01 << 5 ) ;
31+ /**
32+ * @hidden
33+ */
34+ const LIBUSB_RECIPIENT_INTERFACE = 0x01 ;
35+ /**
36+ * @hidden
37+ */
38+ const LIBUSB_ENDPOINT_OUT = 0x00 ;
39+ /**
40+ * @hidden
41+ */
42+ const LIBUSB_ENDPOINT_IN = 0x80 ;
3543/**
3644 * @hidden
3745 */
You can’t perform that action at this time.
0 commit comments