Hum, not sure if I understand your question.

When MH do your scan, which I believe should be every few seconds,
your while(</commands/*.x10>)  will do a sort on the filenames
and run the script for every files in the /commands directory. After it did process the file, the unlink
will erase the file, so I  would  use a filename like "x10.#####", where ##### could be the value
returned by the time(), in perl, or the value from the command date "+%s". This will return
the number of second since 1970. You will never get the same number unless you have 2 events
happening in 1 second. Doing so, you will be sure the sort will done from the oldest to the newest,
because the sort done by the while command is done from the 0 to 9 (ascending). Remember the file is erase by the unlink,
so once it has been processed, it will not be again. Instead of doing an unlink, you could rename the file
like "Done_X10.######", so you could keep a trace of what was handle by MH, and also this name
will not be catch again by the while loop.

Hope this answer your Q, if not try to be more precise.


Kurt André Selbach wrote:
Hi!

This sounds like a very nice idea, and it's well expandable.

Now i have a program which reads the /dev/cm19a fifo/device file, and
put's these into /commands/*.x10

Misterhouse now sees these files and scans them via your code, and
gives me the external input. /just what i wanted.

But there is one thing. if i expand this system, how can i be sure
misterhouse allways opens the last files first?(date checking)
"while (</commands/*.x10>) {" <--is the only thing i modified in your code.

I think a problem might occure if i get
+b1
-b1
within the new "scan" - and since it's going to control heating - i
want it to be as reliable as it can :)

once again, thank you all for reply!


On 3/24/06, Gaetan Lord <misterhouse@gaetanlord.ca> wrote:
  
Hi Kurt

As Matthew said, telnet is a solution, but I will  suggest you another one.
I have many systems in my house that have message to be speak on the
speaker. I have a mechanism to
send them on my misterhouse system, and put them in a file, then
misterhouse detect a new file
and speak the content.

What I would suggest, is to use the same things to achieve what you want.
If your external apps could write the value in a file, let say you put
this information
in /tmp/extinput.

Then the following code will set $Input to the content of the file

my $Input;
if ( new_second ) {
while (</tmp/extinput>) {
      my $File = $_;
      open F, "$File " or  print_log "Can't open file $_ to process
external  input";

      $Input = '';
      while (<F>) {
         chomp;
         $Input =  $_;
      }
      close F;
      print_log "Receive external input : $Input" if $Input ne '';
      unlink $File;
   }
}




Note, the new_second will allow you to scan the directory once a second,
to reduce load. This
could be set to a bigger value, see the doc.

Also, this assume that extinput will not be written more than once a
second. If you write more,
than a slightly different version of this script need to be use.

Hope this help

Kurt André Selbach wrote:
    
Hi misterhouse users!

First i need to say that misterhouse is very amazing, and works great.

I got one question.

When misterhouse is looping my perl scripts, X times a second, i want
it to be able to get data from an external process.

the $input (in this case the string A1ON) should be set from a
terminal, for example:
/opt/misterhouse/bin/misterhouse A1ON

if ($input eq 'A1ON') {
 print_log " A1ON MOTION DETECTED";
}
elsif ($input eq 'A1OFF') {
 print_log " A1OFF Silence ";
}
else
{
 #No input.
}

There might be other ways of doing this, but since i know how to get
these messages from my cm19a, and i havent found much information
about cm19a, and misterhouse. i think this would be the easiest way:


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
________________________________________________________
To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id65

      

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
________________________________________________________
To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id65


    


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
________________________________________________________
To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id65