Strange situation: pyownet is talking to an owserver, all the handshakes go 
well, but owserver replies with error code 5.

A few handy commands to debug the problem.

1) identify the process with which pyownet is speaking

from python:
>>> from pyownet.protocol import proxy
>>> owp = proxy(host="localhost")
>>> print(owp)
owserver at ('127.0.0.1', 4304)

from the shell:
$ sudo ss -lpt '( sport = :4304 )'
State            Recv-Q           Send-Q                     Local Address:Port 
                     Peer Address:Port           
LISTEN           0                128                              0.0.0.0:4304 
                          0.0.0.0:*               
users:(("owserver",pid=318,fd=13))

2) enable verbose logging

from python:
>>> owp.verbose = True
>>> owp.dir('/nonexistent')
('127.0.0.1', 59204) -> ('127.0.0.1', 4304)
-> _ToServerHeader(version=0, payload=13, type=9, flags=0, size=0, offset=0)
.. b'/nonexistent\x00'
<- _FromServerHeader(version=0, payload=0, ret=-1, flags=0, size=0, offset=0)
('127.0.0.1', 59204) xx ('127.0.0.1', 4304)
('127.0.0.1', 59204) XX ('127.0.0.1', 4304)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/pyownet/lib/python3.7/site-packages/pyownet/protocol.py", line 
600, in dir
    raise OwnetError(-ret, self.errmess[-ret], path)
pyownet.protocol.OwnetError: [Errno 1] Startup - command line parameters 
invalid: '/nonexistent'

(here I demonstrate how my owserver replies with error code 1 to the attempt of 
listing a nonexistent node)
from owserver 

from owserver:
$ sudo systemctl stop owserver
$ sudo /usr/bin/owserver —debug <your device here>

… lots of debug messages …

  DEBUG: from_client.c:(65) FromClient payload=13 size=0 type=9 sg=0x0 offset=0
  DEBUG: from_client.c:(73) FromClient (no servermessage) payload=13 size=0 
type=9 controlflags=0x0 offset=0
  DEBUG: ow_tcp_read.c:(63) attempt 13 bytes Time: 10.000000 seconds
  DEBUG: ow_tcp_read.c:(113) read: 13 - 0 = 13
  DEBUG: handler.c:(152) START handler /nonexistent
   CALL: data.c:(103) DataHandler: parse path=/nonexistent
  DEBUG: ow_parseobject.c:(163) /nonexistent
   CALL: ow_parsename.c:(174) path=[/nonexistent]
  DEBUG: ow_regex.c:(53) Not found
  DEBUG: ow_regex.c:(53) Not found
  DEBUG: ow_cache.c:(1643) Lookup of nonexistent unsuccessful
  DEBUG: ow_cache.c:(1601) Finding nonexistent unsuccessful
  DEBUG: ow_remote_alias.c:(179) Remote alias for /nonexistent not found
  DEBUG: ow_parsename.c:(234) Set error to 27 <Path - bad path syntax>
  DEBUG: ow_parsename.c:(133) /nonexistent
  DEBUG: data.c:(106) DataHandler: OWQ_create failed cm.ret=-1
  DEBUG: data.c:(207) DataHandler: cm.ret=-1
  DEBUG: to_client.c:(75) payload=0 size=0, ret=-1, sg=0x0 offset=0 
  DEBUG: to_client.c:(84) No data
  DEBUG: data.c:(226) Finished with client request
  DEBUG: handler.c:(134) OWSERVER handler done
  DEBUG: ow_net_server.c:(259) Normal completion.

Please note here that you can correlate the outgoing packet from pyownet, 

-> _ToServerHeader(version=0, payload=13, type=9, flags=0, size=0, offset=0)
.. b'/nonexistent\x00’

with the incoming packet in owserver, and its subsequent preocessing:
  DEBUG: from_client.c:(65) FromClient payload=13 size=0 type=9 sg=0x0 offset=0
and the subsequent processing, 
  DEBUG: handler.c:(152) START handler /nonexistent
which end with error code -1
  DEBUG: data.c:(207) DataHandler: cm.ret=-1

Similarly you can correlate the outgoing owserver packet to the incoming 
owserver packet
  DEBUG: to_client.c:(75) payload=0 size=0, ret=-1, sg=0x0 offset=0 
  DEBUG: to_client.c:(84) No data
<- _FromServerHeader(version=0, payload=0, ret=-1, flags=0, size=0, offset=0)

3) try the obivous things: a mix of restart/reboot/voodo magic to see if the 
problem disappears ;-)


By comparing the verbose pyownet log with the owserver one you should be able 
to pinpoint the problem.

Good luck!

Stefano

> On 9 Nov 2019, at 15:44, Mick Sulley <m...@sulley.info> wrote:
> 
> I am using pyownet on a few Raspberry Pi systems, but one has stopped 
> working.  I have updated the OS, removed and reinstalled pyownet and it still 
> fails.  This is what I see -
> 
> pi@pi3ether:~ $ python3
> Python 3.7.3 (default, Apr  3 2019, 05:39:12)
> [GCC 8.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from pyownet.protocol import proxy
> >>> owp = proxy(host='localhost')
> >>> owp.dir()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python3.7/dist-packages/pyownet/protocol.py", line 
> 600, in dir
>     raise OwnetError(-ret, self.errmess[-ret], path)
> pyownet.protocol.OwnetError: [Errno 5] legacy - IO error: '/'
> >>>
> 
> If I run owdir from command line I get the sensor listing as expected.  I 
> have tried with python 2.7 as well with the same result.  Running the above 
> on another Pi works as expected.
> 
> I could reinstall Raspbian and start again, but I would like to understand 
> what has gone wrong.  Any ideas?
> 
> Thanks
> 
> Mick
> 
> 
> 
> _______________________________________________
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers

_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to