ost::SerialPort(3)

πŸ“¦ version 1.8.1, in ubuntu jammy

πŸ’– ost::SerialPort(3) β€” the manual page, bestie edition πŸ’–

okay so real talk, this page lives in the Library Functions Manual and it's all about ost::SerialPort, a GNU CommonC++ thing. pull up a chair, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

ost::SerialPort β€” so like, the serial port is an internal class which is attached to and then serviced by a specified SerialService thread. that's the whole vibe. it doesn't go out alone, it's got a service thread holding its hand 🫢


🌈 SYNOPSIS 🌈

#include <serial.h>

Inherits ost::Serial, and ost::TimerPort. yes bestie, it's got two parents and both of them ate πŸ’…

πŸ‘‘ Public Member Functions

  • void setTimer (timeout_t timeout=0) β€” a derived setTimer that goes and tells the service thread pool "hey, the expected timeout changed!!" so it can reschedule everything.
  • void incTimer (timeout_t timeout) β€” a derived incTimer that also notifies the service thread pool that the expected timeout changed. same energy, different function, periodt.

πŸŽ€ Protected Member Functions

  • SerialPort (SerialService *svc, const char *name) β€” constructs a tty serial port for a named serial device. iconic.
  • virtual ~SerialPort () β€” disconnects the Serial Port from the service pool thread and shuts the port down. say bye bye 😭
  • void setDetectPending (bool) β€” tells the service thread whether it should be monitoring pending data for us.
  • bool getDetectPending (void) const β€” returns the current state of the DetectPending flag. vibe check on that flag.
  • void setDetectOutput (bool) β€” tells whether output-ready monitoring should be done by the service thread.
  • bool getDetectOutput (void) const β€” returns the current state of the DetectOutput flag.
  • virtual void expired (void) β€” called by the service thread when the object's timer has expired. ding, time's up ⏰
  • virtual void pending (void) β€” called by the service thread when input data is pending for this tty port.
  • virtual void disconnect (void) β€” called by the service thread when an exception has occurred, such as a hangup.
  • int output (void *buf, int len) β€” transmits "send" data to the serial port.
  • virtual void output (void) β€” performed when output is available for sending data.
  • int input (void *buf, int len) β€” receives "input" for pending data from the serial port.

πŸ¦‹ Friends

  • class SerialService

Additional Inherited Members

(yes there are more, they're inherited, go look at the parent classes, iykyk πŸ’œ)


🌸 DETAILED DESCRIPTION 🌸

The serial port is an internal class which is attached to and then serviced by a specified SerialService thread.

Derived versions of this class offer specific functionality such as serial integration protocols. so if you want custom behaviour, you make a baby class that inherits from this one 🍼

The TTYPort and TTYService classes are used to form thread-pool serviced serial I/O protocol sets. These can be used when one has a large number of serial devices to manage, and a single (or limited number of) thread(s) can then be used to service the tty port objects present. Each tty port supports a timer control and several virtual methods that the service thread can call when events occur. This model provides for 'callback' event management, whereby the service thread performs a 'callback' into the port object when events occur. Specific events supported include:

  • the expiration of a TTYPort timer ⏰
  • pending input data waiting to be read πŸ“₯
  • 'sighup' connection breaks πŸ’”
ngl this is genuinely elegant. one thread, many ports, callbacks doing the absolute most. main character energy fr fr.

Author

David Sugar dyfet@ostel.com

base class for thread pool serviced serial I/O.


🧚 CONSTRUCTOR & DESTRUCTOR DOCUMENTATION 🧚

ost::SerialPort::SerialPort (SerialService * svc, const char * name)

[protected]

Construct a tty serial port for a named serial device.

Parameters

  • svc β€” pool thread object.
  • name β€” of tty port.

virtual ost::SerialPort::~SerialPort () [protected], [virtual]

Disconnect the Serial Port from the service pool thread and shutdown the port. it's giving "we're done here" πŸ’…


⭐ MEMBER FUNCTION DOCUMENTATION ⭐

virtual void ost::SerialPort::disconnect (void) [protected], [virtual]

Called by the service thread when an exception has occured such as a hangup.

virtual void ost::SerialPort::expired (void) [protected], [virtual]

Called by the service thread when the objects timer has expired.

bool ost::SerialPort::getDetectOutput (void) const [inline], [protected]

Get the current state of the DetectOutput flag.

bool ost::SerialPort::getDetectPending (void) const [inline], [protected]

Get the current state of the DetectPending flag.

void ost::SerialPort::incTimer (timeout_t timeout)

Derived incTimer to notify the service thread pool of a change in expected timeout. This allows SerialService to reschedule all timers.

int ost::SerialPort::input (void * buf, int len) [inline], [protected]

Receive 'input' for pending data from the serial port. This is not a public member since it's meant to support internal protocols rather than direct external access to the device. so don't go poking it from outside, bestie πŸ™ˆ

Returns

  • number of bytes received.

Parameters

  • buf β€” address of buffer to input.
  • len β€” of input buffer used.

int ost::SerialPort::output (void * buf, int len) [inline], [protected]

Transmit 'send' data to the serial port. This is not public since it's meant to support internal protocols rather than direct public access to the device.

Returns

  • number of bytes send.

Parameters

  • buf β€” address of buffer to send.
  • len β€” of bytes to send.

virtual void ost::SerialPort::output (void) [protected], [virtual]

Perform when output is available for sending data.

virtual void ost::SerialPort::pending (void) [protected], [virtual]

Called by the service thread when input data is pending for this tty port. Effected by setPacketInput and by setLineInput.

void ost::SerialPort::setDetectOutput (bool) [protected]

Used to indicate if output ready monitoring should be performed by the service thread.

void ost::SerialPort::setDetectPending (bool) [protected]

Used to indicate if the service thread should monitor pending data for us.

void ost::SerialPort::setTimer (timeout_t timeout = 0)

Derived setTimer to notify the service thread pool of changes in expected timeout. This allows SerialService to reschedule all timers.

Parameters

  • timeout β€” in milliseconds.

friend class SerialService [friend]

your fave is friends with SerialService, we love a supportive relationship 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Generated automatically by Doxygen for GNU CommonC++ from the source code.


so yeah. that's the whole page, every flag, every signature, every parameter, nothing skipped, no cap. if you needed the tl;dr: it's a base class for thread pool serviced serial I/O and it's honestly kind of iconic ✨

and that's a wrap, bestie β€” this lil manual page came out of GNU CommonC++ and got its glow-up dated Sun Dec 27 2020, which is literally when this version of ost::SerialPort(3) was born. slay πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from