Skip to content

Commit

Permalink
update ultra-strict build, fix esp32 build
Browse files Browse the repository at this point in the history
  • Loading branch information
driftregion committed Dec 15, 2023
1 parent ea0b196 commit 9373742
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ fuzzer
**/*.cache
**/build
**/sdkconfig*
release/
15 changes: 4 additions & 11 deletions release/iso14229.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion release/iso14229.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ typedef SSIZE_T ssize_t;
#include <inttypes.h>
#include <esp_timer.h>

#define UDS_TP UDS_TP_ISOTP_C
#define UDS_TP_ISOTP_C 1
#define UDS_ENABLE_DBG_PRINT 1
#define UDS_ENABLE_ASSERT 1

Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/sys_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <inttypes.h>
#include <esp_timer.h>

#define UDS_TP UDS_TP_ISOTP_C
#define UDS_TP_ISOTP_C 1
#define UDS_ENABLE_DBG_PRINT 1
#define UDS_ENABLE_ASSERT 1

Expand Down
11 changes: 2 additions & 9 deletions src/tp/isotp_c_socketcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/tp/mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 5 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
24 changes: 24 additions & 0 deletions test_all.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9373742

Please sign in to comment.