Linux CAN drivers development
 help / color / mirror / Atom feed
From: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
To: Mark Santacesaria <mark@keeptruckin.com>
Cc: linux-can@vger.kernel.org
Subject: Re: j1939: recv >8 bytes
Date: Mon, 28 Sep 2015 10:58:05 +0200	[thread overview]
Message-ID: <20150928085805.GA16669@airbook> (raw)
In-Reply-To: <CAKoHjFxUqnPb+QEnTUjEinQHWjhiO-2kwapyjza1iFvGGg2C6g@mail.gmail.com>

[-- 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

      parent reply	other threads:[~2015-09-28  8:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150928085805.GA16669@airbook \
    --to=dev.kurt@vandijck-laurijssen.be \
    --cc=linux-can@vger.kernel.org \
    --cc=mark@keeptruckin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox