Skip to content

OIL 41, chapter Functions: host code written out twice is one function - #125

Merged
theAndreas merged 2 commits into
mainfrom
oil-41-functions-copies
Nov 17, 2026
Merged

theAndreas merged 2 commits into
mainfrom
oil-41-functions-copies

Conversation

@theAndreas

Copy link
Copy Markdown
Owner

Nothing changes for a sketch or for whoever uses the simulator or the control program: the same commands, the same messages, the same exit codes. The library is untouched, and every example has the same flash and RAM as on main.

The second pull request of the review of the chapter Functions in OIL item 41, for FN-13 of the coding style: what the host code did alike in two or more places is one function now, so that a fix to it is made once.

  • The control program's serial port on Linux and its TCP port shared the loops that send all and read what has arrived, copied with the system calls changed.
  • Both simulators, on the host and for the .elf, started and ended a run the same way: the pins and length of the chain every example has, the command line, the result and the exit code.
  • A whole file was read the same way for the page and for --expect; whether a connection is gone was tested the same way in both hosts; the window made the same line from its fields in two places each; the front end said a port is taken twice; DocuPictures wrote its pattern and the panel's height more than once.

Left as they are, with the reason in OIL.md: the two hosts' start, one shared call and a check; their accept loops, whose bodies differ; and the simulator's seven registrations with simavr, which a helper would only turn into two numbers side by side that a caller could swap.

Checked:

  • make check passes: lint, clang-tidy, every host and AVR test, coverage at 100 % of lines, branches and conditions; the simulator's and the control program's own tests run the changed code.
  • The control program's Windows half was not compiled: there is no MinGW in the dev container now; there it only takes the chunk length from the shared header.
  • Not run on hardware; the library does not change.

The loops that send all and read what has arrived, of the control
program's serial port on Linux and its TCP port, are ControlStream's. How a
run of either simulator starts and ends, with the chain every example has
and the exit codes, is SimulatorRun's; reading a whole file, for the page
and --expect, SimulatorFile's; and the test whether a connection is gone
SimulatorSocket's, for both hosts. The window makes each line from its
fields in one place, the front end says a port is taken in one, and
DocuPictures has its pattern and the panel's height once.

Left as they are, with the reason in OIL.md: the hosts' Begin(), the
accept loops and SimulatorAvr's notifies. The library and its sizes do not
change.
@theAndreas
theAndreas merged commit 656b7b4 into main Nov 17, 2026
12 checks passed
@theAndreas
theAndreas deleted the oil-41-functions-copies branch November 17, 2026 14:44
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.

2 participants