# Re: \[Socketcan-users\] back to back can frames.

- From: Kurt Van Dijck \<hidden\>
- Date: 2012-07-05 13:57:53 
- List: linux-can
- Page: https://ratatoskr.run/linux-can/2012/07/9345238
- Thread: https://ratatoskr.run/linux-can/2012/07/9345238/t.md

```text
Max,

(please switch using linux-can@vger.kernel.org, as Oliver suggested)

to answer your question, see below

On Thu, Jul 05, 2012 at 11:35:46AM +0000, Max S. wrote:
> Hello,
> 
> While trying to test a can device I wrote a short program to
> continuously send can frames... However after a short while I get a
> buffer overflow error. Seems the internal queue is filled and overrun...
> 
> How can I send can frames at maximum throughput? simply one after the
> other, back to back.
> 
> what i have now is something like this:
> 
> 
> do{
> 	//prepare next frame...
> }while(write( sfd, frame, sizeof(*arguments.frame) ) == sizeof(*frame));
> //print error message...

> 
> since the write simply pushes the frame into the queue, it is logical
> that the queue would fill up quickly and get overflown?overrun?full.

my core loop would look like this:

	int ret;
	while (1) {
		ret = write(sfd, frame, sizeof(*frame));
		if ((ret < 0) && (errno == ENOBUFS)) {
			usleep(1000);
		} else
			break;
	}
	if (ret < 0)
		/* print error message */

> 
> Thanks,
> Max S.
> 
> _______________________________________________
> Socketcan-users mailing list
> Socketcan-users@lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/socketcan-users

-- 
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534
```
