MCPcopy Create free account
hub / github.com/XCSoar/XCSoar / synchronousOpen

Method synchronousOpen

android/src/IOIOAgent.java:116–170  ·  view source on GitHub ↗

Called by the connection thread to open a connection.

()

Source from the content-addressed store, hash-verified

114 * Called by the connection thread to open a connection.
115 */
116 private IOIO synchronousOpen() {
117 Log.d(TAG, "open " + getName());
118
119 IOIO ioio;
120
121 synchronized(this) {
122 if (shutdownFlag || interrupted())
123 return null;
124
125 connecting = ioio = IOIOFactory.create(factory.createConnection());
126 }
127
128 try {
129 ioio.waitForConnect();
130 if (ioio.getState() != IOIO.State.CONNECTED) {
131 Log.w(TAG, "IOIO connection " + getName() + " failed");
132 ioio.disconnect();
133 return null;
134 }
135
136 Log.d(TAG, "IOIO connection " + getName() + " established");
137
138 Log.i(TAG, "IOIO hardware version " +
139 ioio.getImplVersion(IOIO.VersionType.HARDWARE_VER));
140 Log.i(TAG, "IOIO bootloader version " +
141 ioio.getImplVersion(IOIO.VersionType.BOOTLOADER_VER));
142 Log.i(TAG, "IOIO firmware version " +
143 ioio.getImplVersion(IOIO.VersionType.APP_FIRMWARE_VER));
144 Log.i(TAG, "IOIOLib version " +
145 ioio.getImplVersion(IOIO.VersionType.IOIOLIB_VER));
146
147 ioio.softReset();
148
149 synchronized(this) {
150 listener.onIOIOConnect(ioio);
151 openFlag = true;
152 return ioio;
153 }
154 } catch (ConnectionLostException e) {
155 Log.w(TAG, "IOIO connection " + getName() + " lost");
156 ioio.disconnect();
157 return null;
158 } catch (IncompatibilityException e) {
159 Log.e(TAG, "IOIO connection " + getName() + " incompatible");
160 ioio.disconnect();
161 return null;
162 } catch (InterruptedException e) {
163 ioio.disconnect();
164 return null;
165 } finally {
166 synchronized(this) {
167 connecting = null;
168 }
169 }
170 }
171
172 /**
173 * Called by the connection thread to close the connection.

Callers 1

runMethod · 0.95

Calls 3

getStateMethod · 0.65
onIOIOConnectMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected