Re: Low level I/O: because I could

2017-05-10 Thread eryk sun
On Wed, May 10, 2017 at 10:30 PM, Rob Gaddi wrote: > Sorry, but I'm just too proud of this. > > Given that you have: > > class RegisterLayout(ctypes.Structure): > ...yadayadayada... > > You can then: > > fh = os.open('/dev/devicethingy', os.O_RDWR) > mm = mmap.mmap(fh, ctypes.sizeof(Regi

Low level I/O: because I could

2017-05-10 Thread Rob Gaddi
Sorry, but I'm just too proud of this. Given that you have: class RegisterLayout(ctypes.Structure): ...yadayadayada... You can then: fh = os.open('/dev/devicethingy', os.O_RDWR) mm = mmap.mmap(fh, ctypes.sizeof(RegisterLayout)) registers = RegisterLayout.from_buffer(mm) And it jus