PIC Control Software
From QNAP-Wiki
Contents |
About
Most of the Marvell Orion based devices have a microcontroller that is used to control the power state, LEDs, buttons, buzzer, etc. Usually this is connected to the second UART so the easiest way to implement this functionality is in userspace.
Status
The current release is only to get general feedback on how this program is designed to work. There are still a lot of features to implement and a lot of code cleanup to do.
The following devices are partially supported:
- TS-209 (minimum v0.2, v0.4.1 for reset/usb buttons)
TODO
- A method of clean shutdown for the server
- Ability to detect if /tmp/qcontrol.sock has nothing at the other end when starting up
- Run as a daemon process
- Error handling for the config file
Known Bugs
- After running the server once and killing it, starting again will fail with "Error binding to socket: Address already in use", delete /var/run/qcontrol.sock and try again
Download
The latest version is available from http://code.google.com/p/qcontrol/
Instructions
The Lua 5.1 headers/libraries are required to build qcontrol. The following will extract and build qcontrol then run the server process in debug mode:
tar xzf qcontrol-0.4.2.tar.gz
cd qcontrol-0.4.2
make
./qcontrol -d
You can then execute control commands in another window:
./qcontrol powerled on|off|1hz|2hz
./qcontrol statusled red2hz|green2hz|greenon|redon|greenred2hz|off|green1hz|red1hz|greenred1hz
./qcontrol usbled on|off|8hz
./qcontrol fanspeed stop|silence|low|medium|high|full
./qcontrol buzzer short|long
Config file
qcontrol currently reads from /etc/qcontrol.conf. This file is written in Lua and registers the appropriate modules with qcontrol. An example for the QNAP TS-209 is below:
register("ts209")
register("evdev", "/dev/input/event0",
116, "restart_button",
408, "media_button")
function power_button( time )
os.execute("poweroff")
end
fanfail = 0
function fan_error( )
fanfail = fanfail + 1
if fanfail == 3 then
print("ts209: fan error")
piccmd("statusled", "red2hz")
piccmd("buzzer", "long")
else
if fanfail == 10 then
fanfail = 0
end
end
end
function fan_normal( )
piccmd("statusled", "greenon")
fanfail = 0
end
function temp_low( )
piccmd("fanspeed", "silence")
end
function temp_high( )
piccmd("fanspeed", "full")
end
function restart_button( time )
os.execute("reboot")
end
function media_button( time )
piccmd("usbled", "8hz")
end

