I am attempting to receive data over the UART on a Raspberry Pi with Java ME 8 (fresh install of the newest release).
I modified the /etc/inittab file on the Pi:
#Spawn a getty on Raspberry Pi serial line
# below is commented out to support UART access from Java ME
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
as well as the /boot/cmdline.txt:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
as outlined in the Raspberry Pi Getting Started Guide.
I tried to create a new UART instance via DeviceManager:
uart = (UART) DeviceManager.open(40);
This generates a DeviceNotFoundException ("Device 40 not found"). I used 40 as that is the UART Device ID listed in the Getting Started Guide.
I also tried to create a new UART instance using a UARTConfig:
public void startApp() {
System.out.println("startApp() ++");
uartEventHandler = new UARTDataAvailableEventHandler();
// create a basic UART config
UARTConfig uartAdHocTemplate = new UARTConfig(
DeviceConfig.DEFAULT,
DeviceConfig.DEFAULT,
9600,
UARTConfig.DATABITS_8,
UARTConfig.PARITY_NONE,
UARTConfig.STOPBITS_1,
UARTConfig.FLOWCONTROL_NONE,
100, 100);
try {
uart = (UART) DeviceManager.open(uartAdHocTemplate);
if (uart != null) {
uart.setEventListener(UARTEvent.INPUT_DATA_AVAILABLE, uartEventHandler);
}
} catch (IOException ex) {
Logger.getLogger((TestUART.class.getName())).log(Level.SEVERE, null, ex);
}
System.out.println("startApp() --");
}
The event handler is defined as:
public class UARTDataAvailableEventHandler implements UARTEventListener {
@Override
public void eventDispatched(UARTEvent event) {
System.out.println("Received an UART event!!");
}
}
This runs but the event handler's eventDispatch method is never called.
The application has a UART permission set: jdk.dio.uart.UARTPermission "*:*" "open"
The serial data is sent from an XBee radio module - I verified through a logic analyzer that the expected data is being sent to to the RXD pin on the Pi Cobbler breakout board.
Thank you,
Luther