This project implements a sensor simulation system with the following components:
- Sensor Device Simulator: Generates random temperature readings every 500 milliseconds.
- Data Logger: Periodically writes sensor data to a log file every 2 seconds.
- Command Interface: Allows external interaction via a Unix socket, supporting
GETandSTOPcommands.
- Requirements for each submodule:
- Sensor Device Simulator:
- Runs in a separate thread and generates random temperature readings (e.g., between -50°C and 150°C) every 500 milliseconds. The generated data should be stored in a shared buffer (e.g., a queue protected by a mutex).
- Data Logger:
- Runs in another separate thread and periodically writes sensor data to a log file "sensor_log.txt" every 2 seconds. It should append new readings without overwriting previous data.
- Command Interface via Unix Socket:
- Listens on a socket "/tmp/sensor_socket"
- Accepts the following commands:
- GET: Returns the last five temperature readings
- STOP: Stops the simulation gracefully
- Bash Script for Automation:
- Compiles the program: Runs the test scenarios and summarize the results
- Create a build directory:
mkdir -p build
- Go to the build folder
cd build - Run the CMake
cmake ..
- Build project
make ..
- To run the main program(simulates the data)
./sensor_logger_simulator- Open a new terminal and run this command after running the previous command for about 3 seconds
./scripts/test_commands.sh GET- Stopping the simulation data stream
./scripts/test_commands.sh STOP- Run the automation script (Make sure that this is done after running sensor
./scripts/automation_script.sh