Compare commits
10 Commits
fc137a63d6
...
76b717be89
| Author | SHA1 | Date |
|---|---|---|
|
|
76b717be89 | |
|
|
99ab67143a | |
|
|
a0aeaed234 | |
|
|
3cae8a449b | |
|
|
44e6eb45e3 | |
|
|
9e444073b1 | |
|
|
9d4f3c82a2 | |
|
|
7e8e247b2f | |
|
|
3fe1c42bbf | |
|
|
cb2ca58e4b |
|
|
@ -0,0 +1,57 @@
|
||||||
|
name: Build Deb Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-22.04, ubuntu-24.04]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
path: can-utils
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential devscripts debhelper cmake equivs
|
||||||
|
|
||||||
|
cd can-utils
|
||||||
|
# Install build dependencies defined in debian/control
|
||||||
|
sudo mk-build-deps -i -r -t "apt-get -y" debian/control
|
||||||
|
|
||||||
|
- name: Update changelog
|
||||||
|
run: |
|
||||||
|
cd can-utils
|
||||||
|
# Get version from tag, strip 'v' prefix if present
|
||||||
|
VERSION=${{ github.event.release.tag_name }}
|
||||||
|
VERSION=${VERSION#v}
|
||||||
|
|
||||||
|
# Add new entry to changelog
|
||||||
|
# Use the codename of the current OS (jammy or noble)
|
||||||
|
CODENAME=$(lsb_release -cs)
|
||||||
|
|
||||||
|
dch --create -v "${VERSION}-1~${CODENAME}" --package can-utils --distribution ${CODENAME} "New upstream release ${VERSION}"
|
||||||
|
dch -r ""
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
run: |
|
||||||
|
cd can-utils
|
||||||
|
# Build binary packages only, unsigned
|
||||||
|
dpkg-buildpackage -us -uc -b
|
||||||
|
|
||||||
|
- name: Upload to Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
*.deb
|
||||||
36
bcmserver.c
36
bcmserver.c
|
|
@ -153,7 +153,7 @@ int main(void)
|
||||||
|
|
||||||
char buf[MAXLEN];
|
char buf[MAXLEN];
|
||||||
char format[FORMATSZ];
|
char format[FORMATSZ];
|
||||||
char rxmsg[50];
|
char rxmsg[64];
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||||
|
|
@ -234,7 +234,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
again:
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(sc, &readfds);
|
FD_SET(sc, &readfds);
|
||||||
FD_SET(sa, &readfds);
|
FD_SET(sa, &readfds);
|
||||||
|
|
@ -242,6 +242,8 @@ int main(void)
|
||||||
select((sc > sa)?sc+1:sa+1, &readfds, NULL, NULL, NULL);
|
select((sc > sa)?sc+1:sa+1, &readfds, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (FD_ISSET(sc, &readfds)) {
|
if (FD_ISSET(sc, &readfds)) {
|
||||||
|
size_t size = sizeof(rxmsg);
|
||||||
|
int len = 0, res;
|
||||||
|
|
||||||
recvfrom(sc, &msg, sizeof(msg), 0,
|
recvfrom(sc, &msg, sizeof(msg), 0,
|
||||||
(struct sockaddr*)&caddr, &caddrlen);
|
(struct sockaddr*)&caddr, &caddrlen);
|
||||||
|
|
@ -249,17 +251,35 @@ int main(void)
|
||||||
ifr.ifr_ifindex = caddr.can_ifindex;
|
ifr.ifr_ifindex = caddr.can_ifindex;
|
||||||
ioctl(sc, SIOCGIFNAME, &ifr);
|
ioctl(sc, SIOCGIFNAME, &ifr);
|
||||||
|
|
||||||
sprintf(rxmsg, "< %s %03X %d ", ifr.ifr_name,
|
res = snprintf(rxmsg, size, "< %s %03X %d ", ifr.ifr_name,
|
||||||
msg.msg_head.can_id, msg.frame.can_dlc);
|
msg.msg_head.can_id, msg.frame.can_dlc);
|
||||||
|
if (res < 0 || (size_t)res >= size) {
|
||||||
|
printf("Error: rxmsg buffer (size %zu) too small for data.\n", size);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for ( i = 0; i < msg.frame.can_dlc; i++)
|
len += res;
|
||||||
sprintf(rxmsg + strlen(rxmsg), "%02X ",
|
|
||||||
msg.frame.data[i]);
|
for (i = 0; i < msg.frame.can_dlc; i++) {
|
||||||
|
res = snprintf(rxmsg + len, size - len, "%02X ", msg.frame.data[i]);
|
||||||
|
if (res < 0 || (size_t)res >= (size - len)) {
|
||||||
|
printf("Error: rxmsg buffer (size %zu) too small for data.\n", size);
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
|
len += res;
|
||||||
|
}
|
||||||
|
|
||||||
/* delimiter '\0' for Adobe(TM) Flash(TM) XML sockets */
|
/* delimiter '\0' for Adobe(TM) Flash(TM) XML sockets */
|
||||||
strcat(rxmsg, ">\0");
|
res = snprintf(rxmsg + len, size - len, ">");
|
||||||
|
if (res < 0 || (size_t)res >= (size - len)) {
|
||||||
|
printf("Error: rxmsg buffer (size %zu) too small for data.\n", size);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
send(sa, rxmsg, strlen(rxmsg) + 1, 0);
|
len += res;
|
||||||
|
|
||||||
|
send(sa, rxmsg, len + 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
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,5 @@
|
||||||
|
can-utils (0.0.0-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Initial release.
|
||||||
|
|
||||||
|
-- Maintainer Name <maintainer@example.com> Thu, 01 Jan 1970 00:00:00 +0000
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
Source: can-utils
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: GitHub Actions <actions@github.com>
|
||||||
|
Build-Depends: debhelper-compat (= 13), cmake
|
||||||
|
Standards-Version: 4.6.2
|
||||||
|
Homepage: https://github.com/linux-can/can-utils
|
||||||
|
|
||||||
|
Package: can-utils
|
||||||
|
Architecture: linux-any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: SocketCAN userspace utilities and tools
|
||||||
|
This package contains some userspace utilities for Linux SocketCAN subsystem.
|
||||||
|
|
||||||
|
Basic tools to display, record, generate and replay CAN traffic:
|
||||||
|
candump, canplayer, cansend, cangen, cansniffer, cansequence.
|
||||||
|
CAN access via IP sockets: canlogserver, bcmserver.
|
||||||
|
CAN in-kernel gateway configuration: cangw.
|
||||||
|
CAN bus measurement and testing: canbusload, can-calc-bit-timing, canfdtest, canerrsim.
|
||||||
|
ISO-TP tools: isotpsend, isotprecv, isotpsniffer, isotpdump, isotpserver, isotptun.
|
||||||
|
CAN log file converters: asc2log, log2asc, log2long.
|
||||||
|
Serial Line Discipline configuration: slcan_attach, slcand, slcanpty.
|
||||||
|
J1939 tools: j1939acd, j1939cat, j1939spy, j1939sr, testj1939.
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
Loading…
Reference in New Issue