32 static ParameterCategory
const ParamCateg(
"Serial Port Options");
40 115200, { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200,
41 230400, 460800, 921600, 1000000, 1152000, 1500000, 2000000,
42 2500000, 3000000, 3500000, 4000000 }, ParamCateg);
46 "8N1", boost::regex(
"^[5-8][NEO][12]$"), ParamCateg);
58 "avoid blocking when writing messages to serial-over-USB port and the host is "
59 "not listening to it. Note that even when drop is false, we will still drop "
60 "data after repeated attempts to send it, and will report an error (as opposed to "
61 "silently dropping when drop is true).",
69 "CRLF is for 0x0d 0x0a [\\r\\n]; Zero is for 0x00 [\\0]; Sloppy accepts any of "
70 "CR, LF, CRLF, 0xd0 (issued by some keyboards instead of Return), and Zero as input "
71 "and issues CRLF in outputs.",
72 LineStyle::Sloppy, LineStyle_Values, ParamCateg);
79 TerminalMode::Plain, TerminalMode_Values, ParamCateg);
86 public Parameter<serial::devname, serial::baudrate, serial::format, serial::flowsoft,
87 serial::flowhard, serial::drop, serial::linestyle, serial::mode>
98 void setBlocking(
bool blocking, std::chrono::milliseconds
const & timeout);
101 void toggleDTR(std::chrono::milliseconds
const & dur);
107 bool readSome(std::string & str)
override;
111 void writeString(std::string
const & str)
override;
116 void fileGet(std::string
const & abspath);
121 void filePut(std::string
const & abspath);
136 void writeInternal(
void const * buffer,
const int nbytes,
bool nodrop =
false);
138 termios itsSavedState;
139 std::string itsPartialString;
141 int itsWriteOverflowCounter;
143 std::atomic<int> itsErrno;
144 std::future<void> itsOpenFut;
Interface to a serial port.
void writeString(std::string const &str) override
Write a string, using the line termination convention of serial::linestyle.
JEVOIS_DECLARE_PARAMETER(format, std::string, "Data format", "8N1", boost::regex("^[5-8][NEO][12]$"), ParamCateg)
Parameter.
void postInit() override
Called after all sub-Components are init()ed.
void setBlocking(bool blocking, std::chrono::milliseconds const &timeout)
Set the access to blocking or not.
JEVOIS_DECLARE_PARAMETER(mode, TerminalMode, "Terminal emulation mode for input", TerminalMode::Plain, TerminalMode_Values, ParamCateg)
Parameter.
void flush(void)
Flush all inputs.
JEVOIS_DECLARE_PARAMETER(linestyle, LineStyle, "End of line style: LF is for 0x0a [\\n] CR is for 0x0d [\\r] " "CRLF is for 0x0d 0x0a [\\r\\n] Zero is for 0x00 [\\0] Sloppy accepts any of " "CR, LF, CRLF, 0xd0 (issued by some keyboards instead of Return), and Zero as input " "and issues CRLF in outputs.", LineStyle::Sloppy, LineStyle_Values, ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(flowsoft, bool, "Use soft (XON/XOFF) flow control", false, ParamCateg)
Parameter.
void sendBreak(void)
transmit continuous stream of zero-valued bits for specific duration.
bool readSome(std::string &str) override
Read some bytes if available, and return true and a string when one is complete.
void toggleDTR(std::chrono::milliseconds const &dur)
Set the DTR mode off momentarily.
void filePut(std::string const &abspath)
Receive a file from the host and write it to the local microSD.
JEVOIS_DEFINE_ENUM_CLASS(TerminalMode,(Plain)(VT100))
Enum for Parameter.
void fileGet(std::string const &abspath)
Send a file from the local microSD to the host computer.
JEVOIS_DECLARE_PARAMETER(baudrate, unsigned int, "Baudrate", 115200, { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 }, ParamCateg)
Parameter.
virtual ~Serial()
destructor
JEVOIS_DECLARE_PARAMETER(devname, std::string, "Device file name", "", ParamCateg)
Parameter.
JEVOIS_DECLARE_PARAMETER(drop, bool, "Silently drop write data when write buffer is full. Useful to " "avoid blocking when writing messages to serial-over-USB port and the host is " "not listening to it. Note that even when drop is false, we will still drop " "data after repeated attempts to send it, and will report an error (as opposed to " "silently dropping when drop is true).", true, ParamCateg)
Parameter.
JEVOIS_DEFINE_ENUM_CLASS(LineStyle,(LF)(CR)(CRLF)(Zero)(Sloppy))
Enum for Parameter.
UserInterface::Type type() const override
Return our port type, here Hard or USB.
JEVOIS_DECLARE_PARAMETER(flowhard, bool, "Use hard (RTS/CTS) flow control", false, ParamCateg)
Parameter.
void postUninit() override
Called after all sub-Components are uninit()ed.
Abstract base class for a string-based user interface.
Type
Enum for the interface type.
Main namespace for all JeVois classes and functions.