All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: s-amarce <s-amarce@haw-landshut.de>, linux-can@vger.kernel.org
Subject: Re: Canplayer play to can0 - problem
Date: Mon, 19 Oct 2015 11:41:22 +0200	[thread overview]
Message-ID: <5624BAC2.6050002@pengutronix.de> (raw)
In-Reply-To: <447a130eb0e223d5336a160a19d91648@haw-landshut.de>

[-- Attachment #1: Type: text/plain, Size: 2838 bytes --]

On 10/19/2015 11:14 AM, s-amarce wrote:
> I am currently trying to play a recorded log-file to my installed device 
> can0. There are no problems when the  data is streamed to the device 
> using a cable.
> I managed to stream the log file to a virtual device executing the 
> command canplayer can0=3Dvcan0 < file.log.
> Using this command I can see all the data using candump vcan0 without 
> any problems.
> However when I try to run: canplayer can0=3Dcan0 < file.log, I receive 
> the error: "sendto: No buffer space available."
> Is it possible to replay logfiles to real devices like can0 or do I have 
> to use virtual devices?
> 
> My ifconfig after reboot:
>            can0      Link encap:UNSPEC  HWaddr 
> 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
>            UP RUNNING NOARP  MTU:16  Metric:1
>            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>            collisions:0 txqueuelen:10
>            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
>            Interrupt:68
> 
> // The error
>           canplayer can0=3Dcan0 < data.log
>           sendto: No buffer space available
> 
> // After
>           ifconfig can0
>            can0      Link encap:UNSPEC  HWaddr 
> 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
>            UP RUNNING NOARP  MTU:16  Metric:1
>            RX packets:2 errors:0 dropped:0 overruns:0 frame:0
>            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>            collisions:0 txqueuelen:10
>            RX bytes:16 (16.0 B)  TX bytes:0 (0.0 B)
>            Interrupt:68
> 
> I hope you can help me with this. I look forward to hearing from you.

You have to add a loop like this:

resend:
                nbytes = write(s, &frame, mtu);
                if (nbytes < 0) {
                        if (errno != ENOBUFS) {
                                perror("write");
                                return -1;
                        }
                        /* wait for the write socket (with timeout) */
                        if (poll(&fds, 1, polltimeout) < 0) {
                                 perror("poll");
                                 return -1;
                        } else {
                                goto resend;
                        }
                } else if (nbytes < mtu) {
                        fprintf(stderr, "write: incomplete CAN frame\n");
                        return 1;
                }

Patches welcome,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

      reply	other threads:[~2015-10-19  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-19  9:14 Canplayer play to can0 - problem s-amarce
2015-10-19  9:41 ` Marc Kleine-Budde [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=5624BAC2.6050002@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=s-amarce@haw-landshut.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.