-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added shell script to make vcan can0 interface for testing without ha…
…rdware can Signed-off-by: Daisuke Sato <[email protected]>
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Root privileges are required to run this script | ||
if [ "$EUID" -ne 0 ]; then | ||
echo "This script requires root privileges to execute." | ||
echo "Please rerun it using sudo." | ||
exit 1 | ||
fi | ||
|
||
# Load the vcan module | ||
echo "Loading the vcan module..." | ||
modprobe vcan | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to load the vcan module. Please check the kernel module." | ||
exit 1 | ||
fi | ||
|
||
# Check if 'can0' already exists | ||
if ip link show can0 &>/dev/null; then | ||
echo "The virtual CAN interface 'can0' already exists. Skipping creation." | ||
else | ||
# Create the virtual CAN interface | ||
echo "Creating the virtual CAN interface 'can0'..." | ||
ip link add dev can0 type vcan | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to create the virtual CAN interface 'can0'." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Enable the virtual CAN interface | ||
echo "Enabling the virtual CAN interface 'can0'..." | ||
ip link set up can0 | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to enable the virtual CAN interface 'can0'." | ||
exit 1 | ||
fi | ||
|
||
echo "The virtual CAN interface 'can0' is now set up and configured." | ||
echo "Verification command: ip link show can0" |