tree: 0fbc1fced120a490e761bcd58d1ccb9b2f0ce13e [path history] [tgz]
  1. logging/
  2. aos.json
  3. aos_logging.cc
  4. aos_logging.h
  5. aos_timing_report_streamer.cc
  6. BUILD
  7. channel_preallocated_allocator.h
  8. context.h
  9. epoll.cc
  10. epoll.h
  11. epoll_test.cc
  12. event_loop.cc
  13. event_loop.fbs
  14. event_loop.h
  15. event_loop_event.h
  16. event_loop_param_test.cc
  17. event_loop_param_test.h
  18. event_loop_runtime.cc
  19. event_loop_runtime.h
  20. event_loop_runtime.rs
  21. event_loop_runtime_test.cc
  22. event_loop_runtime_test_lib.rs
  23. event_loop_tmpl.h
  24. event_scheduler.cc
  25. event_scheduler.h
  26. event_scheduler_test.cc
  27. function_scheduler.cc
  28. function_scheduler.h
  29. glib_main_loop.cc
  30. glib_main_loop.h
  31. glib_main_loop_test.cc
  32. message_counter.h
  33. multinode_pingpong.json
  34. multinode_pingpong_test_combined.json
  35. multinode_pingpong_test_split.json
  36. ping.cc
  37. ping.fbs
  38. ping.rs
  39. ping_lib.cc
  40. ping_lib.h
  41. ping_lib.rs
  42. pingpong.json
  43. pingpong_test.cc
  44. pingpong_test.rs
  45. pong.cc
  46. pong.fbs
  47. pong.rs
  48. pong_lib.cc
  49. pong_lib.h
  50. pong_lib.rs
  51. README.md
  52. shm_event_loop.cc
  53. shm_event_loop.h
  54. shm_event_loop.rs
  55. shm_event_loop_for_rust.h
  56. shm_event_loop_test.cc
  57. simple_channel.cc
  58. simple_channel.h
  59. simulated_event_loop.cc
  60. simulated_event_loop.h
  61. simulated_event_loop.rs
  62. simulated_event_loop_for_rust.h
  63. simulated_event_loop_test.cc
  64. simulated_network_bridge.cc
  65. simulated_network_bridge.h
  66. test_message.fbs
  67. timing_report_dump.cc
  68. timing_report_dump_lib.cc
  69. timing_report_dump_lib.h
  70. timing_statistics.cc
  71. timing_statistics.h
  72. timing_statistics_test.cc
aos/events/README.md

How to run ping & pong

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

Set up real-time niceties:

  1. Add the following lines to /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
  1. Reboot your machine to pick up the changes

Compile and run the code

  1. Compile the code for ping and pong, as well as aos_dump for looking at the messages. We'll assume throughout that you're running from the top level directory of the 971 code.
bazel build -c opt //aos/events:ping //aos/events:pong //aos:aos_dump
  1. 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

  2. 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'

Logging

In addition to running ping and pong, this is a good example to explore event logging.

  1. Start by compiling the code:
bazel build -c opt //aos/events/logging:logger_main
  1. Create a folder for the log files, e.g.,
mkdir /tmp/log_folder
  1. Run the command to log the data:
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.

  1. View the contents of the log file (using log_cat functionality found in the logging sub-directory):

    1. Compile log_cat:
    bazel build -c opt //aos/events/logging:log_cat
    
    1. Run the binary pointed at the recorded event log (this assumes you're running from the base directory of the repository and that the file is named fbs_log-001.bfbs):
    bazel-bin/aos/events/logging/log_cat /tmp/log_folder/fbs_log-001.bfbs
    

EXERCISE:

  1. Modify code in ping and pong to see a difference in their behavior, e.g., increment the counter by 2's instead of 1