Android serial communication

Asked

Viewed 11 times

0

I have an Android app that does serial communication with an interface. The device I use has two serial ports: ttymxc0 and ttymxc4. When I try to access both ports at the same time, the library interrupts communication from one of the serial ports and enables the other.

Here is the method where I call the serial communication API:

public String open() {
    if (serialPortBaudRate == 0 || serialPortPath.compareTo("") == 0) {
        return "Erro: Dados da porta inválidos.(0x%08X)";
    }

    File serialportNode = new File(serialPortPath);

    int ret = sp.open(serialportNode, serialPortBaudRate);

    if (ret != ErrorCode.ERR_NO_ERROR) {
        return "ERRO: " + String.format("Falha ao abrir a porta.(0x%08X)", ret);
    }

    startReading();

    return "";
}

Here is the native API method:

public int open(File portNode, int baudrate) {
    int ret = this.openNative(portNode.getAbsolutePath(), baudrate);
    if (ret != 0) {
        this.logError("Failed to open serial port");
    } else {
        this.logDebug(String.format("Open serial port OK ! [%s]", portNode.getAbsolutePath()));
    }

    return ret;
}

Does anyone have any idea how to use both serials concurrently?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.