Skip to content

Commit 9e2775d

Browse files
raiden00pllupyuen
authored andcommitted
fix build for canutilis/lely-canopen
This commit fixes lely-canopen build for make and cmake. It also update lely commit tag to the latest lely master. The required changes are now split into several patches to make it easier to fix any issues in the future. Signed-off-by: raiden00pl <[email protected]>
1 parent bbcba55 commit 9e2775d

8 files changed

+375
-159
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From c907795a0856f1a0eb5a250fca7c2e02bbfdf28e Mon Sep 17 00:00:00 2001
2+
From: raiden00pl <[email protected]>
3+
Date: Thu, 6 Oct 2022 15:12:49 +0200
4+
Subject: [PATCH 1/5] tools: eliminate 'multiple definitions of poll' compiler
5+
errors for flat address space systems
6+
7+
Signed-off-by: raiden00pl <[email protected]>
8+
---
9+
tools/can2udp.c | 2 +-
10+
tools/cocatd.c | 2 +-
11+
tools/coctl.c | 2 +-
12+
3 files changed, 3 insertions(+), 3 deletions(-)
13+
14+
diff --git a/tools/can2udp.c b/tools/can2udp.c
15+
index 960c6117..caee9176 100644
16+
--- a/tools/can2udp.c
17+
+++ b/tools/can2udp.c
18+
@@ -79,7 +79,7 @@ int wtm_send(co_wtm_t *wtm, const void *buf, size_t nbytes, void *data);
19+
20+
int flags;
21+
int keep = 10000;
22+
-io_poll_t *poll;
23+
+static io_poll_t *poll;
24+
io_handle_t can_handle = IO_HANDLE_ERROR;
25+
io_handle_t send_handle = IO_HANDLE_ERROR;
26+
io_handle_t recv_handle = IO_HANDLE_ERROR;
27+
diff --git a/tools/cocatd.c b/tools/cocatd.c
28+
index 348168d5..ad191b74 100644
29+
--- a/tools/cocatd.c
30+
+++ b/tools/cocatd.c
31+
@@ -79,7 +79,7 @@ co_unsigned32_t co_1026_up_ind(
32+
#define FLAG_NO_DAEMON 0x02
33+
34+
int flags;
35+
-io_poll_t *poll;
36+
+static io_poll_t *poll;
37+
io_handle_t hcan = IO_HANDLE_ERROR;
38+
can_net_t *net;
39+
co_dev_t *dev;
40+
diff --git a/tools/coctl.c b/tools/coctl.c
41+
index 351b81c0..12f4b3aa 100644
42+
--- a/tools/coctl.c
43+
+++ b/tools/coctl.c
44+
@@ -90,7 +90,7 @@ int io_thrd_start(void *arg);
45+
void co_net_err(struct co_net *net);
46+
47+
struct co_net net[CO_GW_NUM_NET];
48+
-io_poll_t *poll;
49+
+static io_poll_t *poll;
50+
51+
int flags;
52+
int inhibit = INHIBIT;
53+
--
54+
2.48.1
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
From fa0d7ef4f2ef9f1efff4f79bd69c1b59332ab3ba Mon Sep 17 00:00:00 2001
2+
From: raiden00pl <[email protected]>
3+
Date: Fri, 21 Mar 2025 16:10:50 +0100
4+
Subject: [PATCH 2/5] tools/coctl.c: fix printf issues
5+
6+
Signed-off-by: raiden00pl <[email protected]>
7+
---
8+
tools/coctl.c | 12 +++++++-----
9+
1 file changed, 7 insertions(+), 5 deletions(-)
10+
11+
diff --git a/tools/coctl.c b/tools/coctl.c
12+
index 12f4b3aa..594fe699 100644
13+
--- a/tools/coctl.c
14+
+++ b/tools/coctl.c
15+
@@ -40,6 +40,8 @@
16+
#include <stdlib.h>
17+
#include <string.h>
18+
19+
+#include <inttypes.h>
20+
+
21+
#if _WIN32
22+
#include <io.h>
23+
#endif
24+
@@ -358,7 +360,7 @@ main(int argc, char *argv[])
25+
if (cmd)
26+
printf("... ");
27+
else
28+
- printf("[%u] ", seq);
29+
+ printf("[%" PRIu32 "] ", seq);
30+
fflush(stdout);
31+
}
32+
// Keep reading lines until end-of-file.
33+
@@ -409,7 +411,7 @@ main(int argc, char *argv[])
34+
free(cmd);
35+
cmd = tmp;
36+
} else {
37+
- if (asprintf(&cmd, "[%u] %s", seq, line)
38+
+ if (asprintf(&cmd, "[%" PRIu32 "] %s", seq, line)
39+
== -1) {
40+
cmd = NULL;
41+
break;
42+
@@ -431,7 +433,7 @@ main(int argc, char *argv[])
43+
result = asprintf(&tmp, "%s%s%s",
44+
recv_buf, cmd, line);
45+
else
46+
- result = asprintf(&tmp, "%s[%u] %s",
47+
+ result = asprintf(&recv_buf, "%s[%" PRIu32 "] %s",
48+
recv_buf, seq, line);
49+
if (result < 0) {
50+
mtx_unlock(&recv_mtx);
51+
@@ -444,7 +446,7 @@ main(int argc, char *argv[])
52+
result = asprintf(&recv_buf, "%s%s",
53+
cmd, line);
54+
else
55+
- result = asprintf(&recv_buf, "[%u] %s",
56+
+ result = asprintf(&recv_buf, "[%" PRIu32 "] %s",
57+
seq, line);
58+
if (result < 0) {
59+
recv_buf = NULL;
60+
@@ -561,7 +563,7 @@ gw_rate(co_unsigned16_t id, co_unsigned16_t rate, void *data)
61+
return;
62+
bitrate = rate * 1000;
63+
if (io_can_set_bitrate(net[id - 1].handle, bitrate) == -1)
64+
- diag(DIAG_ERROR, 0, "unable to set bitrate of %s to %u bit/s",
65+
+ diag(DIAG_ERROR, 0, "unable to set bitrate of %s to %" PRIu32 " bit/s",
66+
net[id - 1].can_path, bitrate);
67+
}
68+
69+
--
70+
2.48.1
71+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From ba671d68bde31fc8e4cd893b3634fa6bbd299784 Mon Sep 17 00:00:00 2001
2+
From: raiden00pl <[email protected]>
3+
Date: Wed, 19 Mar 2025 11:18:13 +0100
4+
Subject: [PATCH 3/5] src/co/nmt.c: fix compilation
5+
6+
Signed-off-by: raiden00pl <[email protected]>
7+
---
8+
src/co/nmt.c | 2 ++
9+
1 file changed, 2 insertions(+)
10+
11+
diff --git a/src/co/nmt.c b/src/co/nmt.c
12+
index fa943fba..4074e238 100644
13+
--- a/src/co/nmt.c
14+
+++ b/src/co/nmt.c
15+
@@ -1432,12 +1432,14 @@ co_nmt_on_hb(co_nmt_t *nmt, co_unsigned8_t id, int state, int reason)
16+
if (co_nmt_is_master(nmt))
17+
return;
18+
#endif
19+
+#if !LELY_NO_CO_EMCY
20+
if (nmt->srv.emcy) {
21+
// Remove the EMCY message from the stack.
22+
ssize_t n = co_emcy_find(nmt->srv.emcy, 0x8130);
23+
if (n >= 0)
24+
co_emcy_remove(nmt->srv.emcy, n);
25+
}
26+
+#endif
27+
}
28+
}
29+
30+
--
31+
2.48.1
32+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 8d361b53e8a1f238a0b1545d237e4b0e29fba1fe Mon Sep 17 00:00:00 2001
2+
From: raiden00pl <[email protected]>
3+
Date: Thu, 20 Mar 2025 13:58:17 +0100
4+
Subject: [PATCH 4/5] tools/coctl.c: add missing mutex init
5+
6+
Signed-off-by: raiden00pl <[email protected]>
7+
---
8+
tools/coctl.c | 1 +
9+
1 file changed, 1 insertion(+)
10+
11+
diff --git a/tools/coctl.c b/tools/coctl.c
12+
index 594fe699..c1d73b21 100644
13+
--- a/tools/coctl.c
14+
+++ b/tools/coctl.c
15+
@@ -287,6 +287,7 @@ main(int argc, char *argv[])
16+
co_gw_txt_set_recv_func(gw_txt, &gw_txt_recv, NULL);
17+
co_gw_txt_set_send_func(gw_txt, &gw_txt_send, gw);
18+
19+
+ mtx_init(&wait_mtx, mtx_plain);
20+
mtx_init(&recv_mtx, mtx_plain);
21+
cnd_init(&wait_cond);
22+
wait = 0;
23+
--
24+
2.48.1
25+

0 commit comments

Comments
 (0)