[Gambas-user] Writing to sysfs

Andrew Barr andrew.james.barr at ...626...
Wed Apr 9 17:32:04 CEST 2008


I am writing a control panel for Thinkpad laptops that basically acts as a 
graphical front end to the tp_smapi driver. It allows the user to display 
information about installed batteries and set some vendor-specific settings, 
such as threshold percentages to start/stop charging at. To do this, the 
program must read and write to nodes in sysfs. I have had no problem reading 
from sysfs using the OPEN and LINE INPUT statements, but I am encountering an 
invalid argument error when using OPEN and WRITE or PRINT to write the user's 
preferences to sysfs. Normally, this sort of thing is done by way of 
the 'echo' command, for example:

# echo 0 > /sys/devices/platform/smapi/BAT0/force_discharge

would disable forced discharging of the battery. Permissions are correct for 
the user that the GUI program is running under, and I can confirm by use of 
the '-n' switch to echo that the carriage return being there or not makes no 
difference to either Gambas or the sysfs interface.

Ideas, anyone?
-- 
Andrew Barr

"Come ride with me, through the veils of history. I'll show 
you how God falls asleep on the job." 
   --Muse, "Knights of Cydonia"




More information about the User mailing list