Forum Stats

  • 3,783,368 Users
  • 2,254,767 Discussions


UART Access Not Working - ME SDK 8

l_stanton Member Posts: 4
edited May 21, 2014 11:27AM in Java ME Embedded

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);

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(








                100, 100);

        try {

            uart = (UART);

            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 {


    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,


Best Answer


  • l_stanton
    l_stanton Member Posts: 4
    Accepted Answer

    The application was being launched on EmbeddedDevice1 emulator.  Running on the registered Raspberry Pi fired the INPUT_DATA_AVAILABLE event.

  • 2672563
    2672563 Member Posts: 2
    edited May 18, 2014 9:56PM

    I am trying to do exactly the same thing except in my case the UART is talking to an Adafruit GPS module (with exactly the same comms parameters, conveniently).  When I call I get an IOException with a null message, but the Device Log shows "VM - [SERIAL] iso=-1:[UART] Can't open /dev/ttyAMA0 file errno 13" which is a permission denied error.  This makes no sense since (1) I'm running under sudo, and (2) I don't even need root to access /dev/ttyAMA0 (I can, for example do "cat /dev/ttyAMA0" from BASH command line logged in as pi, and see a bunch of NMEA-ish looking strings fly by).

    I've done the magic to disable the UART as a console and prevent the getty on it, I've given my MIDlet the [jdk.dio.uart.UARTPermission "*:*" "open"] permission.  The JVM security manager seems quite content to let me open this device... but the OS isn't.  Suggestions?

  • Did you follow Getting Started Guide and disable serial console?

  • 2672563
    2672563 Member Posts: 2
    edited May 21, 2014 10:38AM

    Yes, as I stated in my original post, "I've done the magic to disable the UART as a console".  Also I can just do  "cat /dev/ttyAMA0" from the BASH prompt and I see output from the GPS module.  I also can open and read from the UART from a Perl script and I get valid messages from the GPS module.

  • I can't help here since those error are reported by system call of open("/dev/ttyAMA0"), not by java code

This discussion has been closed.