Reading of the "/dev/piControl0" file

Topics about the Software of Revolution Pi
Post Reply
Patrick
Posts: 3
Joined: 05 Nov 2017, 17:43

Reading of the "/dev/piControl0" file

Post by Patrick »

I try to read and write to the Picontrol0 file.
I can read and write but i have problems with the logging.
The "/var/log/kern.log" becomes huge, and the revpi is no longer available (rotation daily)
What is wrong, can I disable the logging?

logging data:
===========
piControl 0:piControlOpen
opened 1 instance
Invalid Ioctl
piControlRelease
close instance 1/1

CODE:
======
with open("/dev/piControl0","rb",0) as f:
#underscores are a tab
___f.seek(523,0)
___data = f.read(128)
User avatar
RevPiModIO
KUNBUS
Posts: 335
Joined: 20 Jan 2017, 08:44
Contact:

Re: Reading of the "/dev/piControl0" file

Post by RevPiModIO »

I think it is because the open function of python is checking if the file could be a tty device... And it will do this by sending ioctl requests to the file handler.

If you do this, the log messages will appear:

Code: Select all

fd = open("/dev/piControl0", "rb+")
fd.isatty()
fd.isatty()
fd.isatty()
fd.isatty()
fd.close()
So, open the file just one time in you program, or use os.open(...) to create a file handler and work with the os.read, os.write functions in python...

Maybe Kunbus can fix that in the piControl device driver.

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
User avatar
lukas
Expert
Posts: 186
Joined: 13 Feb 2017, 10:29

Re: Reading of the "/dev/piControl0" file

Post by lukas »

I concur with Sven's comments: Opening the device file just once seems desirable from a performance perspective anyway and should also reduce the messages.

With a contemporary piControl version, only a single message should be logged, namely the "Invalid Ioctl" one. All the others were silenced by a commit pushed in July 2017. I've just pushed another commit to tone down the remaining message to debug severity, so if you build your own kernel and piControl with kernelbakery now, all the messages should be gone.
Post Reply