Commit Graph

17 Commits (35b2ef691c10ead0b1e1d4e9a1c7c366ba166c20)

Author SHA1 Message Date
Marc Kleine-Budde 791b6de786 treewide: Fix compilation on libmusl, replace error() by err()
Reported-by: Brandon Ros <brandonros1@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-10-30 11:59:49 +01:00
Yegor Yefremov 7b7331976a Add SPDX identifiers
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-06-19 12:24:24 +02:00
Marc Kleine-Budde 9f60ed6fa0 testj1939: use %zu to as format string to print sizeof()
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-03-12 12:37:27 +01:00
Marc Kleine-Budde e0277cc960
Merge pull request #122 from olerem/test
testj1939: split output string in to 8 byte strings
2019-01-14 10:03:42 +01:00
Oleksij Rempel 5551de5e56 testj1939: split output string in to 8 byte strings
Currently if we send lots of bytes, test1939 output will get unreadable.
Make it easier to read by splitting output dump.
New format will looks as following example:
root@DistroKit:~ testj1939 can0:0x90 -r
80 12300: 01 23 45 67 89 ab cd ef
00008     01 23 45 67 89 ab cd ef
00010     01 23 45 67 89 ab cd ef
00018     01 23 45 67 89 ab cd ef
00020     01 23 45 67 89 ab cd ef
00028     01 23 45 67 89 ab cd ef
00030     01 23 45 67 89 ab cd ef
00038     01 23 45 67 89 ab cd ef
00040     01 23 45 67 89 ab cd ef
00048     01 23 45 67 89 ab cd ef
00050     01 23 45 67 89 ab cd ef
00058     01 23 45 67 89 ab cd ef
00060     01 23 45 67 89 ab cd ef
00068     01 23 45 67 89 ab cd ef
00070     01 23 45 67 89 ab cd ef
00078     01 23 45 67 89 ab cd ef

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2019-01-14 09:19:51 +01:00
Oleksij Rempel ed5b495da6 testj1939: fail if we use unsupported size
Currently if we set size which is more then 128 byte
will silently ignore provided value and send only maximal
supported size.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2019-01-14 09:16:05 +01:00
Oleksij Rempel e649b6ee2a libj1939: add libj1939_parse_canaddr and reuse it by testj1939
this function will be needed jcat

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2019-01-04 13:00:33 +01:00
Bastian Stender 54ff81cc40 testj1939: add omit bind option
This option is needed for j1939 socket functionality test.
Connects wihout bind should not work.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2018-09-21 11:31:22 +02:00
Bastian Stender 1ba9b86451 testj1939: add re-bind support
This option is needed for j1939 socket functionality test.
Binding to a socket and rebinding to the socket with e.g. a different SA
should work.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Bastian Stender <bst@pengutronix.de>
2018-09-21 11:31:04 +02:00
Bastian Stender 1f3f2f6163 testj1939: use address to string function from libj1939
canaddr2str() from testj1939 and libj1939's libj1939_addr2str provide
the same functionality. Remove the local helper function and use
libj1939_addr2str instead.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
2018-01-22 12:27:15 +01:00
Bastian Stender 680d5c30c3 testj1939: initialize verbose variable
Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-01-18 14:53:43 +01:00
Marc Kleine-Budde 07daafc825 testj1939: fix warning on 32 bit systems
testj1939.c: In function 'main':
testj1939.c:201:3: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Wformat=]
   fprintf(stderr, "- bind(, %s, %li);\n", canaddr2str(&sockname), sizeof(sockname));
   ^
testj1939.c:210:4: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Wformat=]
    fprintf(stderr, "- connect(, %s, %li);\n", canaddr2str(&peername), sizeof(peername));
    ^
testj1939.c:228:5: warning: format '%li' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]
     fprintf(stderr, "- sendto(, <dat>, %i, 0, %s, %li);\n", todo_send, canaddr2str(&peername), sizeof(peername));
     ^
testj1939.c:254:4: warning: format '%li' expects argument of type 'long int', but argument 3 has type 'unsigned int' [-Wformat=]
    fprintf(stderr, "- recvfrom(, <dat>, %li, 0, &<peername>, %li);\n", sizeof(peername), sizeof(peername));
    ^
testj1939.c:254:4: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Wformat=]

Use 'z' as correct modifier to print sizeof().

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2016-10-04 14:24:49 +02:00
Kurt Van Dijck 1ffa9a16a4 testj1939: add -w option to keep program open 2016-02-23 09:51:16 +01:00
Kurt Van Dijck 75dfd666c4 testj1939: print API calls 2013-11-28 10:58:59 +01:00
Kurt Van Dijck 854f47fa84 testj1939: use send() when connect()ed
When using connect(), don't re-use the peername but use send() without
destination information
2013-11-20 11:21:07 +01:00
Kurt Van Dijck d66e6ce4ee testj1939: remember if peername was provided
When peername was not provided, the program uses send() rather than
sendto() so the API calls are better demonstrated
2013-11-20 11:21:07 +01:00
Kurt Van Dijck 198c5801ec import sample program & help page 2013-11-20 11:14:44 +01:00