[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help with powerbutton handling



A little step forward.

There's a "buttond_service.pyc" that seems to be able to handle the button pressing:

class ButtondService(persistent_service.PersistentService):
    """ Buttond Service Class """
[...]
    def _worker(self):
        """
        _worker method (override from superclass)
        """
        input = self.__button.get_data()
        event_struct_size = struct.calcsize(FORMAT_INPUT_EVENT)
        event_num = len(input) / event_struct_size
        event_queue = Queue.Queue()
[...]
                            if button[BTN_ACTION_TYPE] == 'internal':
                                try:
                                    action_func = self.__action_functions[button[BTN_ACTION_NAME]]

But... I can't find when that _worker method will get called.
I don't see where this service is somehow registered to receive button events.

Can anybody help?


On Mon, Oct 6, 2014 at 10:18 AM, Dario Piantanida <dario.piantanida@gmail.com> wrote:
Hello, I have an LG NAS based on Debian 6, armel arch.
I have root access on it.

I recently broke a couple of things on it, but now it's almost back.
I found it is highly customized about services to start and other system handling.

The last thing I haven't been able to restore is the handling of the powerbutton: before me touching things, I could turn it off keeping it pressed for 2/3 seconds; a longer press would turn it off immediately.

Now it loose the 2/3 seconds reaction, I must log in and shutdown manually.

I found some ACPI scripts and services, but they all start with a testing of an env variable "micom" that it must not be set to "emul", otherwise they exit instantly.

As "micom" is not "emul", they are useless.
I even tried starting "acpid -f" from command line, but it says it lacks some "input" file somewhere, so the handling must be something custom again.

The whole NAS platform is started from a bunch of python scripts and I found they do list the button reactions, listing "shutdown" with code 45, but I can't understand how it gets called.

This is the action defined:
    @classmethod
    def action_shutdown(cls):
        """ action shutdown - evnet code: 45 """
        buzzer.Buzzer().enable()
        initd.Initd().shutdown()

If I search for "action_shutdown" in the scripts, I find:

class ButtondService(persistent_service.PersistentService):
    """ Buttond Service Class """
    _sleep_duration = 0
    __button = None
    __action_functions = {'IP_DHCP': button_action.ButtonAction.action_ip_dhcp,
[...]
     'SHUTDOWN': button_action.ButtonAction.action_shutdown,
[...]
    __conf_table = []
    __conf_table_file = '/etc/nas/button.conf'

/etc/nas/button.conf is a list of buttons and codes.

Searching for SHUTDOWN, I find it is used in here:
    @classmethod
    def _shutdown(cls, args):
        """ Stop all service and umount volumes under platformd

This function is mapped in an array:
class SystemService(EphemeralService):
    """ System Service Class """
    _locked = False
    _actions = {'get_greeting': ['_get_greeting', ()],
[...]
     'shutdown': ['_shutdown', ()],

I then lose traces of the calls and I'm not sure what really should triggers these calls.

Can anybody suggest any string I could search for to understand what system event would trigger a powerbutton press reaction?

Thank you!


Reply to: