* unsure - socketCAN blocking
@ 2012-10-08 10:16 Steffen Rose
2012-10-08 11:46 ` Marc Kleine-Budde
0 siblings, 1 reply; 7+ messages in thread
From: Steffen Rose @ 2012-10-08 10:16 UTC (permalink / raw)
To: linux-can
Hello,
I'm unsure, what I see.
I use:
Virtual box - Host Win 7/Guest kubuntu
Linux lisa 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012 x86_64
x86_64 x86_64 GNU/Linux
SocketCAN connector is a EMS CPC-USB.
On startup, the network works fine.
In different situation one or both directions (RX/TX) stop it's work.
My Linux program say:
write: No buffer space available
It's the write to the socketcan device can0.
For the current situation the communication stopped in general.
$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
qlen 1000
link/ether 08:00:27:62:24:48 brd ff:ff:ff:ff:ff:ff
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen
100
link/can
$ cat /proc/net/can/stats
717 transmitted frames (TXF)
820 received frames (RXF)
607 matched frames (RXMF)
74 % total match ratio (RXMR)
0 frames/s total tx rate (TXR)
0 frames/s total rx rate (RXR)
100 % current match ratio (CRXMR)
0 frames/s current tx rate (CTXR)
0 frames/s current rx rate (CRXR)
100 % max match ratio (MRXMR)
11 frames/s max tx rate (MTXR)
20 frames/s max rx rate (MRXR)
2 current receive list entries (CRCV)
2 maximum receive list entries (MRCV)
$ ip -det -stat link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen
100
link/can
can state ERROR-ACTIVE restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
ems_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
clock 8000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0
RX: bytes packets errors dropped overrun mcast
106 213 0 0 0 0
TX: bytes packets errors dropped carrier collsns
607 607 0 0 0 0
$ ./candump any
say nothing
I'm unsure to interprete the data. I cannot see any mistake.
--
Mit freundlichen Grüßen / Best regards
Steffen Rose
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: unsure - socketCAN blocking
2012-10-08 10:16 unsure - socketCAN blocking Steffen Rose
@ 2012-10-08 11:46 ` Marc Kleine-Budde
2012-10-08 14:36 ` Steffen Rose
0 siblings, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-10-08 11:46 UTC (permalink / raw)
To: Steffen Rose; +Cc: linux-can
[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]
On 10/08/2012 12:16 PM, Steffen Rose wrote:
> Hello,
> I'm unsure, what I see.
>
> I use:
> Virtual box - Host Win 7/Guest kubuntu
> Linux lisa 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012 x86_64
> x86_64 x86_64 GNU/Linux
>
> SocketCAN connector is a EMS CPC-USB.
>
> On startup, the network works fine.
> In different situation one or both directions (RX/TX) stop it's work.
> My Linux program say:
>
> write: No buffer space available
>
> It's the write to the socketcan device can0.
Your program probably produces CAN frames faster than they could be
delivered by your CAN hardware. Your choices are:
1) If the write/sendto system call returns with -ENOBUFS,
add the filedesciptor to poll/select and wait for it to be writeable
again. For some known, but not yet resolved reasons (a.k.a. bug),
the poll/select will return immediately, but the write will fail
again. To workaround this usleep for some milliseconds between
the write/sendto and the poll/select system call.
2) Increase txqueue length to 10000 or so.
(ifconfig can0 txqueuelen 10000)
This avoids to trigger the above bug and your write/sendto will
block until the queues are free again and your CAN frame will added
to the send queue. With this workaround poll/select work as expected,
i.e. when they return the socket is writeable without problems.
Hope that helps,
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: 259 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: unsure - socketCAN blocking
2012-10-08 11:46 ` Marc Kleine-Budde
@ 2012-10-08 14:36 ` Steffen Rose
2012-10-08 14:56 ` Wolfgang Grandegger
0 siblings, 1 reply; 7+ messages in thread
From: Steffen Rose @ 2012-10-08 14:36 UTC (permalink / raw)
To: linux-can; +Cc: Marc Kleine-Budde
Hello,
Am Montag, 8. Oktober 2012, 13:46:06 schrieb Marc Kleine-Budde:
> > I use:
> > Virtual box - Host Win 7/Guest kubuntu
> > Linux lisa 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012
> > x86_64 x86_64 x86_64 GNU/Linux
> >
> > SocketCAN connector is a EMS CPC-USB.
[...]
> Your program probably produces CAN frames faster than they could be
> delivered by your CAN hardware. Your choices are:
I'm unsure.
My CPU load is high. My application polling is not optimal at the moment. But
the CAN busload is not so high.
At the moment I would think, it is more a problem internal or on USB. I'm
unsure. I search information to analyze the current situation.
> 2) Increase txqueue length to 10000 or so.
> (ifconfig can0 txqueuelen 10000)
I did it.
after a little bit time...
Now my error:
write: Interrupted system call
$ ./candump can0
I see nothing.
But: There is traffic on the CAN and the USB traffic light of the CPC-USB is
blinking. Means, the CAN-USB transfer data from the CAN to the socketcan CAN
driver.
Can I see more states about the can, can_raw or the ems_usb modules?
$ ip -det -stat link show can0
4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen
10000
link/can
can state ERROR-ACTIVE restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
ems_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
clock 8000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 19 0 1 1 0
RX: bytes packets errors dropped overrun mcast
18122 25463 19 0 0 0
TX: bytes packets errors dropped carrier collsns
195038 164170 0 0 0 0
--
Mit freundlichen Grüßen / Best regards
Steffen Rose
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: unsure - socketCAN blocking
2012-10-08 14:36 ` Steffen Rose
@ 2012-10-08 14:56 ` Wolfgang Grandegger
2012-10-08 15:00 ` Marc Kleine-Budde
2012-10-08 15:19 ` Steffen Rose
0 siblings, 2 replies; 7+ messages in thread
From: Wolfgang Grandegger @ 2012-10-08 14:56 UTC (permalink / raw)
To: Steffen Rose; +Cc: linux-can, Marc Kleine-Budde
On 10/08/2012 04:36 PM, Steffen Rose wrote:
> Hello,
>
> Am Montag, 8. Oktober 2012, 13:46:06 schrieb Marc Kleine-Budde:
>>> I use:
>>> Virtual box - Host Win 7/Guest kubuntu
>>> Linux lisa 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012
>>> x86_64 x86_64 x86_64 GNU/Linux
>>>
>>> SocketCAN connector is a EMS CPC-USB.
>
> [...]
>
>> Your program probably produces CAN frames faster than they could be
>> delivered by your CAN hardware. Your choices are:
>
> I'm unsure.
> My CPU load is high. My application polling is not optimal at the moment. But
> the CAN busload is not so high.
>
> At the moment I would think, it is more a problem internal or on USB. I'm
> unsure. I search information to analyze the current situation.
>
>> 2) Increase txqueue length to 10000 or so.
>> (ifconfig can0 txqueuelen 10000)
>
> I did it.
>
> after a little bit time...
Did it run longer than before? Anyway, the candump utility shows how to
count messages dropped because the queue was full. Search for the option
"-d".
>
> Now my error:
> write: Interrupted system call
Hm, who has interrupted the write system call? gdb?
>
>
> $ ./candump can0
Please use "candump can0 any,0:0,#FFFFFFFF" to also see error messages.
>
> I see nothing.
Maybe error frames?
> But: There is traffic on the CAN and the USB traffic light of the CPC-USB is
> blinking. Means, the CAN-USB transfer data from the CAN to the socketcan CAN
> driver.
>
> Can I see more states about the can, can_raw or the ems_usb modules?
The stats below should tell you if you still receive messages.
>
> $ ip -det -stat link show can0
> 4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen
> 10000
> link/can
> can state ERROR-ACTIVE restart-ms 0
> bitrate 250000 sample-point 0.875
> tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
> ems_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
> clock 8000000
> re-started bus-errors arbit-lost error-warn error-pass bus-off
> 0 19 0 1 1 0
You seemed to have electrical problem on the bus. Not sure if it's
related, though.
Wolfgang.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: unsure - socketCAN blocking
2012-10-08 14:56 ` Wolfgang Grandegger
@ 2012-10-08 15:00 ` Marc Kleine-Budde
2012-10-08 15:21 ` Steffen Rose
2012-10-08 15:19 ` Steffen Rose
1 sibling, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-10-08 15:00 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Steffen Rose, linux-can
[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]
On 10/08/2012 04:56 PM, Wolfgang Grandegger wrote:
>>> Your program probably produces CAN frames faster than they could be
>>> delivered by your CAN hardware. Your choices are:
>>
>> I'm unsure.
>> My CPU load is high. My application polling is not optimal at the moment. But
>> the CAN busload is not so high.
>>
>> At the moment I would think, it is more a problem internal or on USB. I'm
>> unsure. I search information to analyze the current situation.
>>
>>> 2) Increase txqueue length to 10000 or so.
>>> (ifconfig can0 txqueuelen 10000)
>>
>> I did it.
>>
>> after a little bit time...
>
> Did it run longer than before? Anyway, the candump utility shows how to
> count messages dropped because the queue was full. Search for the option
> "-d".
>
>>
>> Now my error:
>> write: Interrupted system call
>
> Hm, who has interrupted the write system call? gdb?
Is your application making use of signals? This is not an error, just
restart the write.
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: 259 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: unsure - socketCAN blocking
2012-10-08 15:00 ` Marc Kleine-Budde
@ 2012-10-08 15:21 ` Steffen Rose
0 siblings, 0 replies; 7+ messages in thread
From: Steffen Rose @ 2012-10-08 15:21 UTC (permalink / raw)
To: linux-can
Am Montag, 8. Oktober 2012, 17:00:02 schrieb Marc Kleine-Budde:
> >> Now my error:
> >> write: Interrupted system call
> > Hm, who has interrupted the write system call? gdb?
> Is your application making use of signals? This is not an error, just
> restart the write.
I will ask my colleguage. But that is possible.
--
Mit freundlichen Grüßen / Best regards
Steffen Rose
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: unsure - socketCAN blocking
2012-10-08 14:56 ` Wolfgang Grandegger
2012-10-08 15:00 ` Marc Kleine-Budde
@ 2012-10-08 15:19 ` Steffen Rose
1 sibling, 0 replies; 7+ messages in thread
From: Steffen Rose @ 2012-10-08 15:19 UTC (permalink / raw)
To: linux-can; +Cc: Wolfgang Grandegger
Hello,
> > Now my error:
> > write: Interrupted system call
>
> Hm, who has interrupted the write system call? gdb?
That's my question, too.
> > $ ./candump can0
>
> Please use "candump can0 any,0:0,#FFFFFFFF" to also see error messages.
Thank you.
>
> Maybe error frames?
I see some error frames and error passive in the logs. But no busoff.
Now - (sporadic different situations):
The CAN transmit from the virtual env to the CAN, but the receiving doesn't
work. Also the candump show only the messages transmitted by the internal
programs, not the additional traffic on the real CAN.
> > Can I see more states about the can, can_raw or the ems_usb modules?
>
> The stats below should tell you if you still receive messages.
>
> > $ ip -det -stat link show can0
> > 4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN
> > qlen 10000
Currently I see only TX packets, no RX.
> You seemed to have electrical problem on the bus. Not sure if it's
> related, though.
Possible. But also in error passive is traffic possible and now the CAN
interface is in error active. In my case not only some messages are dropped.
The traffic dropped in one or both directions in general.
Of course, it is possible, that the USB connection or the virtual box USB
driver or so on is the problem! At the moment I want to analyze the problem
and search help for this.
--
Mit freundlichen Grüßen / Best regards
Steffen Rose
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-10-08 15:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08 10:16 unsure - socketCAN blocking Steffen Rose
2012-10-08 11:46 ` Marc Kleine-Budde
2012-10-08 14:36 ` Steffen Rose
2012-10-08 14:56 ` Wolfgang Grandegger
2012-10-08 15:00 ` Marc Kleine-Budde
2012-10-08 15:21 ` Steffen Rose
2012-10-08 15:19 ` Steffen Rose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox