Message220877
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. |
|
Date |
User |
Action |
Args |
2014-06-17 20:18:53 | FazJaxton | set | recipients:
+ FazJaxton |
2014-06-17 20:18:53 | FazJaxton | set | messageid: <1403036333.47.0.341368949906.issue21797@psf.upfronthosting.co.za> |
2014-06-17 20:18:53 | FazJaxton | link | issue21797 messages |
2014-06-17 20:18:53 | FazJaxton | create | |
|