forked from RCMast3r/data_acq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
got socketcan working with detection of can device
- Loading branch information
Showing
3 changed files
with
56 additions
and
20 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,13 @@ | ||
#!/bin/bash | ||
|
||
# Check if can0 is already down | ||
if ! ip link show up | grep -q can0; then | ||
echo "can0 is already down." | ||
else | ||
echo "Bringing down can0..." | ||
|
||
# Bring down can0 interface | ||
sudo ip link set down can0 | ||
|
||
echo "can0 has been brought down." | ||
fi |
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
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,20 @@ | ||
#!/bin/bash | ||
|
||
# Check if can0 is up | ||
if ! ip link show up | grep -q can0; then | ||
echo "Bringing up can0..." | ||
|
||
# Load CAN related modules | ||
sudo modprobe can | ||
sudo modprobe can_raw | ||
|
||
# Set the bitrate for can0 | ||
sudo ip link set can0 type can bitrate 5000000 | ||
|
||
# Bring up can0 interface | ||
sudo ip link set up can0 | ||
|
||
echo "can0 setup complete." | ||
else | ||
echo "can0 is already up." | ||
fi |