Compare commits
11 Commits
f3ecf22e8e
...
51056e9acf
| Author | SHA1 | Date |
|---|---|---|
|
|
51056e9acf | |
|
|
44e6eb45e3 | |
|
|
9e444073b1 | |
|
|
9d4f3c82a2 | |
|
|
7e8e247b2f | |
|
|
3fe1c42bbf | |
|
|
1520ab5b98 | |
|
|
aa902ae2af | |
|
|
a0b592178e | |
|
|
4f2fdecfba | |
|
|
63500f8dd0 |
|
|
@ -75,7 +75,6 @@ jobs:
|
||||||
gcc \
|
gcc \
|
||||||
gcc-aarch64-linux-gnu \
|
gcc-aarch64-linux-gnu \
|
||||||
gcc-arm-linux-gnueabihf \
|
gcc-arm-linux-gnueabihf \
|
||||||
gcc-mips-linux-gnu \
|
|
||||||
libgps-dev \
|
libgps-dev \
|
||||||
make
|
make
|
||||||
|
|
||||||
|
|
@ -139,13 +138,6 @@ jobs:
|
||||||
podman exec -i stable cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=cmake/${toolchain}.cmake -DENABLE_WERROR=ON -DENABLE_GPS=${gps} -B build-${toolchain}
|
podman exec -i stable cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=cmake/${toolchain}.cmake -DENABLE_WERROR=ON -DENABLE_GPS=${gps} -B build-${toolchain}
|
||||||
podman exec -i stable cmake --build build-${toolchain}
|
podman exec -i stable cmake --build build-${toolchain}
|
||||||
|
|
||||||
- name: Configure & Build with mips-linux-gnu-gcc
|
|
||||||
env:
|
|
||||||
toolchain: mips-linux-gnu-gcc
|
|
||||||
run: |
|
|
||||||
podman exec -i stable cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=cmake/${toolchain}.cmake -DENABLE_WERROR=ON -B build-${toolchain}
|
|
||||||
podman exec -i stable cmake --build build-${toolchain}
|
|
||||||
|
|
||||||
- name: Configure & Build with gcc (Makefile)
|
- name: Configure & Build with gcc (Makefile)
|
||||||
env:
|
env:
|
||||||
cc: gcc
|
cc: gcc
|
||||||
|
|
|
||||||
37
canerrsim.c
37
canerrsim.c
|
|
@ -25,6 +25,7 @@
|
||||||
#include <linux/can/error.h>
|
#include <linux/can/error.h>
|
||||||
#include <linux/can/raw.h>
|
#include <linux/can/raw.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -122,27 +123,25 @@ void show_help_and_exit()
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void err_exit(const char *msg)
|
void __attribute__((format (printf, 1, 2))) err_exit(const char *format, ...)
|
||||||
{
|
{
|
||||||
printf("%s", msg);
|
va_list ap;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_custom_format_and_exit(const char *param, const char *format)
|
va_start(ap, format);
|
||||||
{
|
vfprintf(stdout, format, ap);
|
||||||
char str_buf[80];
|
va_end(ap);
|
||||||
sprintf(str_buf, format, param);
|
|
||||||
err_exit(str_buf);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_invalid_option(const char *option)
|
void show_invalid_option(const char *option)
|
||||||
{
|
{
|
||||||
show_custom_format_and_exit(option, "Error: Invalid option %s\n");
|
err_exit("Error: Invalid option %s\n", option);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_err_and_exit(const char *err_type)
|
void show_err_and_exit(const char *err_type)
|
||||||
{
|
{
|
||||||
show_custom_format_and_exit(err_type, "Error: You can only have one %s parameter!\n");
|
err_exit("Error: You can only have one %s parameter!\n", err_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_loc_err_and_exit()
|
void show_loc_err_and_exit()
|
||||||
|
|
@ -176,7 +175,6 @@ int main(int argc, char *argv[])
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
struct can_frame frame;
|
struct can_frame frame;
|
||||||
bool show_bits = false, location_processed = false, transceiver_processed = false, arbitration_processed = false;
|
bool show_bits = false, location_processed = false, transceiver_processed = false, arbitration_processed = false;
|
||||||
char tmp_str[256];
|
|
||||||
|
|
||||||
printf("CAN Sockets Error Messages Simulator\n");
|
printf("CAN Sockets Error Messages Simulator\n");
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
|
|
@ -537,24 +535,25 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// create socket
|
// create socket
|
||||||
if ((sock = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0)
|
if ((sock = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0)
|
||||||
err_exit("Error while opening socket");
|
err_exit("Error while opening socket\n");
|
||||||
|
|
||||||
// set interface name
|
// set interface name
|
||||||
|
if (strlen(argv[1]) >= IFNAMSIZ)
|
||||||
|
err_exit("Name of CAN device '%s' is too long!\n\n", argv[1]);
|
||||||
|
|
||||||
strcpy(ifr.ifr_name, argv[1]); // can0, vcan0...
|
strcpy(ifr.ifr_name, argv[1]); // can0, vcan0...
|
||||||
if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) {
|
if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0)
|
||||||
sprintf(tmp_str, "Error setting CAN interface name %s", argv[1]);
|
err_exit("Error setting CAN interface name %s\n", argv[1]);
|
||||||
err_exit(tmp_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bind socket to the CAN interface
|
// bind socket to the CAN interface
|
||||||
addr.can_family = AF_CAN;
|
addr.can_family = AF_CAN;
|
||||||
addr.can_ifindex = ifr.ifr_ifindex;
|
addr.can_ifindex = ifr.ifr_ifindex;
|
||||||
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||||
err_exit("Error in socket bind");
|
err_exit("Error in socket bind\n");
|
||||||
|
|
||||||
// Send CAN error frame
|
// Send CAN error frame
|
||||||
if (write(sock, &frame, sizeof(frame)) < 0)
|
if (write(sock, &frame, sizeof(frame)) < 0)
|
||||||
err_exit("Error writing to socket");
|
err_exit("Error writing to socket\n");
|
||||||
else
|
else
|
||||||
printf("CAN error frame sent\n");
|
printf("CAN error frame sent\n");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,205 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "${CANPLAYER}" ]; then
|
||||||
|
CANPLAYER="canplayer"
|
||||||
|
fi
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo "$*" > /dev/stderr
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "canplayer-bisect <start|stop|clean|good|yes|bad|no|again|where|undo> <logfile> <canplayer options>"
|
||||||
|
}
|
||||||
|
|
||||||
|
is_ready() {
|
||||||
|
if [ ! -d .canplayer-bisect ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
is_ready
|
||||||
|
|
||||||
|
LOGFILE=$(cat .canplayer-bisect/logfile |head -n 1)
|
||||||
|
|
||||||
|
SAVED_LEN="$(cat .canplayer-bisect/len|tail -n 1)"
|
||||||
|
LEN="$(wc -l ${LOGFILE} | awk '{ print $1 }')"
|
||||||
|
|
||||||
|
if [ "$LEN" != "$SAVED_LEN" ]; then
|
||||||
|
die "logfile has changed size. restart"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CANPLAYER_ARGS=$(cat .canplayer-bisect/args |head -n 1)
|
||||||
|
|
||||||
|
HEAD="$(cat .canplayer-bisect/head |tail -n 1)"
|
||||||
|
TAIL="$(cat .canplayer-bisect/tail |tail -n 1)"
|
||||||
|
}
|
||||||
|
|
||||||
|
back() {
|
||||||
|
HEAD="$(cat .canplayer-bisect/head |tail -n 2 |head -n1)"
|
||||||
|
TAIL="$(cat .canplayer-bisect/tail |tail -n 2 |head -n1)"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_undo() {
|
||||||
|
sed -i '$ d' .canplayer-bisect/head
|
||||||
|
sed -i '$ d' .canplayer-bisect/tail
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
mkdir -p .canplayer-bisect
|
||||||
|
echo $LEN > .canplayer-bisect/len
|
||||||
|
echo $LOGFILE > .canplayer-bisect/logfile
|
||||||
|
echo $CANPLAYER_ARGS > .canplayer-bisect/args
|
||||||
|
|
||||||
|
echo $HEAD >> .canplayer-bisect/head
|
||||||
|
echo $TAIL >> .canplayer-bisect/tail
|
||||||
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
cat $LOGFILE | sed -n ${HEAD},${TAIL}p
|
||||||
|
}
|
||||||
|
|
||||||
|
play() {
|
||||||
|
#we *could* pipe directly to canplayer, but then the user can't add -l i to CANPLAYER_ARGS to hunt for packets using looped playback
|
||||||
|
the_show="$(mktemp)"
|
||||||
|
trap "rm -rf \"${the_show}\"" EXIT
|
||||||
|
|
||||||
|
show > "${the_show}"
|
||||||
|
"${CANPLAYER}" ${CANPLAYER_ARGS} -I "${the_show}"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_show() {
|
||||||
|
setup
|
||||||
|
|
||||||
|
show
|
||||||
|
}
|
||||||
|
|
||||||
|
check_heads_n_tails() {
|
||||||
|
if [ $HEAD -eq $TAIL ]; then
|
||||||
|
do_stop
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_good() {
|
||||||
|
setup
|
||||||
|
|
||||||
|
check_heads_n_tails
|
||||||
|
|
||||||
|
if [ $(( $HEAD + 1 )) -eq $TAIL ]; then
|
||||||
|
TAIL=$HEAD
|
||||||
|
else
|
||||||
|
TAIL=$(( ( $TAIL - $HEAD ) / 2 + $HEAD - 1 ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
teardown
|
||||||
|
play
|
||||||
|
}
|
||||||
|
|
||||||
|
do_bad() {
|
||||||
|
setup
|
||||||
|
|
||||||
|
check_heads_n_tails
|
||||||
|
|
||||||
|
back
|
||||||
|
if [ $(( $HEAD + 1 )) -eq $TAIL ]; then
|
||||||
|
HEAD=$TAIL
|
||||||
|
else
|
||||||
|
HEAD=$(( ( $TAIL - $HEAD ) / 2 + $HEAD ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
teardown
|
||||||
|
play
|
||||||
|
}
|
||||||
|
|
||||||
|
do_again() {
|
||||||
|
setup
|
||||||
|
play
|
||||||
|
}
|
||||||
|
|
||||||
|
do_start() {
|
||||||
|
do_clean
|
||||||
|
|
||||||
|
LEN="$(wc -l ${LOGFILE} | awk '{ print $1 }')"
|
||||||
|
|
||||||
|
HEAD=1
|
||||||
|
TAIL=$LEN
|
||||||
|
|
||||||
|
echo "assuming logfile contains the packets you seek... bisecting to first half"
|
||||||
|
|
||||||
|
teardown
|
||||||
|
play
|
||||||
|
}
|
||||||
|
|
||||||
|
do_where() {
|
||||||
|
setup
|
||||||
|
echo "between $HEAD and $TAIL (+$(( $TAIL - $HEAD ))) of $LOGFILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_stop() {
|
||||||
|
setup
|
||||||
|
|
||||||
|
if [ "$COMMAND" == "no" ]; then
|
||||||
|
echo "failed to find what you were looking for"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "the packets you seek are:"
|
||||||
|
do_where
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_clean() {
|
||||||
|
rm -rf .canplayer-bisect
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
COMMAND=$1
|
||||||
|
|
||||||
|
if [ ! -d .canplayer-bisect ] && [ ! -z "$2" ] && [ ! -e "$2" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
LOGFILE="$2"
|
||||||
|
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
CANPLAYER_ARGS="$*"
|
||||||
|
|
||||||
|
case "$COMMAND" in
|
||||||
|
start)
|
||||||
|
do_start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
do_stop
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
do_clean
|
||||||
|
;;
|
||||||
|
good|yes)
|
||||||
|
do_good
|
||||||
|
;;
|
||||||
|
bad|no)
|
||||||
|
do_bad
|
||||||
|
;;
|
||||||
|
again)
|
||||||
|
do_again
|
||||||
|
;;
|
||||||
|
where)
|
||||||
|
do_where
|
||||||
|
;;
|
||||||
|
undo)
|
||||||
|
do_undo
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
do_show
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
@ -72,8 +72,7 @@ int mcp251xfd_regmap_read(struct mcp251xfd_priv *priv,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* maybe it's something like "spi0.0" */
|
/* maybe it's something like "spi0.0" */
|
||||||
tmp = strchr(file_path, '/');
|
if (strchr(file_path, '/'))
|
||||||
if (tmp)
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
/* first try literally */
|
/* first try literally */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue