On 2012-05-09 22:49, Ross Williamson wrote:
> Hi all,
>
> I'm looking over the python mmap example and am I correct in thinking
> that if front is larger than the buffer size then we would loose data - i.e.
>
> front += c.comedi_get_buffer_contents(dev,subdevice) #If this becomes a
> number > size - should wrap around
> map.seek(back%size) # Correctly finds position if back > size
> for i in range(back,front,2):
> map.read(2) #Problem here as the count would take the read to be > size
> and return blank?
Yes, that is a problem.
> Don't we need something like this inside the loop?:
>
> if i == size:
> map.seek(0)
You're half right, but 'front' and 'back' (and therefore 'i') can be
larger than 'size'. I think the test should be either
if i%size == 0:
or
if map.tell(0) == size:
--
-=( Ian Abbott @ MEV Ltd. E-mail: <
abb...@mev.co.uk> )=-
-=( Tel:
+44 (0)161 477 1898 FAX:
+44 (0)161 718 3587 )=-