Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to write the serial print into a log file. #227

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gustavosr8
Copy link
Contributor

No description provided.

@gustavosr8 gustavosr8 requested a review from augustofg February 5, 2025 20:00
@gustavosr8 gustavosr8 self-assigned this Feb 5, 2025
@gustavosr8 gustavosr8 force-pushed the log-serial branch 3 times, most recently from bb812c2 to a3e00cb Compare February 7, 2025 12:53
Description=Serial Logger Service

[Service]
ExecStart=/usr/local/bin/log-serial.py /var/log/openmmc-serial.log /dev/serial/by-id/%i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log file should also be parametrized with %i

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should add usage of disable-jtag somewhere, right? Or since it doesn't work, should we avoid merging it for now?

Comment on lines +1 to +19
#!/bin/bash

# Check if a serial port argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <serial_port>"
exit 1
fi

SERIAL_PORT=$1

SCRIPT_PATH="log-serial.py"
SERVICE_TEMPLATE="[email protected]"
SERVICE_PATH="/usr/local/lib/systemd/system/[email protected]"
BIN_PATH="/usr/local/bin/log-serial.py"

cp "$SCRIPT_PATH" "$BIN_PATH"
cp "$SERVICE_TEMPLATE" "$SERVICE_PATH"

systemctl enable --now "log-serial@${SERIAL_PORT}.service"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should store this install script, and possibly everything else, in bpm-app, instead of here.

These files are useful for all crates, and it's easier to pull scripts from a single repository than hunting for all necessary ones.

Comment on lines +1 to +7
disable-jtag: disable-jtag.c
gcc -Wall -Wextra -O2 -o disable-jtag disable-jtag.c -lftdi

clean:
rm -f disable-jtag

.PHONY: all clean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disable-jtag: disable-jtag.c
gcc -Wall -Wextra -O2 -o disable-jtag disable-jtag.c -lftdi
clean:
rm -f disable-jtag
.PHONY: all clean
CFLAGS = -Wall -Wextra -O2
LDLIBS = -lftdi
EXE = disable-jtag
.PHONY: all clean
all: $(EXE)
clean:
rm -f $(EXE)

We can use automatic rules here, instead of specifying our own. Even if we couldn't, we should never use gcc in a rule, use $(CC); and rules shouldn't repeat their parameters, they should use $@, $^ and $<, and ideally they should also be more generic. Example of such a rule:

%: %.c
	$(CC) $(CFLAGS) -o $@ $< $(LDLIBS)

.PHONY declared all but it didn't exist.

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