On Thu, May 05, 2011 at 08:37:56PM +0200, Oliver Hartkopp wrote:
> On 28.04.2011 09:42, Kurt Van Dijck wrote:
> > On Thu, Apr 28, 2011 at 08:34:02AM +0200, Oliver Hartkopp wrote:
> >> On 27.04.2011 11:06, Kurt Van Dijck wrote:
> >>> This patch adds SAE J1939 tools & libraries to can-utils
> >>>
> >>> * jacd: a J1939 address claiming daemon
> >>> * jspy: spy on a J1939 bus
> >>> * jsr: send/receive J1939 packets
> >>
> >> Hey, that's definitely very interesting to play with!!
> >> (and to see how the API is used ...)
> > Happy to hear you got started now :-)
> > FYI I added some sendto() examples in the kernel documentation ...
> > 
> > I believe the kernel part is bugfree now.
> > Enjoy J1939!
> 
> Hi Kurt,
> 
> i tried to follow your documentation and have done this:
> 
> root@host:~# IP link set vcan0 j1939 on
> root@host:~# IP addr add dev vcan0 j1939 0x20
> root@host:~# IP addr add dev vcan0 j1939 0x30
> 
> (IP is the patched version of 'ip' on my box)
> 
> Then i started in different terminals:
> 
> candump -td -c -c any
> 
> jspy -P
> 
> and then invoked in a third terminal:
> 
> echo 11223344 | jsr -v -v vcan0:30,0033
> 
> ... but nothing happens.
you're not gonna like this: I had not tested this scenario
(i.e. piped stdin, no buffer size given as argument) recently,
after I prepared the tools for publishing. I did change the
default buffersize to 0 ....

What you're trying to do should have worked in the first place ....
(I'm hiding underneath the table now :-) ).

The thing was: fstat(STDIN_FILENO) does still not return a size, and
thus a bit futher, read(0, buff, 0) is done, returing ... 0,
which equals EOF => done here, exit as soon as we can.

The patch below solves that:

Thanks for testing,
Kurt

Index: can-utils/jsr.c
===================================================================
--- can-utils/jsr.c     (revision 1254)
+++ can-utils/jsr.c     (working copy)
@@ -140,7 +140,7 @@
 
                if (fstat(STDIN_FILENO, &st) < 0)
                        error(1, errno, "stat stdin, could not determine buffer 
size");
-               s.pkt_len = st.st_size;
+               s.pkt_len = st.st_size ?: 1024;
        }
 
        /* prepare */
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to