jfjlaros / simpleRPC

Simple RPC implementation for Arduino.
MIT License
50 stars 17 forks source link

Array and String bulk write #33

Open yanxke opened 6 months ago

yanxke commented 6 months ago

Pull Request Details

Provide details about your pull request and what it adds, fixes, or changes.

Use the underlying io.write(buf, len) methods when there are multiple items to be written. This dramatically speeds up the transfer speeds.

Breaking Changes

Describe what features are broken by this pull request and why, if any.

None

Issues Fixed

Enter the issue numbers resolved by this pull request below, if any.

None

Other Relevant Information

Provide any other important details below.

Tested on my Adafruit M0 and it's about 3X the transfer speed over the USB serial console.

jfjlaros commented 6 months ago

I do not think this will work when the array contains non-POD types, e.g., an array of vectors.

yanxke commented 6 months ago

There should be a new method for sending buffer arrays then. The methods for sending generic types are too slow.

jfjlaros commented 6 months ago

I do not think overloading something like Array<uint8_t, n> will be safe. Adding an additional data member to Array will break the proposed approach for example.

Maybe an overload for specific array references could work, e.g.,

template <size_t n, size_t m>
void rpcWrite(Stream& io, uint8_t (& data)[n][m]) {
  // ...
}
suahelen commented 4 months ago

I had the same experience. The issue would be resolved with this PR: https://github.com/jfjlaros/arduino-simple-rpc/pull/26