MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / get_usb_impl

Function get_usb_impl

lib/usb/usb.cc:69–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69USB* get_usb_impl()
70{
71 /* Special case for certain configurations. */
72
73 if (globalConfig()->usb().has_greaseweazle() &&
74 globalConfig()->usb().greaseweazle().has_port())
75 {
76 const auto& conf = globalConfig()->usb().greaseweazle();
77 log("Using Greaseweazle on serial port {}", conf.port());
78 return createGreaseweazleUsb(conf.port(), conf);
79 }
80
81 if (globalConfig()->usb().has_applesauce() &&
82 globalConfig()->usb().applesauce().has_port())
83 {
84 const auto& conf = globalConfig()->usb().applesauce();
85 log("Using Applesauce on serial port {}", conf.port());
86 return createApplesauceUsb(conf.port(), conf);
87 }
88
89 /* Otherwise, select a device by USB ID. */
90
91 auto candidate = selectDevice();
92 switch (candidate->id)
93 {
94 case FLUXENGINE_ID:
95 log("Using FluxEngine {}", candidate->serial);
96 return createFluxengineUsb(candidate->device);
97
98 case GREASEWEAZLE_ID:
99 log("Using Greaseweazle {} on {}",
100 candidate->serial,
101 candidate->serialPort);
102 return createGreaseweazleUsb(
103 candidate->serialPort, globalConfig()->usb().greaseweazle());
104
105 case APPLESAUCE_ID:
106 log("Using Applesauce {} on {}",
107 candidate->serial,
108 candidate->serialPort);
109 return createApplesauceUsb(
110 candidate->serialPort, globalConfig()->usb().applesauce());
111
112 default:
113 error("internal");
114 }
115}
116
117USB& getUsb()
118{

Callers 1

usb.ccFile · 0.85

Calls 6

createGreaseweazleUsbFunction · 0.85
createApplesauceUsbFunction · 0.85
selectDeviceFunction · 0.85
createFluxengineUsbFunction · 0.85
errorFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected