diff --git a/.gitignore b/.gitignore index b0a5de7..9930e37 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ fuzzer **/*.cache **/build **/sdkconfig* +release/ diff --git a/release/iso14229.c b/release/iso14229.c index ee3d88d..d870732 100644 --- a/release/iso14229.c +++ b/release/iso14229.c @@ -1043,7 +1043,7 @@ static uint8_t decodeAddressAndLength(UDSReq_t *r, uint8_t *const buf, void **me assert(r); assert(memoryAddress); assert(memorySize); - long long unsigned int tmp = 0; + uintptr_t tmp = 0; *memoryAddress = 0; *memorySize = 0; @@ -2090,7 +2090,7 @@ static int SetupSocketCAN(const char *ifname) { return sockfd; } -uint32_t isotp_user_get_ms() { return UDSMillis(); } +uint32_t isotp_user_get_ms(void) { return UDSMillis(); } void isotp_user_debug(const char *message, ...) { va_list args; @@ -2114,13 +2114,6 @@ int isotp_user_send_can(const uint32_t arbitration_id, const uint8_t *data, cons return ISOTP_RET_OK; } -static void printhex(const uint8_t *addr, int len) { - for (int i = 0; i < len; i++) { - printf("%02x,", addr[i]); - } - printf("\n"); -} - static void SocketCANRecv(UDSTpISOTpC_t *tp) { assert(tp); struct can_frame frame = {0}; @@ -2238,7 +2231,7 @@ static ssize_t isotp_c_socketcan_tp_peek(UDSTpHandle_t *hdl, uint8_t **p_buf, UD } fprintf(stdout, "%06d, %s recv, 0x%03x (%s), ", UDSMillis(), tp->tag, ta, ta_type == UDS_A_TA_TYPE_PHYSICAL ? "phys" : "func"); - for (unsigned i = 0; i < ret; i++) { + for (int i = 0; i < ret; i++) { fprintf(stdout, "%02x ", (*p_buf)[i]); } fprintf(stdout, "\n"); @@ -2627,7 +2620,7 @@ static void LogMsg(const char *prefix, const uint8_t *buf, size_t len, UDSSDU_t fflush(LogFile); // flush every time in case of crash } -static void NetworkPoll() { +static void NetworkPoll(void) { for (unsigned i = 0; i < MsgCount; i++) { struct Msg *msg = &msgs[i]; if (UDSTimeAfter(UDSMillis(), msg->scheduled_tx_time)) { diff --git a/release/iso14229.h b/release/iso14229.h index 6505996..b4fe37a 100644 --- a/release/iso14229.h +++ b/release/iso14229.h @@ -81,7 +81,7 @@ typedef SSIZE_T ssize_t; #include #include -#define UDS_TP UDS_TP_ISOTP_C +#define UDS_TP_ISOTP_C 1 #define UDS_ENABLE_DBG_PRINT 1 #define UDS_ENABLE_ASSERT 1 diff --git a/src/server.c b/src/server.c index 73d115a..db97c08 100644 --- a/src/server.c +++ b/src/server.c @@ -178,7 +178,7 @@ static uint8_t decodeAddressAndLength(UDSReq_t *r, uint8_t *const buf, void **me assert(r); assert(memoryAddress); assert(memorySize); - long long unsigned int tmp = 0; + uintptr_t tmp = 0; *memoryAddress = 0; *memorySize = 0; diff --git a/src/sys_esp32.h b/src/sys_esp32.h index 39afafa..ccb41e1 100644 --- a/src/sys_esp32.h +++ b/src/sys_esp32.h @@ -6,7 +6,7 @@ #include #include -#define UDS_TP UDS_TP_ISOTP_C +#define UDS_TP_ISOTP_C 1 #define UDS_ENABLE_DBG_PRINT 1 #define UDS_ENABLE_ASSERT 1 diff --git a/src/tp/isotp_c_socketcan.c b/src/tp/isotp_c_socketcan.c index d8d808c..4a569b3 100644 --- a/src/tp/isotp_c_socketcan.c +++ b/src/tp/isotp_c_socketcan.c @@ -38,7 +38,7 @@ static int SetupSocketCAN(const char *ifname) { return sockfd; } -uint32_t isotp_user_get_ms() { return UDSMillis(); } +uint32_t isotp_user_get_ms(void) { return UDSMillis(); } void isotp_user_debug(const char *message, ...) { va_list args; @@ -62,13 +62,6 @@ int isotp_user_send_can(const uint32_t arbitration_id, const uint8_t *data, cons return ISOTP_RET_OK; } -static void printhex(const uint8_t *addr, int len) { - for (int i = 0; i < len; i++) { - printf("%02x,", addr[i]); - } - printf("\n"); -} - static void SocketCANRecv(UDSTpISOTpC_t *tp) { assert(tp); struct can_frame frame = {0}; @@ -186,7 +179,7 @@ static ssize_t isotp_c_socketcan_tp_peek(UDSTpHandle_t *hdl, uint8_t **p_buf, UD } fprintf(stdout, "%06d, %s recv, 0x%03x (%s), ", UDSMillis(), tp->tag, ta, ta_type == UDS_A_TA_TYPE_PHYSICAL ? "phys" : "func"); - for (unsigned i = 0; i < ret; i++) { + for (int i = 0; i < ret; i++) { fprintf(stdout, "%02x ", (*p_buf)[i]); } fprintf(stdout, "\n"); diff --git a/src/tp/mock.c b/src/tp/mock.c index 8ee088d..01b7b49 100644 --- a/src/tp/mock.c +++ b/src/tp/mock.c @@ -34,7 +34,7 @@ static void LogMsg(const char *prefix, const uint8_t *buf, size_t len, UDSSDU_t fflush(LogFile); // flush every time in case of crash } -static void NetworkPoll() { +static void NetworkPoll(void) { for (unsigned i = 0; i < MsgCount; i++) { struct Msg *msg = &msgs[i]; if (UDSTimeAfter(UDSMillis(), msg->scheduled_tx_time)) { diff --git a/test/BUILD b/test/BUILD index 22ff166..75c1723 100644 --- a/test/BUILD +++ b/test/BUILD @@ -133,5 +133,10 @@ cc_library( "-Wno-unused-parameter", "-Wno-gnu-zero-variadic-macro-arguments", ], + defines = [ + "UDS_TP_ISOTP_C_SOCKETCAN", + "UDS_TP_ISOTP_SOCK", + "UDS_TP_MOCK", + ], target_compatible_with = ["//platforms/compiler:clang"], ) diff --git a/test_all.sh b/test_all.sh new file mode 100755 index 0000000..5509ece --- /dev/null +++ b/test_all.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Run all the tests that will run on the host machine +# Note: qemu must be installed, vcan must be set up +# See test/README.md for more information + +bazel test //test:all + +## +## QEMU tests +## + +# ISO-TP linux sockets fail on qemu-arm with the following error: +# ENOPROTOOPT 92 Protocol not available +# however, socketcan linux sockets work fine. +bazel test --config=arm_linux //test:all --test_tag_filters=-isotp_sock + +# It seems socketcan is not supported at all on qemu-ppc +bazel test --config=ppc //test:all --test_tag_filters=-vcan +bazel test --config=ppc64 //test:all --test_tag_filters=-vcan +bazel test --config=ppc64le //test:all --test_tag_filters=-vcan + +# Test that the ultra strict build works +bazel build -s --config=x86_64_clang //test:ultra_strict \ No newline at end of file