Running ping<->pong is a nice way to test that you can run some basic code and shows how messaging can work between two nodes
/etc/security/limits.d/rt.conf
, replacing "USERNAME" with the username you're running under. You'll probably need to do this as root, e.g., sudo nano /etc/security/limits.d/rt.conf
USERNAME - nice -20 USERNAME - rtprio 95 USERNAME - memlock unlimited
bazel build -c opt //aos/events:ping //aos/events:pong //aos:aos_dump
In 2 separate windows, run the ping and pong commands using the pingpong_config.json
config file: 1. bazel-bin/aos/events/ping --config bazel-bin/aos/events/pingpong_config.json
2. bazel-bin/aos/events/pong --config bazel-bin/aos/events/pingpong_config.json
In a third window, explore the message stream using aos_dump
. Some things you can do: 1. List the channels: bazel-bin/aos/aos_dump --config bazel-bin/aos/events/pingpong_config.json
2. Listen to a specific topic on a channel-- copy one of the channels listed in the first step and put it at the end of the aos_dump command (e.g., "/test aos.examples.Ping") bazel-bin/aos/aos_dump --config bazel-bin/aos/events/pingpong_config.json /test aos.examples.Ping
3. Listen to multiple topics on a channel (e.g., all the topics published on "/test") bazel-bin/aos/aos_dump --config bazel-bin/aos/events/pingpong_config.json /test
NOTE: To make life easier, you can alias aos_dump
to include the path and the config file (you may want to specify the full path to the aos_dump executable so it can be run from anywhere)
alias aos_dump='bazel-bin/aos/aos_dump --config bazel-bin/aos/events/pingpong_config.json'
In addition to running ping and pong, this is a good example to explore event logging.
bazel build -c opt //aos/events/logging:logger_main
mkdir /tmp/log_folder
bazel-bin/aos/events/logging/logger_main --config bazel-bin/aos/events/pingpong_config.json --logging_folder /tmp/log_folder/
A log file should be created in /tmp/log_folder, with a name something like fbs_log-001.bfbs
.
If you're running ping and pong at the same time, you should be able to watch the log file grow in size as events are being logged. For example, running ls -lh /tmp/log_folder/*
will list the files and their sizes. Doing this periodically (e.g., every 15-30 seconds) should show the new log file growing in size.
View the contents of the log file (using log_cat
functionality found in the logging
sub-directory):
log_cat
:bazel build -c opt //aos/events/logging:log_cat
fbs_log-001.bfbs
):bazel-bin/aos/events/logging/log_cat /tmp/log_folder/fbs_log-001.bfbs