Thread (1 message) 1 message, 1 author, 2015-09-28

Re: j1939: recv >8 bytes

From: Kurt Van Dijck <hidden>
Date: 2015-09-28 08:58:16

Possibly related (same subject, not in this thread)

Hi Mark,

see my comments below,
--- Original message ---
Date: Sun, 27 Sep 2015 22:24:33 -0400
From: Mark Santacesaria <redacted>
To: Kurt Van Dijck <redacted>
Subject: Re: j1939: recv >8 bytes

   hey Kurt.... thanks again for the help.... i was hoping to ask you
   something else.... the three main things that i want to do are:
   - request and receive an address claim
You may take a look at jacd, in my can-utils j1939 branch.
   - request and receive a VIN
   - listen to the traffic to monitor a handful of messages
   i was planning on setting up a state machine that handles sending the
   messages and a receive section that takes in all of the messages and
   processes them..... i think this should work fine except as you
   mentioned in your reply the number of bytes received is specified so
   can i set up to listen to single packet and multi-packet messages at
   the same time? � i may not know the order that things are going to be
   received....
The #bytes you give to the recv() call is the size of the buffer.
The #received bytes is the return value (if successfull).

So, a single
	ret = recv(sock, buf, sizeof(buf), 0);

may receive single packet & multi-packet. My goal was to make this
transparent indeed. Just make sure the buffer 'buf' is big enough
to receive the largest packet that you expect.
'ret' may be 8, <8, or >8, or in case of failure, <0.

Kind regards,
Kurt
   thanks!!!�  I appreciate the help a bunch...

   On Fri, Sep 25, 2015 at 4:28 AM, Kurt Van Dijck
   <[1]dev.kurt@vandijck-laurijssen.be> wrote:

     Hi Mark,
     I added linux-can mailing list in CC, and altered the subject.
     See my answer to your question below.
     --- Original message ---
     > Date: Thu, 24 Sep 2015 11:21:48 -0400
     > From: Mark Santacesaria <[2]mark@keeptruckin.com>
     > To: [3]kurt.van.dijck@eia.be
     > Subject: j1939 linux kernel...
     >
     >�  �  hey kurt.... thanks for the effort that you put in to the
     j1939
     >�  �  code.... i was trying to receive a VIN request which is a
     multi-packet
     >�  �  message, and while i found examples of sending more that 8
     bytes but i
     >�  �  am not sure how to receive.....
     A "multi-packet message" is treated as a single j1939 packet.
     You receive it like any other j1939 packet:
     �  �  �  �  uint8_t buf[1024];
     �  �  �  �  int ret;
     �  �  �  �  ret = recv(sock, buf, sizeof(buf), 0);
     will receive up to 1024 bytes from the next j1939 packet.
     You may use any buffer size you like here.
     see also
     �  �  �  �  man recv
     Kind regards,
     Kurt

   --
   Mark Santacesaria
   Design Engineer
   Keep Truckin
   716-208-9681
   KeepTruckin logo

References

   1. mailto:dev.kurt@vandijck-laurijssen.be
   2. mailto:mark@keeptruckin.com
   3. mailto:kurt.van.dijck@eia.be
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help