Compare commits

...

6 Commits

Author SHA1 Message Date
Carsten Schmidt 724f63290a
Merge 15ed00a985 into 2b8c7c5f4b 2025-02-14 13:46:57 +01:00
Khem Raj 2b8c7c5f4b Include time.h for timespec struct definition
Fixes
git/isobusfs/../libj1939.h:33:18: error: field has incomplete type 'struct timespec'
   33 |         struct timespec next_send_time;
      |                         ^
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-02-14 12:41:31 +01:00
Jan Engelhardt 4577316bd6 Update .gitignore 2025-02-14 12:40:42 +01:00
Marc Kleine-Budde 4364d655b8
Merge pull request #576 from jengelh/master
build: give libisobusfs a version
2025-02-12 16:55:15 +01:00
Jan Engelhardt 2e71e396c5 build: give libisobusfs a version 2025-02-10 15:32:27 +01:00
Carsten Schmidt 15ed00a985 Read PDU to send from binary file. 2023-03-25 16:41:45 +01:00
4 changed files with 38 additions and 2 deletions

7
.gitignore vendored
View File

@ -1,6 +1,13 @@
*~
*.a
*.so
*.so.*
*.o
.ccls-cache
CMakeCache.txt
CMakeFiles/
Makefile
cmake_install.cmake
compile_commands.json
tags
/build

View File

@ -126,6 +126,7 @@ if(NOT ANDROID)
set_target_properties(isobusfs PROPERTIES
PUBLIC_HEADER "${PUBLIC_HEADER_ISOBUSFS}"
SOVERSION 0
)
install(TARGETS isobusfs

View File

@ -42,6 +42,7 @@
*
*/
#include <fcntl.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
@ -78,12 +79,32 @@ void print_usage(char *prg)
fprintf(stderr, " -S (SF broadcast mode - for functional addressing)\n");
fprintf(stderr, " -C (CF broadcast mode - no wait for flow controls)\n");
fprintf(stderr, " -L <mtu>:<tx_dl>:<tx_flags> (link layer options for CAN FD)\n");
fprintf(stderr, " -i <filename> (Read PDU data from binary file instead of STDIN)\n");
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
fprintf(stderr, "The pdu data is expected on STDIN in space separated ASCII hex values.\n");
fprintf(stderr, "(*) = Use '-t %s' to set N_As to zero for Linux version 5.18+\n", ZERO_STRING);
fprintf(stderr, "\n");
}
ssize_t read_binary_file(void *buffer, const size_t siz_buffer, const char *filename)
{
int fd = -1;
ssize_t num_read = -1;
if( buffer == NULL || siz_buffer < 1 || filename == NULL ) {
return 0;
}
if( (fd = open(filename, O_RDONLY)) == -1 ) {
return 0;
}
num_read = read(fd, buffer, siz_buffer);
close(fd);
return num_read > 0 ? num_read : 0;
}
int main(int argc, char **argv)
{
int s;
@ -102,7 +123,7 @@ int main(int argc, char **argv)
addr.can_addr.tp.tx_id = addr.can_addr.tp.rx_id = NO_CAN_ID;
while ((opt = getopt(argc, argv, "s:d:x:p:P:t:f:D:l:g:bSCL:?")) != -1) {
while ((opt = getopt(argc, argv, "s:d:x:p:P:t:f:D:l:g:bSCL:i:?")) != -1) {
switch (opt) {
case 's':
addr.can_addr.tp.tx_id = strtoul(optarg, NULL, 16);
@ -227,6 +248,10 @@ int main(int argc, char **argv)
}
break;
case 'i':
buflen = read_binary_file(&buf[0], sizeof(buf), optarg);
break;
case '?':
print_usage(basename(argv[0]));
exit(0);
@ -285,6 +310,7 @@ int main(int argc, char **argv)
exit(1);
}
if( buflen < 1 ) {
if (!datalen) {
while (buflen < BUFSIZE && scanf("%hhx", &buf[buflen]) == 1)
buflen++;
@ -292,6 +318,7 @@ int main(int argc, char **argv)
for (buflen = 0; buflen < datalen; buflen++)
buf[buflen] = ((buflen % 0xFF) + 1) & 0xFF;
}
}
loop:
if (usecs)
@ -313,7 +340,7 @@ loop:
goto loop;
}
/*
/*
* due to a Kernel internal wait queue the PDU is sent completely
* before close() returns.
*/

View File

@ -17,6 +17,7 @@
#include <linux/can/j1939.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <sys/socket.h>
#ifndef J1939_LIB_H