Hello Roberto,

Very nice work.

I found the documentation at the end of the file (as you had said) and have
a few comments:

A. I dont believe there is a default port for owserver.
B. The difference between the "scheme" stream and ow-stream must make
sense in PHP context (it doesn't to me). Would this be obvious to a
PHP programmer, or should you make an arbitrary decision for them and
offer this only as an "advanced" configuration option?
C. Your "get" method is "overloaded" -- directory lists and file
contents. We do this in owphp because we link in the OWFS library and
have the path parsing engine available. I see that you have a
primative test (trailing slash) for distinguishing directories, but
probably realized that allowing users to specify made more sense.
In the owshell programs, which also don't have the library linked in,
I just separate out read, dir and presence. That may be more intuitive
to your users.
The actual design and interface is entirely your choice, and perhaps
an overloaded "get" makes more sense in PHP.

When it's ready, I'd like to include this in the mainline OWFS package.

Paul Alfille

/*
explanation:


EVERY FUNCTION TRIGGER AN ERROR! you should use @$ow->function to
don't handle errors


$ow=new OWPhp($host);
   in top of file we have some constants: (line 58)
       define('OWPHP_DEFAULT_HOST'    ,'127.0.0.1');
       define('OWPHP_DEFAULT_PORT'    ,1234);
       i don't know what's the default OW port, i'm using today 1234 :)
   for OWPhp($host) we can use this types of host value:
   "scheme://host:port" "scheme://host" "anything that can't be
parsed with parseurl"
   if port isn't set we get default port, if host isn't set we get default host
   if scheme == "stream" or scheme == "ow-stream"
      we will prefer to use PHP stream_socket_client functions
      else if function socket_create exists we will use
socket_connect() with sockets we can set TCP_NODELAY SO_REUSEADDR
SO_OOBINLINE(we use it?)  SO_RCVBUF SO_SNDBUF
$ow->setHost($host)
   is the same thing that new OWPhp($host)
$ow->getHost()
   get host URI
      owstream://host:port if using stream_socket_client
      ow://host:port if using sockets
$ow->setTimeout($timeout=5)
   set read timeout, default 5
$ow->getTimeout()
   get read timeout
$ow->set($path,$value='')
   set an value to path
   true on success
   false on error or if file is readonly
$ow->get($path='/',$get_type=OWPHP_MSG_READ_ANY,$return_full_info_array=false,$parse_php_type=true)
   on error return NULL
   get_type can be:
      OWPHP_MSG_READ (execute OWPHP_MSG_READ and if don't find
execute OWPHP_MSG_DIR)
      OWPHP_MSG_READ *default
         read an file from owserver
      OWPHP_MSG_DIR
         read an dir from owserver
      OWPHP_MSG_PRESENCE
         read presence from owserver (return false or true)
   return_full_info_array
      if true return an array with everything that was received from
owserver more data_php and unit if file is an temperature value
   parse_php_type
      try to check what type is an file (temperature, boolean,
string, number (double or integer))
END :)

examples:

$ow=new OWPhp("tcp://172.16.1.100:1234");
var_dump($ow->get("/",OWPHP_MSG_DIR,true));
var_dump($ow->get("/10.E8C1C9000800/temperature",OWPHP_MSG_READ,true));
var_dump($ow->get("/10.E8C1C9000800",OWPHP_MSG_PRESENCE,true));
var_dump($ow->get("/WRONG VALUE",OWPHP_MSG_PRESENCE,true));

var_dump($ow->get("/",OWPHP_MSG_DIR,false));
var_dump($ow->get("/10.E8C1C9000800/temperature",OWPHP_MSG_READ,false));
var_dump($ow->get("/10.E8C1C9000800",OWPHP_MSG_PRESENCE,false));
var_dump($ow->get("/WRONG VALUE",OWPHP_MSG_PRESENCE,false));




On 12/19/06, Roberto Spadim <[EMAIL PROTECTED]> wrote:

Hello guys i end the PHP class (OWPhp) for OWServer
all tests worked, if anyone can debug it could be very gooood :)
bye
Roberto Spadim


download link:
www.spadim.com.br/owphp.php.txt

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to