mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
can: make integration test find vcan interface automatically
This commit is contained in:
parent
a0c7876d74
commit
d8795655e4
1 changed files with 79 additions and 8 deletions
|
@ -21,29 +21,100 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##################################################################################
|
||||
# To set up vcan interface use the following commands
|
||||
# sudo modprobe vcan
|
||||
# sudo ip link add dev vcan0 type vcan
|
||||
# sudo ip link set vcan0 up
|
||||
|
||||
SCRIPT=$(realpath $0)
|
||||
SCRIPTPATH=$(dirname ${SCRIPT})
|
||||
source ${SCRIPTPATH}/../../tools/villas-helper.sh
|
||||
|
||||
CONFIG_FILE=${SCRIPTPATH}/../../etc/examples/nodes/can.conf
|
||||
CONFIG_FILE=$(mktemp)
|
||||
INPUT_FILE=$(mktemp)
|
||||
OUTPUT_FILE=$(mktemp)
|
||||
CAN_OUT_FILE=$(mktemp)
|
||||
CAN_IF=vcan0
|
||||
|
||||
NUM_SAMPLES=${NUM_SAMPLES:-10}
|
||||
NUM_VALUES=${NUM_VALUES:-3}
|
||||
|
||||
# Check if vcan0 interface is present
|
||||
if [[ ! $(ip link show "${CAN_IF}" up) ]]; then
|
||||
echo "Did not find any vcan interface ${CAN_IF} or interface is not up"
|
||||
CAN_IF=$(ip link show type vcan | head -n1 | awk '{match($2, /(.*):/,a)}END{print a[1]}')
|
||||
|
||||
if [[ ! ${CAN_IF} ]]; then
|
||||
echo "Did not find any vcan interface"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
#sudo modprobe vcan
|
||||
#sudo ip link add dev vcan0 type vcan
|
||||
#sudo ip link set vcan0 up
|
||||
# Check if vcan0 interface is present
|
||||
if [[ ! $(ip link show "${CAN_IF}" up) ]]; then
|
||||
echo "Interface ${CAN_IF} is not up"
|
||||
exit 99
|
||||
fi
|
||||
|
||||
cat > ${CONFIG_FILE} << EOF
|
||||
nodes = {
|
||||
can_node1 = {
|
||||
type = "can"
|
||||
interface_name = "${CAN_IF}"
|
||||
sample_rate = 500000
|
||||
|
||||
in = {
|
||||
signals = (
|
||||
{
|
||||
name = "sigin1",
|
||||
unit = "Volts",
|
||||
type = "float",
|
||||
enabled = true,
|
||||
can_id = 66,
|
||||
can_size = 4,
|
||||
can_offset = 0
|
||||
},
|
||||
{
|
||||
name = "sigin2",
|
||||
unit = "Volts",
|
||||
type = "float",
|
||||
enabled = true,
|
||||
can_id = 66,
|
||||
can_size = 4,
|
||||
can_offset = 4
|
||||
},
|
||||
{
|
||||
name = "sigin3",
|
||||
unit = "Volts",
|
||||
type = "float",
|
||||
enabled = true,
|
||||
can_id = 67,
|
||||
can_size = 8,
|
||||
can_offset = 0
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
out = {
|
||||
signals = (
|
||||
{
|
||||
type = "float",
|
||||
can_id = 66,
|
||||
can_size = 4,
|
||||
can_offset = 0
|
||||
},
|
||||
{
|
||||
type = "float",
|
||||
can_id = 66,
|
||||
can_size = 4,
|
||||
can_offset = 4
|
||||
},
|
||||
{
|
||||
type = "float",
|
||||
can_id = 67,
|
||||
can_size = 8,
|
||||
can_offset = 0
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Generate test data
|
||||
VILLAS_LOG_PREFIX=$(colorize "[Signal]") \
|
||||
|
|
Loading…
Add table
Reference in a new issue