Flush buffered output to twe::stream.
Flush the output buffer of mwx::stream
. Instance to a helper class that calls the flush()
method.
For serial ports, wait polling until output completes.
For mwx::simpbuf
buffers, output 0x00
at the end (size is not changed)
twe::stream に改行コードを出力する
Instance of a helper class to output a newline code (CR LF) for the <<
operator of mwx::stream
.
stream_helper is a helper object that grants the mwx::stream
interface. It creates a helper object that references a data class and performs data input/output via the helper object.
The following creates a helper object bs
from an array b
of smplbufs and inputs data using the mwx::stream::operator <<()
operator.
stream_helper behaves as if the data array were a stream.
Internally, it holds read/write positions in the data array. It behaves as follows.
After the last data is read or written, it moves to the next read/write position.
After the last data is read or data is appended to the end, the read/write position becomes the end.
If the read/write position is the end of the line, then
available()
becomes false
.
Read cannot be performed.
Writing is appended if it is within the writable range.
stream_helper is a data class (smplbuf, EEPROM) member functions.
Moves the read/write position to the beginning.
Set the read/write position.
Returns the read/write position. Returns -1
for the end position.
Returns 0
if the read/write position is the end. If it is not the end, it returns any other value.
Enter printf format in mwx::stream
Helper class for writing format format to the << operator of mwx::stream
. In the library, it is alias defined as Using format=mwx::mwx_format;
.
The maximum number of arguments that can be registered in the variable number argument list is 8. 64-bit parameters such as double and uint64_t type are limited in number. If the limit is exceeded, a compile error will result due to static↵_assert.
Store the argument list received in the constructor in a variable internal to the class using the expand function of the parameter pack.
Call fctprintf()
at the point operator <<
is called to write data to the stream
The constructor stores the format pointer and parameters. The subsequent call with the <<
operator interprets the format and processes the output.
The fmt
must remain accessible until this object is destroyed.
input-output stream
Upper-level class that handles input/output streams.
Interfaces to several classes (Serial, Wire, SPI, smplbuf
) by polymorphism using CRTP (Curiously Recurring Template Pattern) method.
In CRTP, lower classes are defined as template class Derived : public stream<Derived>;
and methods of lower classes are referenced from upper classes.
This class defines common processing such as print
method, <<
operator, etc., and calls write()
method, etc. implemented in lower classes, which is similar to using virtual functions.
Lower classes implement the functions listed below.
Returns 1 if the input exists, 0 if it does not.
The return value of this implementation is not the buffer length.
Flush output (wait for output to complete).
Inputs 1-byte data from the stream. If the data does not exist, return -1
.
Outputs 1 byte to the stream.
This is a static function that produces a single byte output. Since this is not a class method, member variables and other information are not available. Instead, a pointer to the class instance is passed to vp, which is passed as a parameter.
This static function is used internally and the function pointer is passed as a one-byte output function of fctprintf()
. This is used to implement the print
method, etc.
Output a single byte.
Performs various types of formatted output.
Prints output in printf format.
TWESDK/TWENET/current/src/printf/README.md 参照
When outputting as a byte string, cast to uint8_t, uint16_t, uint32_t
type. When outputting numerical values as strings, explicitly cast to int
type.
Single-byte types are handled differently depending on the type name. Usually, use the size-conscious uint8_t[S]
type.
Manages input timeouts and errors using the >>
operator.
The timeout period is specified by set_timeout()
, and input is processed using the >>
operator. If no input is received within the given timeout period, the error value can be read out with get_error_status()
. The error status is cleared by clear_error_status()
.
Input processing.
Cannot be executed within setup()
.
Because it waits for polling, depending on the timeout time setting (e.g. no timeout), the watchdog timer may be triggered and reset.
Normally, the following readout is performed during loop()
.
The following is a list of types that can be read and stored.
whence | Set the location |
---|---|
Parameters | Description |
---|---|
Parameters | Description |
---|
Parameters | Description |
---|
Parameters | Description |
---|
Parameters | Description |
---|
Paramita | Explanation |
---|
Argument type | Explanation |
---|
Argument type | Description |
---|
Value | Meaning |
---|
Argument type | Explanation |
---|
MWX_SEEK_SET
set from the leading position. If offset
is 0
, it means the same as rewind()
.
MWX_SEEK_CUR
Move by offset
with respect to the current position.
MWX_SEEK_END
end position. Setting offset
to 0
sets the end position. If -1
is set, it moves to the last character.
fmt
Format format. See TWESDK/TWENET/current/src/printf/README.md
...
Parameters according to the format format. * The maximum number of parameters is 4. 5 or more parameters will result in a compile error. * Since consistency with the format is not checked, it is not safe for inconsistent input.
| a value of type |
Return value | 0: no data 1: data present |
| The character you want to output. |
Return value | 1 if output succeeds, 0 if it fails. |
| the character to output |
| pointer to a class instance Usually, cast to the original class and call the write() method |
| Integer powerups |
| power form BIN binary / OCT 8 math / DEC 10 math / HEX 16 math |
| Number of decimals below the decimal point |
back | the number of booklets |
| Sets the timeout period in units of 1/10 second. If |
0 | No Error |
1 | Error Status |
1-byte input (big-endian order) |
2-byte input (big-endian order) |
| 4-byte input (big-endian order) |
| input for |
| read |
| 1-byte output (not formatted as a number) |
1-byte output (not formatted as a number) |
| numeric output (printf's "%.2f") |
| output 1 byte (same as char type) |
| output 2 bytes (big-endian order) |
| output 4 bytes (big-endian order) |
| Output up to the terminating character. Output does not include the terminating character. >( |
| Output the array size |
| output in printf format |
| output of newline CRLF |
| flush output |
| output numeric types in big-endian order. (right-hand side value) |
| A pair containing |
output byte string using |
|
|
|
Output the contents of an array class of type uint8_t
. ALC
is .
Outputs data of smplbuf<T>
T
is of type uint8_t
, AL
is a .