Compare commits
10 Commits
f3ecf22e8e
...
51056e9acf
| Author | SHA1 | Date |
|---|---|---|
|
|
51056e9acf | |
|
|
44e6eb45e3 | |
|
|
9e444073b1 | |
|
|
9d4f3c82a2 | |
|
|
7e8e247b2f | |
|
|
3fe1c42bbf | |
|
|
1520ab5b98 | |
|
|
aa902ae2af | |
|
|
a0b592178e | |
|
|
4f2fdecfba |
|
|
@ -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");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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