sergensio_baud.3(3)

πŸ“¦
version 2.8.15 Β· 2 versions
  • 2.8.15 Β· alpine 3.22, alpine 3.23, alpine 3.24, debian bookworm, debian trixie, epel 9, fedora 43, opensuse-leap 16.0, ubuntu noble, ubuntu questing (latest)
  • 2.3.5 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, debian bookworm, debian trixie, epel 9, fedora 43, opensuse-leap 16.0, ubuntu noble, ubuntu questing

πŸ’– NAME πŸ’–

sergensio_baud, sergensio_datasize, sergensio_parity, sergensio_stopbits, sergensio_flowcontrol, sergensio_iflowcontrol, sergensio_sbreak, sergensio_dtr, sergensio_rts, sergensio_signature, sergensio_linestate, sergensio_modemstate, sergensio_flowcontrol_state, sergensio_flush, sergensio_send_break β€” Control serial parameters on a sergensio πŸŽ€

So bestie, this is the sergensio_baud.3(3) page, living in the Library Functions Manual. It's literally a whole crew of functions that all hang out together and fiddle with serial port settings. Obsessed. Let's get into it. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gensio/sergensio.h>

typedef void (*sergensio_done)(struct sergensio *sio, int err,
                    unsigned int val, void *cb_data);

typedef void (*sergensio_done_sig)(struct sergensio *sio, int err,
                    const char *sig, unsigned int len,
                    void *cb_data);

int sergensio_baud(struct sergensio *sio, unsigned int baud,
                    sergensio_done done, void *cb_data);

int sergensio_datasize(struct sergensio *sio, unsigned int datasize,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_PARITY_NONE
#define SERGENSIO_PARITY_ODD
#define SERGENSIO_PARITY_EVEN
#define SERGENSIO_PARITY_MARK
#define SERGENSIO_PARITY_SPACE

int sergensio_parity(struct sergensio *sio, unsigned int parity,
                    sergensio_done done, void *cb_data);

int sergensio_stopbits(struct sergensio *sio, unsigned int stopbits,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_FLOWCONTROL_NONE
#define SERGENSIO_FLOWCONTROL_XON_XOFF
#define SERGENSIO_FLOWCONTROL_RTS_CTS

int sergensio_flowcontrol(struct sergensio *sio,
                    unsigned int flowcontrol,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_FLOWCONTROL_DCD
#define SERGENSIO_FLOWCONTROL_DTR
#define SERGENSIO_FLOWCONTROL_DSR

int sergensio_iflowcontrol(struct sergensio *sio,
                    unsigned int iflowcontrol,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_BREAK_ON
#define SERGENSIO_BREAK_OFF

int sergensio_sbreak(struct sergensio *sio, unsigned int breakv,
                    sergensio_done done, void *cb_data);

int sergensio_send_break(struct sergensio *sio);

#define SERGENSIO_DTR_ON
#define SERGENSIO_DTR_OFF

int sergensio_dtr(struct sergensio *sio, unsigned int dtr,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_RTS_ON
#define SERGENSIO_RTS_OFF

int sergensio_rts(struct sergensio *sio, unsigned int rts,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_CTS_AUTO
#define SERGENSIO_CTS_OFF

int sergensio_cts(struct sergensio *sio, unsigned int cts,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_DCD_DSR_ON
#define SERGENSIO_DCD_DSR_OFF

int sergensio_dcd_dsr(struct sergensio *sio, unsigned int dcd_dsr,
                    sergensio_done done, void *cb_data);

#define SERGENSIO_RI_ON
#define SERGENSIO_RI_OFF

int sergensio_ri(struct sergensio *sio, unsigned int ri,
                    sergensio_done done, void *cb_data);

int sergensio_signature(struct sergensio *sio,
                    const char *sig, unsigned int len,
                    sergensio_done_sig done, void *cb_data);

#define SERGENSIO_LINESTATE_DATA_READY
#define SERGENSIO_LINESTATE_OVERRUN_ERR
#define SERGENSIO_LINESTATE_PARITY_ERR
#define SERGENSIO_LINESTATE_FRAMING_ERR
#define SERGENSIO_LINESTATE_BREAK
#define SERGENSIO_LINESTATE_XMIT_HOLD_EMPTY
#define SERGENSIO_LINESTATE_XMIT_SHIFT_EMPTY
#define SERGENSIO_LINESTATE_TIMEOUT_ERR

int sergensio_linestate(struct sergensio *sio, unsigned int linestate);

#define SERGENSIO_MODEMSTATE_CTS_CHANGED
#define SERGENSIO_MODEMSTATE_DSR_CHANGED
#define SERGENSIO_MODEMSTATE_RI_CHANGED
#define SERGENSIO_MODEMSTATE_CD_CHANGED
#define SERGENSIO_MODEMSTATE_CTS
#define SERGENSIO_MODEMSTATE_DSR
#define SERGENSIO_MODEMSTATE_RI
#define SERGENSIO_MODEMSTATE_CD

int sergensio_modemstate(struct sergensio *sio,
                    unsigned int modemstate);

int sergensio_flowcontrol_state(struct sergensio *sio, bool val);

#define SERGENSIO_FLUSH_RCV_BUFFER
#define SERGENSIO_FLUSH_XMIT_BUFFER
#define SERGENSIO_FLUSH_RCV_XMIT_BUFFERS

int sergensio_flush(struct sergensio *sio, unsigned int val);

int sergensio_send_break(struct sergensio *sio);

🌸 DESCRIPTION 🌸

Handle various serial port functions. That's the whole vibe. It's the toolbox, bestie. 🧰

✨ SERIAL PORT CONTROLS ✨

Okay so on a client sergensio, all these functions set various settings on the serial port. Important: the setting is not necessarily applied right away, because it might have to get sent as a message first. It's giving "I'll get to it." 😌

If you hand it a done function, that function gets called once the set operation is known to be complete. And heads up β€” the set operation may not work at all (the hardware might just not support it, etc.), and in that case your done function will report the current value of the setting back to you. So always check. πŸ‘‘

If you only want the current value of a setting and don't wanna change anything? Just pass in a zero to any of the functions below and it'll just report the value through the done function. No cap, that's the whole trick. πŸ’…

There are blocking functions for all of these β€” go read sergensio_b_alloc(3) for the details on those. The ones on this page are all non-blocking. ⚑

  • sergensio_baud β€” Set the baud rate to the integer value. Not every system and not every piece of hardware supports every baud rate, so fr fr check the done function to see what the baud rate actually got set to. πŸ™ˆ
  • sergensio_datasize β€” Set the data size; 5, 6, 7, 8 are supported.
  • sergensio_parity β€” Set the parity value.
  • sergensio_stopbits β€” Set the number of stop bits, either 1 or 2.
  • sergensio_flowcontrol β€” Set the outgoing flow-control type.
  • sergensio_iflowcontrol β€” Set the incoming flow control type.
  • sergensio_sbreak β€” Turn on or off the break signal.
  • sergensio_dtr β€” Set the DTR value.
  • sergensio_rts β€” Set the RTS value.
  • sergensio_send_break β€” Send a break signal (on for a bit then off) on the line.

On a server gensio, those same functions up there are used to respond to an event that's setting the value. So you pass in the actual value. The done value is ignored on the server side. It said what it said. 🀷

And on a connection that's on the modem side of the serial port (like ipmisol), there's a whole different set of control commands, and the ones above may or may not work. 😭

Instead, use these. And lowkey watch out: passing 0 to these may or may not return the current value β€” they might just return an error. 🫠

  • sergensio_cts β€” Set the CTS value to auto (managed by the hardware) or off (tell the other end not to send d<ata).
  • sergensio_dcd_rts β€” Set the DCD and RTS value to be enabled or disabled.
  • sergensio_ri β€” Set the ring indicator value to be enabled or disabled.

πŸŽ€ SIGNATURE πŸŽ€

So this isn't really part of serial port control, but the telnet RFC2217 spec has a signature that can be used to identify the server. The sergensio_signature function fetches that signature (on the client side) or responds to a request for the signature (on the server side). Main character energy for a little string of bytes, honestly. πŸ¦‹

⭐ STATE FUNCTIONS ⭐

On the client side, the serial port state functions set the state info you are interested in receiving. For instance, if the user wants to know about parity errors, they could set SERGENSIO_LINESTATE_OVERRUN_ERR in the linestate and they'd receive linestate events with parity errors. Slay. πŸ’–

On the server side, these are used to report state information. And ngl, the gensio itself doesn't track what the client has requested β€” that is up to the server code itself. So that's on you, bestie. πŸ‘‘

  • sergensio_linestate β€” Various information (mostly error) about what has happened on the serial line. Not all sergensios support requesting this information.
  • sergensio_modemstate β€” CTS, DSR, RI, and CD line on the serial port. On the client side, the user should set what values they want to receive with those _CHANGED values. The other values are ignored on the client side. On the server side, this is used to report current values and which values have changed to cause the report.

🌈 OTHER SERIAL PORT CONTROLS 🌈

These functions do other miscellaneous functions on a serial port. The little side quests. 🧚

  • sergensio_flowcontrol_state β€” Tell the remote end of the serial port to stop sending using flow control.
  • sergensio_flush β€” Flush all data from buffers to the serial port.
  • sergensio_send_break β€” Send a short break signal on the serial port. The length is implementation dependent.

πŸ’œ RETURN VALUES πŸ’œ

Zero is returned on success, or a gensio error on failure. That's it, that's the tea. β˜•


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Corey Minyard <minyard@acm.org> β€” thank you for your service, legend. 🫢


okay bestie that's the whole page, mwah πŸ’‹ This was the Library Functions Manual entry sergensio_baud.3(3), dated 20 Jul 2020 β€” yes she's vintage, and she still ate. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from