linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* j1939: recv >8 bytes
       [not found] <CAKoHjFzLoME76fmon+O7oS5_pKQk2j7QujnMsOfL7aLrr8xDWg@mail.gmail.com>
@ 2015-09-25  8:28 ` Kurt Van Dijck
       [not found]   ` <CAKoHjFxUqnPb+QEnTUjEinQHWjhiO-2kwapyjza1iFvGGg2C6g@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Kurt Van Dijck @ 2015-09-25  8:28 UTC (permalink / raw)
  To: Mark Santacesaria; +Cc: linux-can

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 <mark@keeptruckin.com>
> To: 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: j1939: recv >8 bytes
       [not found]   ` <CAKoHjFxUqnPb+QEnTUjEinQHWjhiO-2kwapyjza1iFvGGg2C6g@mail.gmail.com>
@ 2015-09-28  8:58     ` Kurt Van Dijck
  0 siblings, 0 replies; 2+ messages in thread
From: Kurt Van Dijck @ 2015-09-28  8:58 UTC (permalink / raw)
  To: Mark Santacesaria; +Cc: linux-can

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 3079 bytes --]

Hi Mark,

see my comments below,

--- Original message ---
> Date: Sun, 27 Sep 2015 22:24:33 -0400
> From: Mark Santacesaria <mark@keeptruckin.com>
> To: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-28  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAKoHjFzLoME76fmon+O7oS5_pKQk2j7QujnMsOfL7aLrr8xDWg@mail.gmail.com>
2015-09-25  8:28 ` j1939: recv >8 bytes Kurt Van Dijck
     [not found]   ` <CAKoHjFxUqnPb+QEnTUjEinQHWjhiO-2kwapyjza1iFvGGg2C6g@mail.gmail.com>
2015-09-28  8:58     ` Kurt Van Dijck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).