Private
Public Access
2
0

examples/java: Port examples containing [Interesting] tag from C/C++

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Petre Eftime
2015-09-30 13:22:47 +03:00
committed by Brendan Le Foll
parent 0e44dfac44
commit bda9f4d211
8 changed files with 598 additions and 0 deletions

45
examples/java/AioA0.java Normal file
View File

@@ -0,0 +1,45 @@
/*
* Author: Nandkishor Sonar
* Copyright (c) 2014 Intel Corporation.
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//! [Interesting]
import mraa.Aio;
public class AioA0 {
public static void main(String[] args) {
Aio a0 = new Aio(0);
while (true) {
int adc_value = a0.read();
float adc_value_float = a0.readFloat();
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
}
}
}
//! [Interesting]

View File

@@ -0,0 +1,72 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Dir;
import mraa.Gpio;
import mraa.Result;
import mraa.mraa;
public class BlinkIO {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
final static int DEFAULT_IOPIN = 8;
public static void main(String argv[]) throws InterruptedException {
int iopin = DEFAULT_IOPIN;
if (argv.length == 0) {
System.out.println("Provide an int arg if you want to flash on something other than " + DEFAULT_IOPIN);
} else {
iopin = Integer.valueOf(argv[0], DEFAULT_IOPIN);
}
//! [Interesting]
Gpio gpio = new Gpio(iopin);
Result result = gpio.dir(Dir.DIR_OUT);
if (result != Result.SUCCESS) {
mraa.printError(result);
System.exit(1);
}
while (true) {
gpio.write(1);
Thread.sleep(1000);
gpio.write(0);
Thread.sleep(1000);
}
//! [Interesting]
}
}

View File

@@ -0,0 +1,60 @@
/*
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Gpio;
import mraa.mraa;
public class GpioMmapped {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
public static void main(String argv[]) throws InterruptedException {
//! [Interesting]
String board = mraa.getPlatformName();
String version = mraa.getVersion();
System.out.println("hello mraa");
System.out.println(String.format("Version: %s", version));
Gpio gpio = new Gpio(1);
gpio.useMmap(true);
while (true) {
gpio.write(1);
Thread.sleep(50);
gpio.write(0);
Thread.sleep(50);
}
//! [Interesting]
};
}

View File

@@ -0,0 +1,73 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//! [Interesting]
import mraa.Dir;
import mraa.Gpio;
import mraa.IntelEdison;
import mraa.mraa;
import mraa.Platform;
import mraa.Result;
public class HelloEdison {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
public static void main(String argv[]) {
Platform platform = mraa.getPlatformType();
if (platform != Platform.INTEL_EDISON_FAB_C) {
System.err.println("Error: This program can only be run on edison");
System.exit(Result.ERROR_INVALID_PLATFORM.swigValue());
}
/*
* MRAA_INTEL_EDISON_GP182 == 0, so this will initialise pin0 on arduino,
* which is hardware GPIO 130 and not 182
* We set the owner to false here, this makes sure that we do not close the
* gpio from sysfs in mraa_gpio_close meaning it will stay as an output and
* we will not always transition from 0->1 as gpio182 as output has the
* default position of '0'. Note that the value could change as a result of
* a mraa_gpio_dir however meaning we always go from 0->1 or 1->0
*/
Gpio gpio182 = new Gpio(IntelEdison.INTEL_EDISON_GP182.swigValue(), false);
gpio182.dir(Dir.DIR_OUT);
int val = gpio182.read();
System.out.println(String.format("GPIO%d (mraa pin %d) was: %d, will set to %d\n", 182,
gpio182.getPin(), val, val == 0 ? 1 : 0));
gpio182.write(val == 0 ? 1 : 0);
};
}
//! [Interesting]

View File

@@ -0,0 +1,135 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.I2c;
public class I2cCompass {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
final static byte MAX_BUFFER_LENGTH = 6;
final static byte CONF_BUFFER_LENGTH = 2;
final static short HMC5883L_I2C_ADDR = 0x1E;
// configuration registers
final static byte HMC5883L_CONF_REG_A = 0x00;
final static byte HMC5883L_CONF_REG_B = 0x01;
// mode register
final static byte HMC5883L_MODE_REG = 0x02;
// data register
final static byte HMC5883L_X_MSB_REG = 0;
final static byte HMC5883L_X_LSB_REG = 1;
final static byte HMC5883L_Z_MSB_REG = 2;
final static byte HMC5883L_Z_LSB_REG = 3;
final static byte HMC5883L_Y_MSB_REG = 4;
final static byte HMC5883L_Y_LSB_REG = 5;
final static byte DATA_REG_SIZE = 6;
// status register
final static byte HMC5883L_STATUS_REG = 0x09;
// ID registers
final static byte HMC5883L_ID_A_REG = 0x0A;
final static byte HMC5883L_ID_B_REG = 0x0B;
final static byte HMC5883L_ID_C_REG = 0x0C;
final static byte HMC5883L_CONT_MODE = 0x00;
final static byte HMC5883L_DATA_REG = 0x03;
// scales
final static byte GA_0_88_REG = ((byte) (0x00 << 5));
final static byte GA_1_3_REG = ((byte) (0x01 << 5));
final static byte GA_1_9_REG = ((byte) (0x02 << 5));
final static byte GA_2_5_REG = ((byte) (0x03 << 5));
final static byte GA_4_0_REG = ((byte) (0x04 << 5));
final static byte GA_4_7_REG = ((byte) (0x05 << 5));
final static byte GA_5_6_REG = ((byte) (0x06 << 5));
final static byte GA_8_1_REG = ((byte) (0x07 << 5));
// digital resolutions
final static float SCALE_0_73_MG = 0.73f;
final static float SCALE_0_92_MG = 0.92f;
final static float SCALE_1_22_MG = 1.22f;
final static float SCALE_1_52_MG = 1.52f;
final static float SCALE_2_27_MG = 2.27f;
final static float SCALE_2_56_MG = 2.56f;
final static float SCALE_3_03_MG = 3.03f;
final static float SCALE_4_35_MG = 4.35f;
public static void main(String[] args) throws InterruptedException {
float direction = 0;
int x, y, z;
byte[] rx_tx_buf = new byte[MAX_BUFFER_LENGTH];
byte[] conf_buf = new byte[CONF_BUFFER_LENGTH];
//! [Interesting]
I2c i2c = new I2c(0);
i2c.address(HMC5883L_I2C_ADDR);
conf_buf[0] = HMC5883L_CONF_REG_B;
conf_buf[1] = GA_1_3_REG;
i2c.write(conf_buf);
//! [Interesting]
i2c.address(HMC5883L_I2C_ADDR);
conf_buf[0] = HMC5883L_MODE_REG;
conf_buf[1] = HMC5883L_CONT_MODE;
i2c.write(conf_buf);
while (true) {
i2c.address(HMC5883L_I2C_ADDR);
i2c.writeByte(HMC5883L_DATA_REG);
i2c.address(HMC5883L_I2C_ADDR);
i2c.read(rx_tx_buf);
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
if (direction < 0)
direction += 2 * Math.PI;
System.out.println(String.format("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
z * SCALE_0_92_MG));
System.out.println(String.format("Heading : %f\n", direction * 180 / Math.PI));
Thread.sleep(1000);
}
}
}

View File

@@ -0,0 +1,93 @@
/*
* Author: Michael Ring <mail@michael-ring.org>
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import java.nio.ByteBuffer;
import mraa.Result;
import mraa.Spi;
public class SpiMAX7219 {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
public static void main(String argv[]) throws InterruptedException {
//! [Interesting]
Spi spi = new Spi(1);
spi.frequency(400000);
spi.lsbmode(false);
if(spi.bitPerWord(16) != Result.SUCCESS) {
System.err.println("Could not set SPI Device to 16Bit mode, exit...");
System.exit(1);
}
spi.write_word(0x0900); //Do not decode bits
spi.write_word(0x0a05); // Brightness of LEDs
spi.write_word(0x0b07); // Show all Scan Lines
spi.write_word(0x0c01); // Display on
spi.write_word(0x0f00); // Testmode off
short dataAA55[] = { 0x01aa, 0x0255, 0x03aa, 0x0455, 0x05aa, 0x0655, 0x07aa, 0x0855 };
ByteBuffer buf = ByteBuffer.allocate(dataAA55.length * 2);
for (int i = 0; i < dataAA55.length; i++)
buf.putShort(dataAA55[i]);
spi.write(buf.array());
Thread.sleep(2000);
short data55AA[] = { 0x0155, 0x02aa, 0x0355, 0x04aa, 0x0555, 0x06aa, 0x0755, 0x08aa };
buf = ByteBuffer.allocate(data55AA.length * 2);
for (int i = 0; i < data55AA.length; i++)
buf.putShort(data55AA[i]);
spi.write(buf.array());
Thread.sleep(2000);
short data[] = { 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700, 0x0800 };
buf = ByteBuffer.allocate(data.length * 2);
for (int i = 0; i < data.length; i++)
buf.putShort(data[i]);
spi.write(buf.array());
for (int i = 1; i <= 8; i++) {
for (int j = 0; j < 8; j++) {
spi.write_word((i << 8) + (1 << j));
Thread.sleep(1000);
}
spi.write_word(i << 8);
}
//! [Interesting]
};
}

View File

@@ -0,0 +1,64 @@
/*
* Author: Alexander Komarov <alexander.komarov@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Spi;
public class SpiMCP4261 {
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
public static void main(String argv[]) throws InterruptedException {
//! [Interesting]
Spi spi = new Spi(0);
System.out.println("Hello, SPI initialised");
byte data[] = {0x00, 100};
while (true) {
for (int i = 90; i < 130; i++) {
data[1] = (byte) i;
byte[] recv = spi.write(data);
System.out.println(String.format("Writing - %d", i));
System.out.println(String.format("Received - %d - %d", recv[0], recv[1]));
Thread.sleep(100);
}
for (int i = 130; i > 90; i--) {
data[1] = (byte) i;
byte[] recv = spi.write(data);
System.out.println(String.format("Writing - %d", i));
System.out.println(String.format("Received - %d - %d", recv[0], recv[1]));
Thread.sleep(100);
}
}
//! [Interesting]
};
}

View File

@@ -0,0 +1,56 @@
/*
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2014, 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Result;
import mraa.Uart;
import mraa.UartParity;
public class UartExample {
public static void main(String[] args) {
//! [Interesting]
Uart uart = new Uart(0);
if (uart.setBaudRate(115200) != Result.SUCCESS) {
System.err.println("Error setting baud rate");
System.exit(1);
}
if (uart.setMode(8, UartParity.UART_PARITY_NONE, 1) != Result.SUCCESS) {
System.err.println("Error setting mode");
System.exit(1);
}
if (uart.setFlowcontrol(false, false) != Result.SUCCESS) {
System.err.println("Error setting flow control");
System.exit(1);
}
uart.writeStr("Hello monkeys");
//! [Interesting]
}
}