test
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
Diff: source/drivers/MicroBitSerial.cpp
- Revision:
- 67:99cfde195ff3
- Parent:
- 66:2fc7d7c2fffc
--- a/source/drivers/MicroBitSerial.cpp Wed Jul 13 12:18:46 2016 +0100 +++ b/source/drivers/MicroBitSerial.cpp Wed Jul 13 12:18:47 2016 +0100 @@ -441,8 +441,9 @@ * * Defaults to SYNC_SLEEP. * - * @return the number of bytes written, or MICROBIT_SERIAL_IN_USE if another fiber - * is using the serial instance for transmission. + * @return the number of bytes written, MICROBIT_SERIAL_IN_USE if another fiber + * is using the serial instance for transmission, MICROBIT_INVALID_PARAMETER + * if buffer is invalid, or the given bufferLen is <= 0. */ int MicroBitSerial::send(ManagedString s, MicroBitSerialMode mode) { @@ -471,14 +472,18 @@ * * Defaults to SYNC_SLEEP. * - * @return the number of bytes written, or MICROBIT_SERIAL_IN_USE if another fiber - * is using the serial instance for transmission. + * @return the number of bytes written, MICROBIT_SERIAL_IN_USE if another fiber + * is using the serial instance for transmission, MICROBIT_INVALID_PARAMETER + * if buffer is invalid, or the given bufferLen is <= 0. */ int MicroBitSerial::send(uint8_t *buffer, int bufferLen, MicroBitSerialMode mode) { if(txInUse()) return MICROBIT_SERIAL_IN_USE; + if(bufferLen <= 0 || buffer == NULL) + return MICROBIT_INVALID_PARAMETER; + lockTx(); //lazy initialisation of our tx buffer