Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Propulsive-Landing/ferda int…
Browse files Browse the repository at this point in the history
…o dev
  • Loading branch information
UConnAIAA committed Sep 21, 2024
2 parents 2094a13 + a15ba02 commit 7bc4354
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,86 @@ Create features in branches created from dev branch. When feature is complete, m
3. Run `sudo apt install libeigen3-dev`
4. Build the repo (make sure you're in debug or release mode depending on which one you need)
5. Run the executable that gets created in the `build/` folder


## Hardware Config

### Device Symbolic Linking
1. Create a Shell Script
First, create a shell script that will perform the device detection and symbolic link creation.

Script: `/home/pi/link_iio_devices.sh`

```
#!/bin/bash
# Define the home directory for symbolic links
HOME_DIR="/home/your_username"
# Define the symbolic links
IMU_LINK="${HOME_DIR}/imu_device"
BAROMETER_LINK="${HOME_DIR}/barometer_device"
GYROSCOPE_LINK="${HOME_DIR}/gyroscope_device"
# Remove old links if they exist
rm -f "$IMU_LINK" "$BAROMETER_LINK" "$GYROSCOPE_LINK"
# Iterate over the IIO device directories
for device in /sys/bus/iio/devices/iio:device*; do
if [[ -d "$device" ]]; then
if [[ -f "$device/in_accel_scale_available" ]]; then
ln -s "$device" "$IMU_LINK"
echo "IMU device found: $device"
elif [[ -f "$device/in_temp_scale" ]]; then
ln -s "$device" "$BAROMETER_LINK"
echo "Barometer device found: $device"
elif [[ -f "$device/in_anglvel_scale" ]]; then
ln -s "$device" "$GYROSCOPE_LINK"
echo "Gyroscope device found: $device"
fi
fi
```

2. Make the Script Executable
Run the following command to make the script executable:

```
sudo chmod +x /usr/local/bin/link_iio_devices.sh
```

3. Create the Systemd Service File
Next, create a systemd service file to run this script at startup.

Service File: /etc/systemd/system/link_iio_devices.service

```
[Unit]
Description=Link IIO Devices
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/link_iio_devices.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
```

4. Enable the Systemd Service
Enable the service so that it runs at startup:

```
sudo systemctl enable link_iio_devices.service
```

5. Start the Service (Optional)
You can start the service immediately (for testing purposes) using:

```
sudo systemctl start link_iio_devices.service
```

Home Directory: Replace `pi` in the script with the actual username or adjust the home directory path as needed.
Permissions: Ensure that your user has permission to create symbolic links in the specified home directory.
Testing: After creating the service, you can check the status with sudo systemctl status link_iio_devices.service to see if it executed successfully.

0 comments on commit 7bc4354

Please sign in to comment.