microbit-dal: added validation to send [#151]
This commit is contained in:
parent
a962befe74
commit
05c03b06fa
|
@ -265,8 +265,9 @@ class MicroBitSerial : public RawSerial
|
|||
*
|
||||
* 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 send(ManagedString s, MicroBitSerialMode mode = MICROBIT_DEFAULT_SERIAL_MODE);
|
||||
|
||||
|
@ -292,8 +293,9 @@ class MicroBitSerial : public RawSerial
|
|||
*
|
||||
* 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 send(uint8_t *buffer, int bufferLen, MicroBitSerialMode mode = MICROBIT_DEFAULT_SERIAL_MODE);
|
||||
|
||||
|
|
|
@ -441,8 +441,9 @@ int MicroBitSerial::sendChar(char c, MicroBitSerialMode mode)
|
|||
*
|
||||
* 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 @@ int MicroBitSerial::send(ManagedString s, MicroBitSerialMode mode)
|
|||
*
|
||||
* 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
|
||||
|
|
Loading…
Reference in New Issue