MCPcopy Index your code
hub / github.com/processing/processing / transfer

Method transfer

java/libraries/io/src/processing/io/SPI.java:164–188  ·  view source on GitHub ↗

Transfers data over the SPI bus @param out bytes to send @return bytes read in (array is the same length as out) @webref

(byte[] out)

Source from the content-addressed store, hash-verified

162 * @webref
163 */
164 public byte[] transfer(byte[] out) {
165 if (NativeInterface.isSimulated()) {
166 return new byte[out.length];
167 }
168
169 // track the current setting per device across multiple instances
170 String curSettings = maxSpeed + "-" + dataOrder + "-" + mode;
171 if (!curSettings.equals(settings.get(dev))) {
172 int ret = NativeInterface.setSpiSettings(handle, maxSpeed, dataOrder, mode);
173 if (ret < 0) {
174 System.err.println(NativeInterface.getError(handle));
175 throw new RuntimeException("Error updating device configuration");
176 }
177 settings.put(dev, curSettings);
178 }
179
180 byte[] in = new byte[out.length];
181 int transferred = NativeInterface.transferSpi(handle, out, in);
182 if (transferred < 0) {
183 throw new RuntimeException(NativeInterface.getError(transferred));
184 } else if (transferred < out.length) {
185 throw new RuntimeException("Fewer bytes transferred than requested: " + transferred);
186 }
187 return in;
188 }
189
190
191 /**

Callers

nothing calls this directly

Calls 8

isSimulatedMethod · 0.95
setSpiSettingsMethod · 0.95
getErrorMethod · 0.95
transferSpiMethod · 0.95
getMethod · 0.65
equalsMethod · 0.45
printlnMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected