Unix Device File Emulation

blaine frikker at gmail.com
Wed Apr 23 17:02:30 CEST 2008


Hey everyone,
  So I've got a quick query for advice.

  We have an embedded device in which we are displaying to an LCD
device that sits at /dev/screen.  This device is not readily available
all the time, so I am needing to write an emulator.  This will
basically just monitor a file, /dev/screen for example, and write the
commands to a TK or WxWindows canvas.

So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0)
to (10,10).

My question: Whats the best way to set up a monitor (in python) of
this file? Would I simply open up the file for read, check for
changes, get any updated data, and clear the file? Or is there some
standard way of doing something like this that guarantees no overlap
or data loss?

example usage: echo 'line 0 0 10 10' > /dev/screen

On the actual embedded device this is handled by a kernel module.  We
can spit commands into it as fast as we can and the kernel module can
keep up.  This is typical unix device file behavior.

Any suggestions or advice would be splendid.  Thanks!
Blaine



More information about the Python-list mailing list