5 years, 4 months ago.

RawSerial should add one function of as WriteBytes(const uint8_t* buf, int len)

I thought that RawSerial should add one function like WriteBytes(const uint8_t* buf, int len), it will be usefull. BTW, can the printf change implementation method without using vsnprintf(NULL, 0...), 'Cos it didn't support by most of MCUs.

Question relating to:

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

2 Answers

5 years, 3 months ago.

I would recommend the signatures:

write(const void* source_buffer, size_t length);
read(void* destination_buffer, size_t length);

This allows arbitrary data structures to be sent or received without any casting, eg:

struct MyDataPacket {
  // My Data Packet Fields
  uint32_t field1;
  int64_t  field2;
  // More fields as needed

// Fill MyDataPacket
MyDataPacket data;
data.field1 = value;
data.field2 = othervalue;
// etc...

// Send MyDataPacket
rawserial.write(&data, sizeof(data));

Accepted Answer
5 years, 4 months ago.


any contribution is more than welcome, send a pull request to mbed github repository (link below) with proposed changes, where we can review, test and merge ,plus discuss the implementation.

mbed SDK https://github.com/mbedmicro/mbed