App_uart manifests as one byte buffer.

Hi,

I am running into this issue when receiving over uart where the byte received is always one byte behind relative to the byte sent by the sender. The byte received is either, a) nothing if it's the first communication, or b) the byte of the previous message sent by the sender.

I get this behavior in both the unchanged uart example, as well as the libuarte example in SDKs 15,16,17 (haven't tested others).

For example:

Sent: 0

Received: 

Sent: 1

Received: 0

Sent: 2

Received: 1

What do I have to change in the uart and libuarte loopback examples to see the following behavior?

Sent: 0

Received: 0

Sent: 1

Received: 1

Sent: 2

Received: 2

Parents
  • Hi,

    This is not the normal behavior of the example. I tested out the UART peripheral example from SDK 17.1.0 just now, and I can send one character from the PC terminal (specifically "Termite", with settings set to "append nothing", to avoid any CR/LF bytes affecting the test), and I receive the character back from the nRF52 DK. 

    What are you using to send the data to the nRF52 device? Have you verified that the data is actually sent out from the sender (using logic analyzer, etc)?

    Best regards,
    Jørgen

  • I unfortunately don't have a logic analyzer.

    I am seeing this behavior through two methods of sending data.

    1. I'm on a Mac, so I use the "screen" command as serial terminal to connect to the board and send bytes. Something like,

    >> screen /dev/tty.usbmodem0006830284221 115200

    Then I type input and it gets sent right back and I see the weird behavior.

    2. I run a java program and use a library called JSerialComm 2.7.0 to talk over the serial connection. Here is the code,

    SerialPort ports[] = SerialPort.getCommPorts();

    SerialPort devBoard = ports[4];

    devBoard.openPort();

    devBoard.setBaudRate(115200);

    devBoard.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING | SerialPort.TIMEOUT_WRITE_BLOCKING, 0, 30);

    InputStream input = devBoard.getInputStream();

    OutputStream output = devBoard.getOutputStream();

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while (true) {

    String string = br.readLine();

    output.write(string.getBytes());

    byte bite = (byte) input.read();

    System.out.print((char) bite);

    }

    Still get the same behavior. A co-worker of mine tried running the above on a PC to the same effect.

Reply
  • I unfortunately don't have a logic analyzer.

    I am seeing this behavior through two methods of sending data.

    1. I'm on a Mac, so I use the "screen" command as serial terminal to connect to the board and send bytes. Something like,

    >> screen /dev/tty.usbmodem0006830284221 115200

    Then I type input and it gets sent right back and I see the weird behavior.

    2. I run a java program and use a library called JSerialComm 2.7.0 to talk over the serial connection. Here is the code,

    SerialPort ports[] = SerialPort.getCommPorts();

    SerialPort devBoard = ports[4];

    devBoard.openPort();

    devBoard.setBaudRate(115200);

    devBoard.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING | SerialPort.TIMEOUT_WRITE_BLOCKING, 0, 30);

    InputStream input = devBoard.getInputStream();

    OutputStream output = devBoard.getOutputStream();

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while (true) {

    String string = br.readLine();

    output.write(string.getBytes());

    byte bite = (byte) input.read();

    System.out.print((char) bite);

    }

    Still get the same behavior. A co-worker of mine tried running the above on a PC to the same effect.

Children
No Data
Related