From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Grandegger Subject: Re: [SocketCan] Problem of accuracy Date: Mon, 09 Jul 2012 14:15:44 +0200 Message-ID: <4FFACB70.7020202@grandegger.com> References: <4FF55274.3030006@volkswagen.de> <4FF8102C.8030609@grandegger.com> <4FF9E9E4.4090602@grandegger.com> <4FFA85B3.5080800@grandegger.com> <4FFA9466.3040600@grandegger.com> <4FFAA2D7.4010905@grandegger.com> <4FFAB09F.6090800@grandegger.com> <4FFAC346.7060201@grandegger.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from ngcobalt02.manitu.net ([217.11.48.102]:44547 "EHLO ngcobalt02.manitu.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753280Ab2GIMPr (ORCPT ); Mon, 9 Jul 2012 08:15:47 -0400 In-Reply-To: Sender: linux-can-owner@vger.kernel.org List-ID: To: Mohamed HAMZAOUI Cc: Linux-CAN On 07/09/2012 01:57 PM, Mohamed HAMZAOUI wrote: > If i have understood you correctly, I think it must change the period > if the write function is a synchronous call ! > if my function is like this : >=20 > while(1) > { > nannosleep(1000000); > write (myFrame in opened CAN socket); > } >=20 > then the result is 1ms + timeOf (write) for every iteration. Yep. > but if the write call is asynchronous we return to case you mentioned= ! The write call is asynchronous and I'm surprised that it takes 300us to return. Could you show us your test program? > Is this correct ? Anyway, in a previous mail you wrote: > i use clock_nanosleep with (1000000 ns =3D 1ms) and the result mesure= d > with another CAN transeiver is an average of 1.30 ms (delta =3D 300 =C2= =B5s) > ! You cannot expect precises timing with nanosloeep(). Have a look to cyclictest.c to understand how to implement a periodic task. Wolfgang.