Hello,

I have traced this to a behavior in the igdaemon associated to my IguanaWorks IR transceiver.
I'm contacting them about the issue.  Thanks.

- Scott


On Sat, Nov 30, 2013 at 2:08 PM, Scott Borisch <scott.borisch@gmail.com> wrote:
Hello,

I am using LIRC, but specifically, I am using LIRC with IguanaWorks iguanaIR support.
Here was my installation procedure:

===================================

1) Add
/etc/atp/sources.list

2) Run
apt-get update
apt-get install iguanair

3) Compile LIRC with Iguana support:

Compile LIRC into .deb package

Most Linux distro’s include binaries of LIRC, but those binaries are compiled without support for the IguanaIR driver. So, to use our device under LIRC, you need to compile LIRC with support for our driver. Thankfully, on .deb systems, this can be done is 6 steps:

  1. Add our debian repository to your /etc/apt/sources.list file
  2. Install our software with “sudo apt-get install iguanair”
  3. If not already added, add your distro’s source repository to you /etc/apt/sources.list (often can be done via package manager gui, depending on the distro)
  4. Get what is needed to compile LIRC with “sudo apt-get build-dep lirc”
  5. Compile LIRC with “sudo apt-get -b source lirc”
  6. Now that command will have created lirc binaries in the parent directory. You can install that binary with “sudo dpkg -i lirc-VERSION.deb”

===================================

What I have noticed is that sometimes, when I run the command:

sudo /usr/sbin/lircd --driver=iguanaIR --device=iguana > lircd.log 2> lircd.err

and then the command:

/usr/bin/irw > irw.log 2> irw.err

to start lircd and irw, that sometimes lircd works, and some times it does not.
By does not work, I mean that lircd returns nothing to either stderr and stdout,
and neither does irw.

In these cases where lircd seems to fail, if I run:

ps aux | grep lircd, I get:

root      4015  0.0  0.0   3476   696 ?        Ss   13:48   0:00 /usr/sbin/lircd --driver=iguanaIR --device=iguana

but when lircd works, ps aux | grep lircd returns: 

root      3982  0.0  0.0   3476   516 ?        Ss   13:56   0:00 /usr/sbin/lircd --driver=iguanaIR --device=iguana
root      3985  0.0  0.0   3476   384 ?        S    13:56   0:00 /usr/sbin/lircd --driver=iguanaIR --device=iguana

This issue is a boot correlated issue.
Once it fails, it fails every time, until I reboot,
and likewise for when it works.

Any ideas?  Any log files I can look at to debug this?
Thanks.

BTW, I am using a python script to automate the process, to be sure that
I am running the exact same procedure every time.

python function listed below:

======================================

def start_process():

  # Force /etc/sudoers to take effect.
  # Why is this needed?
  cmd = 'sudo ls'
  (so,se,rc) = call_cmd_line(command=cmd,wait_on_response=True,die_on_std_error=True,
         print_std_out=True,print_std_err=True,echo_cmd=True,
         die_on_return_code=True,timeout_in_sec=60)
  

  #Check if process is running, if so, kill it
  proc_list = []
  proc_list.append(r"/usr/sbin/lircd")
  proc_list.append(r"/usr/bin/irw")  
  cmd = 'ps aux'
  (so,se,rc) = call_cmd_line(command=cmd,wait_on_response=True,die_on_std_error=True,
         print_std_out=g_dbg,print_std_err=g_dbg,echo_cmd=g_dbg,
         die_on_return_code=True,timeout_in_sec=60)
  so_list = so.split("\n")
  for line in so_list:
    item_list = cleanup_ps_aux(line)
    print "item_list is (postfilter):\n"+str(item_list)+"\n\n"    
    try:
      pid = item_list[1]
    except:
      print "Line has no pid:\n"+line+"\n\n"
      continue
    for proc in proc_list:
      m = re.search(proc,line)
      if m:
        print "Kill pid "+str(pid)+" for process "+str(proc)+"\n\n"
        cmd = 'sudo kill -9 '+pid
        (so,se,rc) = call_cmd_line(command=cmd,wait_on_response=True,die_on_std_error=True,
         print_std_out=True,print_std_err=True,echo_cmd=True,
         die_on_return_code=False,timeout_in_sec=60)        
        if ((rc != 1) and (rc != 0)):
          raise RuntimeError, "expected return code is 1, got **"+str(rc)+"** for cmd:\n"+cmd+"\n\n" 
      #endif
    #endfor
  #endfor

  # Delete any old log files
  cmd_list = []
  cmd_list.append('/bin/rm irw.log')
  cmd_list.append('/bin/rm irw.err')
  cmd_list.append('/bin/rm lircd.log')
  cmd_list.append('/bin/rm lircd.err')  
  for cmd in cmd_list:
    try:
      call_cmd_line(command=cmd,wait_on_response=True,die_on_std_error=True,
             print_std_out=g_dbg,print_std_err=g_dbg,echo_cmd=g_dbg,
             die_on_return_code=True,timeout_in_sec=60)
    except:
      pass
  #endfor
  
  # Restart lircd, irw
  #
  # The approach to solve your problem is to put your user in sudoers file, like you can see.
  # Open terminal window and type:
  # sudo visudo
  # In the bottom of the file, type the follow:
  # username ALL=(ALL) NOPASSWD: ALL

  cmd_list = []
  cmd_list.append('sudo /usr/sbin/lircd --driver=iguanaIR --device=iguana > lircd.log 2> lircd.err')
  cmd_list.append('/usr/bin/irw > irw.log 2> irw.err')
  for cmd in cmd_list:
    call_cmd_line(command=cmd,wait_on_response=False,die_on_std_error=True,
           print_std_out=True,print_std_err=True,echo_cmd=True,
           die_on_return_code=True,timeout_in_sec=60)
    print "Wait for:\n"+cmd+"\n\n"
    time.sleep(2)

  # Make sure lircd processes started:
  # Emperically, if they aren't both present, it won't work, 
  # AND we get no error messages for some reason.
  #
  # root      4039  0.0  0.0   3476   520 ?        Ss   11:13   0:00 /usr/sbin/lircd --driver=iguanaIR --device=iguana
  # root      4042  0.0  0.0   3476   392 ?        S    11:13   0:00 /usr/sbin/lircd --driver=iguanaIR --device=iguana
  
  stat_cmd_list = []
  stat_cmd_list.append(('Ss','/usr/sbin/lircd'))
  stat_cmd_list.append(('S', '/usr/sbin/lircd'))  
  cmd = 'ps aux'
  (so,se,rc) = call_cmd_line(command=cmd,wait_on_response=True,die_on_std_error=True,
         print_std_out=g_dbg,print_std_err=g_dbg,echo_cmd=g_dbg,
         die_on_return_code=True,timeout_in_sec=60)
  so_list = so.split("\n")
  found_match_dict = {}
  found_match_dict['Ss'] = False
  found_match_dict['S']  = False
  for line in so_list:
    item_list = cleanup_ps_aux(line)
    print "item_list is (postfilter):\n"+str(item_list)+"\n\n"    
    try:
      stat = item_list[7]
      cmd  = item_list[10]
      #print "stat is:\n"+stat+"\n"
      #print "cmd is:\n"+cmd+"\n"
    except:
      print "Line has no stat and/or cmd:\n"+line+"\n\n"
      continue
    for (exp_stat,exp_cmd) in stat_cmd_list:
      m_stat = re.search(exp_stat,stat)
      m_cmd  = re.search(exp_cmd,cmd)
      print "exp_stat is: "+exp_stat+", exp_cmd is "+exp_cmd+"\n"
      print "stat is: "+stat+", cmd is "+cmd+"\n\n"      
      if (m_stat and m_cmd):
        print "Found match for: "+exp_stat+", "+exp_cmd+"\n\n"
        found_match_dict[stat] = True
      #endif
    #endfor
  #endfor
  for (key,value) in found_match_dict.items():
    if (value is False):
      raise RuntimeError, "Failed to find processes with STAT: "+key+\
                          "\nso is:\n"+str(so)+"\n\n"
    #endif
  #endfor

  if (g_dbg is True): print "Exit: start_process\n\n"
  
#enddef start_process


- Scott