Skip to content

stream I/O #6

@supercamel

Description

@supercamel

Hello,

The stream class should have functions that simplify and assist with receiving ASCII text and binary data from a serial input. I propose these functions should add the ability to

  • check number of bytes available
  • read all bytes into a list/array/container object
  • read bytes until a specific value is reached
  • extract bytes between two specified values. often binary packets have a start byte and an end byte
  • get binary int (16, 32 or 64 bit, little or big endian). for an int16, this would read two bytes and convert it into an int16.
  • getline
  • get string until a byte is received (like getline, only it doesn't stop at '\n', it stops at whatever char is specified).
  • parse next integer. ignore all bytes until an integer is received, then return that value
  • parse next float

At the moment, the stream class requires a 'put' function to write a byte. To receive data, it would require an 'available' function that returns the number of bytes available to process, and a 'get' function that reads a single byte.

Feedback & discussion around how to best implement this is very welcome. To actually contribute code, please do a pull request.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions