Skip to content

Print serial terminal settings#1827

Open
midouest wants to merge 6 commits into
monome:mainfrom
midouest:serial-print-tio
Open

Print serial terminal settings#1827
midouest wants to merge 6 commits into
monome:mainfrom
midouest:serial-print-tio

Conversation

@midouest

@midouest midouest commented Apr 9, 2025

Copy link
Copy Markdown
Contributor
  • Sets a TerminalIO metatable on the term table passed to handler.configure(term) with a :print() method for printing the current settings. This functions similarly to executing stty -F /path/to/tty -a on the command line.
  • Fixes a small typo in the cc table docs
  • Fixes an off-by-one error when loading the CC values into Lua

Example output of TerminalIO:print():

dev_serial: TTY device Playdate at /dev/ttyACM0 handled by playdate

(before)
speed: 9600 baud
cc: intr=3, quit=28, erase=127, kill=21, eof=4, eol=0, start=17, stop=19, susp=26, min=1, time=0
cflag: -parenb, -parodd, cs8, -hupcl, -cstopb, -cread, -clocal
iflag: -ignbrk, -brkint, -ignpar, -parmrk, -inpck, -istrip, -inlcr, -igncr, -icrnl, -ixon, -ixoff, -iuclc, -ixany, -iutf8
oflag: -opost, -olcuc, -ocrnl, -onlcr, -onocr, -onlret, -ofill, -ofdel, vt0
lflag: -isig, -icanon, -iexten, -echo, -echoe, -echok, -echonl, -noflsh

(after)
speed: 115200 baud
cc: intr=3, quit=28, erase=127, kill=21, eof=4, eol=0, start=17, stop=19, susp=26, min=0, time=5
cflag: -parenb, -parodd, cs8, -hupcl, -cstopb, -cread, -clocal
iflag: -ignbrk, -brkint, -ignpar, -parmrk, -inpck, -istrip, -inlcr, -igncr, icrnl, -ixon, -ixoff, -iuclc, -ixany, -iutf8
oflag: -opost, -olcuc, -ocrnl, -onlcr, -onocr, -onlret, -ofill, -ofdel, vt0
lflag: -isig, -icanon, -iexten, -echo, -echoe, -echok, -echonl, -noflsh

@tlubke

tlubke commented Apr 14, 2025

Copy link
Copy Markdown
Collaborator

Feels a bit heavy for what it's doing. A couple of notes, but will think about this a little bit more too.

  • TerminalIO isn't named very Lua-like.
  • Probably don't need TerminalIO:print() since __tostring() is already set in the metatable.
  • In the __tostring() method, I wonder if there is a clever way to make use of the existing tables instead of creating more.
  • I think making output closer to the tables/variables in the serial module makes more sense than making output match stty.
  • If you want to make a separate PR for the two fixes, I don't see a problem with those being merged right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants