This project is a networked game platform running on embedded Linux devices, such as Raspberry Pi, using GPIO and I2C interfaces. The platform includes a server and client implementation for playing a game of Rock, Paper, Scissors between two devices. Additionally, a REST API is provided for accessing game results stored in a CSV file.
- Server and Client Communication: The server and client communicate over TCP/IP to play Rock, Paper, Scissors.
- Game Logging: Game results, including the choices and outcome, are logged in a CSV file (
results.csv). - REST API: A simple REST API is provided to retrieve all logged game results.
- GPIO and I2C Integration: The project integrates with GPIO and I2C interfaces, making it suitable for hardware interaction on embedded systems.
- Per-Axis Control: The
per_axis.cfile likely handles specific controls or computations related to individual axes, potentially for sensors or other peripherals.
main.c: The entry point for the application. It determines whether to run in server or client mode.source/: Contains the implementation files for the different modules:file_helper.c: Provides functions for reading and writing game results to a CSV file.per_axis.c: Manages operations or calculations on a per-axis basis, which might relate to sensor data or motor control.rest_controller.c: Implements the REST API for retrieving game results.step_controller.c: Controls the game flow.tcp_helper.c: Manages TCP communication.
header/: Contains header files with function declarations and constants used across the project.log/: Stores theresults.csvfile where game results are logged.doc/: Contains documentation for the project, providing detailed explanations and guides.
Before building and running the project, ensure you have the following dependencies installed:
sudo apt-get install gpiod libgpiod-dev
sudo apt-get install libi2c-dev i2c-tools
sudo apt-get install libmicrohttpd-dev-
Create the Build Directory (if not already present):
mkdir build && mkdir log cd build
-
Configure and Build the Project:
cmake .. make clean && make
-
Start the Server:
- Run the server on the device that will act as the host (e.g.,
146.136.88.38):
./EmbLinux_Project server
- Run the server on the device that will act as the host (e.g.,
-
Start the REST API:
- The server will also start a REST API on port
8080that you can use to query game results.
- The server will also start a REST API on port
-
Start the Client:
- On another device, start the client and connect to the server using its IP address:
./EmbLinux_Project client 146.136.88.38
- First, start the server program on the server device.
- Then, start the client program on the client device.
- The client and server will communicate to play a game of Rock, Paper, Scissors. The results will be logged in
results.csv. - You can retrieve the results using the REST API by accessing
http://<server-ip>:8080/.
To free ports 8888 and 8080 before running the server and client:
sudo lsof -t -i:8888 | xargs sudo kill && sudo lsof -t -i:8080 | xargs sudo killTo test the TCP connection on port 8888:
nc 146.136.88.38 8888For reference, the IP addresses of the devices in your setup are:
146.136.88.38- SvA (Server)146.136.88.26- RC (Client)146.136.90.42- SvA Host
sudo apt-get install gpiod libgpiod-dev
sudo apt-get install libi2c-dev i2c-tools
sudo apt-get install libmicrohttpd-dev./EmbLinux_Project client 146.136.88.38sudo lsof -t -i:8888 | xargs sudo kill && sudo lsof -t -i:8080 | xargs sudo killnc 146.136.88.38 8888