This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author FazJaxton
Recipients FazJaxton
Date 2014-06-17.20:18:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403036333.47.0.341368949906.issue21797@psf.upfronthosting.co.za>
In-reply-to
Content
I am using the mmap module on Linux with python 2.7.6 to access memory-mapped IO.  The device that I am accessing implements a hardware FIFO that holds 16-bit values and pops an entry when the MSB of the entry is read.  I am trying to use the mmap module to do an 8-bit read of the LSB then an 8-bit read of the MSB, which should pop the value.  However, I am finding that the LSB read is sometimes popping the value before I read the MSB.

I am mapping the memory like this:
        self.fd = os.open ("/dev/mem", os.O_RDWR | os.O_SYNC)
        self.mempage = mmap.mmap (self.fd, mmap_size, mmap.MAP_SHARED,
                mmap.PROT_READ | mmap.PROT_WRITE, offset = pc104_base)

Then trying to read a value like this:
        val = self.mempage[pos]

The LSB of the hardware device is a lower address than the MSB.  The read of the LSB seems to sometimes overlap into a read of the MSB, which causes the following read of the MSB to be incorrect, as the value has already been popped.  Sometimes the reads of the MSB are correct; I am not sure why this behavior is not consistent across all reads.

The reads for this device need to be 8-bit, as the bus the device is connected to only supports 8-bit reads.

I think that a single-byte access of the memory mapping should only access a single byte in the underlying memory region.
History
Date User Action Args
2014-06-17 20:18:53FazJaxtonsetrecipients: + FazJaxton
2014-06-17 20:18:53FazJaxtonsetmessageid: <1403036333.47.0.341368949906.issue21797@psf.upfronthosting.co.za>
2014-06-17 20:18:53FazJaxtonlinkissue21797 messages
2014-06-17 20:18:53FazJaxtoncreate