Skip to content

NRF5: Async serial write doesn't send first character and reads past length #4002

Closed
@seppestas

Description

@seppestas

Because of an off-by-one error in the serial_api of the NRF5 target the first character of the buffer is not sent and data at buffer[length] is accessed when using the Serial.Read function.

Steps to reproduce

  • Program following firmware on an NRF52 MCU:
#include "mbed.h"

// Note: using USBTX and USBRX seems to cause issues when trying to read
// This might be caused by stdio or my hardware.
Serial serial(USBTX, USBRX);

int main()
{
	serial.write(reinterpret_cast<const uint8_t *>("Hello world!"), sizeof("Hello world"), 0, 0);
}
  • Connect to the device's serial port
  • Start the device

Result

"ello world!" is received on the other end of the serial connection.

Expected result

"Hello world" should be recieved on the other end of the serial connection.

Environment

Tested on the NINA-B112 module with UBLOX_EVK_NINA_B1 target, but this issue
should exist on all targets overriding the NRF5 target.

Originaly found on mbed-os 5.4 (f4864dc), bug still exists in master.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions