Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-28 Thread Martin Patzak
 Stefano, thank you for the summary, most appreciated 
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-27 Thread Stefano Miccoli via Owfs-developers
I have no experience with the DS2413, but if I understand correctly the manual, 
here is a list of valid commands:

owproxy.write('device_id' + '/PIO.A, b'1’)  # A on
owproxy.write('device_id' + '/PIO.A, b’0’)  # A off

owproxy.write('device_id' + '/PIO.B, b'1’)  # B on
owproxy.write('device_id' + '/PIO.B, b’0’)  # B off

owproxy.write('device_id' + '/PIO.ALL, b’1,1’)  # both on
owproxy.write('device_id' + '/PIO.ALL, b’0,0’)  # both off

owproxy.write('device_id' + ‘/PIO.BYTE', b’\x03’)   # both on
owproxy.write('device_id' + ‘/PIO.BYTE', b’\x00’)   # both off

In fact from the Manual page DS2413(3):

   PIO.A PIO.B PIO.ALL PIO.BYTE
   read-write, yes-no
   State of the open-drain output ( PIO ) pin. 0 = non-conducting (off), 1
   = conducting (on).
   Writing  zero  will  turn  off  the  switch,  non-zero will turn on the
   switch. Reading the PIO state will return the switch setting. To deter-
   mine  the  actual  logic level at the switch, refer to the sensed prop-
   erty.
   ALL references both channels simultaneously, comma separated.
   BYTE references both channels simultaneously as  a  single  byte,  with
   channel A in bit 0.

If I got this right, then owserver on PIO.A is expecting a single byte, with 
character ‘1’ or ‘0’, ascii encoded ( python literals b’1’ or b’0’). PIO.BYTE 
instead is a single byte in which bit 0 is channel A, and bit 1 is channel B, 
so here I have to transmit a byte with integer values 0, 1, 2, or 3, (python 
literals b’\x00’, b’\x01’, b’\x03’, b’\x03’). PIO.ALL should be 3 bytes, e.g. 
b’0,1’.

Just to clarify the python3 literals:

>>> b'1' == b'\x31'
True
>>> b'0' == b'\x30'
True
>>> bytes.fromhex('00')
b'\x00'
>>> bytes.fromhex('deadbeef')
b'\xde\xad\xbe\xef'
>>> bytes(range(8))
b'\x00\x01\x02\x03\x04\x05\x06\x07'

Hope this helps.

Stefano

> On 27 Aug 2020, at 19:47, Mick Sulley  wrote:
> 
> Yes I have struggled with that as well.  I have discovered how to do it, but 
> I don't really understand why.
> 
> The answer seems to be that to write a 1 you need
> 
> owproxy.write('device_id' + '/PIO.BYTE, b'1')
> 
> so you need to write the byte value of the string 1, not the byte value of 
> the integer 1.  As I say, I don't understand why that is so, I dabble with 
> Python, I'm far from expert :)
> 
> Hope that helps
> 
> Mick
> 
> On 27/08/2020 15:18, Dennis Putnam wrote:
>> Hi Martin,
>> 
>> See embedded comments.
>> 
>> On 8/27/2020 2:56 AM, Martin Patzak wrote:
>>> 
>>> what does onOff.to_bytes(1,byteorder=sys.byteorder)) evaluate to? Is that 
>>> resulting in a byte-value? I am not familiar with this...
>> This seems to be the crux of the problem. After a lot of testing it appears 
>> to be a python 3 issue converting an integer to a byte string. I am 
>> convinced that passing a byte string to the write function is the problem. 
>> Thanks for everyone's help but this is not an owfs problem.
>>> 
>>> Things you could try:
>>> In the path use the fully qualifying path and add /uncached and write a 
>>> byte-value like this 
>>> owproxy.write('/uncached/3A.0BE14D00/PIO.BYTE',b'0')
>>> write to the individual outputs PIO.A or PIO.B directly
>>> try reading the sensed values print('sensed.BYTE = ', 
>>> owp.read('/uncached/3A.0BE14D00/sensed.BYTE')
>>> 
>>> On 26.08.20 21:05, Dennis Putnam wrote:
 I have rewritten my code to use pyownet but am now nearly back where I 
 started. I have the following code:
 
 owproxy.write('/3A.'+blower.id_+'/PIO.BYTE',onOff.to_bytes(1,byteorder=sys.byteorder))
 
 That statement gives me the following error:
 
 pyownet.protocol.OwnetError: [Errno 22] legacy - Invalid transaction: 
 '/3A.0BE14D00/PIO.BYTE'
 
 The error is meaningless to me. The path is not wrong so is it complaining 
 about writing a single byte?
 
 Thanks again.
 
 On 8/24/2020 4:33 PM, Dennis Putnam wrote:
> Thanks to everyone that replied. I was not aware of pyownet. I will look 
> into that and rewrite my code to use it.
> 
> On 8/24/2020 11:47 AM, Martin Patzak wrote:
>> For python I would highly recommend you use the library pyownet by 
>> Stefano Miccoli
>> https://github.com/miccoli/pyownet/ 
>> 
>> using Fuse can lead to weird problems... (not saying that it is the 
>> reason in your specific case)
>> 
>> or you can use the buil-in functions in owserver  owread/owwrite/owdir 
>> instead.
>> 
> 
 
 
  
 
Virus-free. www.avast.com 
 
  
>> 
>> 
>> 
>> 
>> ___
>> Owfs-developers mailing list
>> Owfs-developers@lists.sourceforge.net 

Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-27 Thread Mail Lists
Hi Guys,
I’m pretty “late to the party” but In April this year I upgraded my RPi to the 
latest Debian packages to read all my DS28EA00 sensors and ran into issues with 
some of the sensor subfields had disappeared, namely “temphigh” And “templow” 
and needed to patch the source code and rebuild the package and then it was all 
good again. 

You might want to just double check that you can do read/write commands to the 
PIO.BYTE using the shell command line tools (owdir owread, owwrite) to make 
sure its not a owfs core issue.

HTH

Alex Shepherd 

Sent from my iPad

>> On 28/08/2020, at 5:48 AM, Mick Sulley  wrote:
> 
> Yes I have struggled with that as well.  I have discovered how to do it, but 
> I don't really understand why.
> 
> The answer seems to be that to write a 1 you need
> 
> owproxy.write('device_id' + '/PIO.BYTE, b'1')
> 
> so you need to write the byte value of the string 1, not the byte value of 
> the integer 1.  As I say, I don't understand why that is so, I dabble with 
> Python, I'm far from expert :)
> 
> Hope that helps
> 
> Mick
> 
> On 27/08/2020 15:18, Dennis Putnam wrote:
>> Hi Martin,
>> 
>> See embedded comments.
>> 
>>> On 8/27/2020 2:56 AM, Martin Patzak wrote:
>>> 
>>> what does onOff.to_bytes(1,byteorder=sys.byteorder)) evaluate to? Is that 
>>> resulting in a byte-value? I am not familiar with this...
>> This seems to be the crux of the problem. After a lot of testing it appears 
>> to be a python 3 issue converting an integer to a byte string. I am 
>> convinced that passing a byte string to the write function is the problem. 
>> Thanks for everyone's help but this is not an owfs problem.
>>> 
>>> Things you could try:
>>> In the path use the fully qualifying path and add /uncached and write a 
>>> byte-value like this 
>>> owproxy.write('/uncached/3A.0BE14D00/PIO.BYTE',b'0')
>>> write to the individual outputs PIO.A or PIO.B directly
>>> try reading the sensed values print('sensed.BYTE = ', 
>>> owp.read('/uncached/3A.0BE14D00/sensed.BYTE')
>>> 
>>> On 26.08.20 21:05, Dennis Putnam wrote:
 I have rewritten my code to use pyownet but am now nearly back where I 
 started. I have the following code:
 
 owproxy.write('/3A.'+blower.id_+'/PIO.BYTE',onOff.to_bytes(1,byteorder=sys.byteorder))
 
 That statement gives me the following error:
 
 pyownet.protocol.OwnetError: [Errno 22] legacy - Invalid transaction: 
 '/3A.0BE14D00/PIO.BYTE'
 
 The error is meaningless to me. The path is not wrong so is it complaining 
 about writing a single byte?
 
 Thanks again.
 
> On 8/24/2020 4:33 PM, Dennis Putnam wrote:
> Thanks to everyone that replied. I was not aware of pyownet. I will look 
> into that and rewrite my code to use it.
> 
>> On 8/24/2020 11:47 AM, Martin Patzak wrote:
>> For python I would highly recommend you use the library pyownet by 
>> Stefano Miccoli
>> https://github.com/miccoli/pyownet/
>> 
>> using Fuse can lead to weird problems... (not saying that it is the 
>> reason in your specific case)
>> 
>> or you can use the buil-in functions in owserver  owread/owwrite/owdir 
>> instead.
 
 
Virus-free. www.avast.com
>> 
>> 
>> 
>> 
>> ___
>> 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
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-27 Thread Mick Sulley
Yes I have struggled with that as well.  I have discovered how to do it, 
but I don't really understand why.


The answer seems to be that to write a 1 you need

    owproxy.write('device_id' + '/PIO.BYTE, b'1')

so you need to write the byte value of the string 1, not the byte value 
of the integer 1.  As I say, I don't understand why that is so, I dabble 
with Python, I'm far from expert :)


Hope that helps

Mick

On 27/08/2020 15:18, Dennis Putnam wrote:

Hi Martin,

See embedded comments.

On 8/27/2020 2:56 AM, Martin Patzak wrote:


what does *onOff.to_bytes(1,byteorder=sys.byteorder)) *evaluate to? 
Is that resulting in a byte-value? I am not familiar with this...
This seems to be the crux of the problem. After a lot of testing it 
appears to be a python 3 issue converting an integer to a byte string. 
I am convinced that passing a byte string to the write function is the 
problem. Thanks for everyone's help but this is not an owfs problem.


Things you could try:

  * In the path use the fully qualifying path and add */uncached *and
write a byte-value like this
*owproxy.write('/uncached/3A.0BE14D00/PIO.BYTE',b'0')*
  * writeto the individual outputs PIO.A or PIO.B directly
  * try reading the sensed values***print('sensed.BYTE = ',
owp.read('/uncached/3A.0BE14D00**/sensed.BYTE')*

**
On 26.08.20 21:05, Dennis Putnam wrote:
I have rewritten my code to use pyownet but am now nearly back where 
I started. I have the following code:


*owproxy.write('/3A.'+blower.id_+'/PIO.BYTE',onOff.to_bytes(1,byteorder=sys.byteorder))

*That statement gives me the following error:

*pyownet.protocol.OwnetError: [Errno 22] legacy - Invalid 
transaction: '/3A.0BE14D00/PIO.BYTE'


*The error is meaningless to me. The path is not wrong so is it 
complaining about writing a single byte?


Thanks again.

On 8/24/2020 4:33 PM, Dennis Putnam wrote:
Thanks to everyone that replied. I was not aware of pyownet. I will 
look into that and rewrite my code to use it.


On 8/24/2020 11:47 AM, Martin Patzak wrote:
For python I would highly recommend you use the library *pyownet 
*by Stefano Miccoli

/https://github.com/miccoli/pyownet/

/using Fuse can lead to weird problems... (not saying that it is 
the reason in your specific case)


or you can use the buil-in functions in owserver 
owread/owwrite/owdir instead.







 
	Virus-free. www.avast.com 
 



<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>






___
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


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-27 Thread Dennis Putnam
Hi Martin,

See embedded comments.

On 8/27/2020 2:56 AM, Martin Patzak wrote:
>
> what does *onOff.to_bytes(1,byteorder=sys.byteorder)) *evaluate to? Is
> that resulting in a byte-value? I am not familiar with this...
This seems to be the crux of the problem. After a lot of testing it
appears to be a python 3 issue converting an integer to a byte string. I
am convinced that passing a byte string to the write function is the
problem. Thanks for everyone's help but this is not an owfs problem.
>
> Things you could try:
>
>   * In the path use the fully qualifying path and add */uncached *and
> write a byte-value like this
> *owproxy.write('/uncached/3A.0BE14D00/PIO.BYTE',b'0')*
>   * writeto the individual outputs PIO.A or PIO.B directly
>   * try reading the sensed values***print('sensed.BYTE = ',
> owp.read('/uncached/3A.0BE14D00**/sensed.BYTE')*
>
> **
> On 26.08.20 21:05, Dennis Putnam wrote:
>> I have rewritten my code to use pyownet but am now nearly back where
>> I started. I have the following code:
>>
>> *owproxy.write('/3A.'+blower.id_+'/PIO.BYTE',onOff.to_bytes(1,byteorder=sys.byteorder))
>>
>> *That statement gives me the following error:
>>
>> *pyownet.protocol.OwnetError: [Errno 22] legacy - Invalid
>> transaction: '/3A.0BE14D00/PIO.BYTE'
>>
>> *The error is meaningless to me. The path is not wrong so is it
>> complaining about writing a single byte?
>>
>> Thanks again.
>>
>> On 8/24/2020 4:33 PM, Dennis Putnam wrote:
>>> Thanks to everyone that replied. I was not aware of pyownet. I will
>>> look into that and rewrite my code to use it.
>>>
>>> On 8/24/2020 11:47 AM, Martin Patzak wrote:
 For python I would highly recommend you use the library *pyownet
 *by Stefano Miccoli
 /https://github.com/miccoli/pyownet/

 /using Fuse can lead to weird problems... (not saying that it is
 the reason in your specific case)

 or you can use the buil-in functions in owserver 
 owread/owwrite/owdir instead.

>>>
>>
>>
>> 
>>  Virus-free. www.avast.com
>> 
>>
>>
>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>



-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-27 Thread Martin Patzak
... did you try Mick's sample program?

> import pyownet
>
> DevAddress = '*3A.0BE14D00*'
> owp = pyownet.protocol.proxy(persistent=True)
> owp.write('/DevAddress/PIO.BYTE',b'0')
> print('PIO.BYTE = ', owp.read('/uncached/DevAddress/PIO.BYTE'))
> print('sensed.BYTE = ', owp.read('/uncached/DevAddress/sensed.BYTE'))


On 26.08.20 21:05, Dennis Putnam wrote:
> I have rewritten my code to use pyownet but am now nearly back where I
> started. I have the following code:
>
> *owproxy.write('/3A.'+blower.id_+'/PIO.BYTE',onOff.to_bytes(1,byteorder=sys.byteorder))
>
> *That statement gives me the following error:
>
> *pyownet.protocol.OwnetError: [Errno 22] legacy - Invalid transaction:
> '/3A.0BE14D00/PIO.BYTE'
>
> *The error is meaningless to me. The path is not wrong so is it
> complaining about writing a single byte?
>
> Thanks again.
>
> On 8/24/2020 4:33 PM, Dennis Putnam wrote:
>> Thanks to everyone that replied. I was not aware of pyownet. I will
>> look into that and rewrite my code to use it.
>>
>> On 8/24/2020 11:47 AM, Martin Patzak wrote:
>>> For python I would highly recommend you use the library *pyownet *by
>>> Stefano Miccoli
>>> /https://github.com/miccoli/pyownet/
>>>
>>> /using Fuse can lead to weird problems... (not saying that it is the
>>> reason in your specific case)
>>>
>>> or you can use the buil-in functions in owserver 
>>> owread/owwrite/owdir instead.
>>>
>>
>
>
> 
>   Virus-free. www.avast.com
> 
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

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


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-26 Thread Dennis Putnam
I have rewritten my code to use pyownet but am now nearly back where I
started. I have the following code:

*owproxy.write('/3A.'+blower.id_+'/PIO.BYTE',onOff.to_bytes(1,byteorder=sys.byteorder))

*That statement gives me the following error:

*pyownet.protocol.OwnetError: [Errno 22] legacy - Invalid transaction:
'/3A.0BE14D00/PIO.BYTE'

*The error is meaningless to me. The path is not wrong so is it
complaining about writing a single byte?

Thanks again.

On 8/24/2020 4:33 PM, Dennis Putnam wrote:
> Thanks to everyone that replied. I was not aware of pyownet. I will
> look into that and rewrite my code to use it.
>
> On 8/24/2020 11:47 AM, Martin Patzak wrote:
>> For python I would highly recommend you use the library *pyownet *by
>> Stefano Miccoli
>> /https://github.com/miccoli/pyownet/
>>
>> /using Fuse can lead to weird problems... (not saying that it is the
>> reason in your specific case)
>>
>> or you can use the buil-in functions in owserver 
>> owread/owwrite/owdir instead.
>>
>



-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-24 Thread Martin Patzak
> It is a  little ironic that in the owfs suite of programs the module
> called owfs it the only one you really should not use.
yes, I second that. That was confusing to hear in the beginning. If felt
so intuitive...
Maybe it should not be part of the standard package at all?

> With Python3 the value ina write MUST be a byte value, hence b'0' in
> that line, Python2 didn't seem to care, that threw me for a while.
Good point! 


On 24.08.20 20:48, Mick Sulley wrote:
>
> Yes I would second that.  It is a  little ironic that in the owfs
> suite of programs the module called owfs it the only one you really
> should not use.  Basically hte best way is to run owserver which talks
> to all the devices, and then your python code talks to owserver.
>
> I have been using pyownet since I dropped fuse, it really is very
> good, documentation here https://pyownet.readthedocs.io/en/latest/
>
> With python3 you need something like this -
>
> import pyownet
>
> DevAddress = 'enter your device address here'
> owp = pyownet.protocol.proxy(persistent=True)
> owp.write('/DevAddress/PIO.BYTE',b'0')
> print('PIO.BYTE = ', owp.read('/uncached/DevAddress/PIO.BYTE')
> print('sensed.BYTE = ', owp.read('/uncached/DevAddress/sensed.BYTE')
>
> With Python3 the value ina write MUST be a byte value, hence b'0' in
> that line, Python2 didn't seem to care, that threw me for a while.
>
> Also from command line you can use the commands from ow-shell, so
> owdir lists all devices, owread 28.A59F9D0B/latesttemp reads the
> value from that device.
>
> Hope that helps.
>
> Mick
>
>
> On 24/08/2020 16:47, Martin Patzak wrote:
>> For python I would highly recommend you use the library *pyownet *by
>> Stefano Miccoli
>> /https://github.com/miccoli/pyownet/
>>
>> /using Fuse can lead to weird problems... (not saying that it is the
>> reason in your specific case)
>>
>> or you can use the buil-in functions in owserver 
>> owread/owwrite/owdir instead.
>>
>> On 24.08.20 15:57, Dennis Putnam wrote:
>>> I have the following python 3 code:
>>>
>>> *fn='/mnt/1wire/3A.'+blower.id_+'/PIO.BYTE'**
>>> **with open(fn,'wb') as fh:**
>>> **   fh.write(onOff.to_bytes(1,byteorder=sys.byteorder))
>>>
>>> *This produces the error:
>>>
>>> *OSError: [Errno 22] Invalid argument
>>>
>>> *The value of onOff will be either 1 or 0. In this particular case
>>> the value is 1. The value of blower.id_ is 0BE14D00. This is
>>> what that OWFS directory contains:
>>>
>>> *ls -l /mnt/1wire/3A.0BE14D00*
>>> total 0
>>> -r--r--r-- 1 root root  16 Aug 19 21:17 address
>>> -rw-rw-rw- 1 root root 256 Aug 19 21:17 alias
>>> -r--r--r-- 1 root root   2 Aug 19 21:17 crc8
>>> -r--r--r-- 1 root root   2 Aug 19 21:17 family
>>> -r--r--r-- 1 root root  12 Aug 19 21:17 id
>>> -r--r--r-- 1 root root  16 Aug 19 21:17 locator
>>> -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.A
>>> -rw-rw-rw- 1 root root   3 Aug 19 21:17 PIO.ALL
>>> -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.B
>>> -rw-rw-rw- 1 root root  12 Aug 19 21:17 PIO.BYTE
>>> -r--r--r-- 1 root root  16 Aug 19 21:17 r_address
>>> -r--r--r-- 1 root root  12 Aug 19 21:17 r_id
>>> -r--r--r-- 1 root root  16 Aug 19 21:17 r_locator
>>> -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.A
>>> -r--r--r-- 1 root root   3 Aug 19 21:17 sensed.ALL
>>> -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.B
>>> -r--r--r-- 1 root root  12 Aug 19 21:17 sensed.BYTE
>>> -r--r--r-- 1 root root  32 Aug 19 21:17 type
>>>
>>> I cannot see anything wrong with the code or permissions and the
>>> error is so generic I don't know to what it refers. Can someone spot
>>> what is invalid or help me debug this problem? TIA.
>>>
>>>
>>> ___
>>> 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
>
>
> ___
> 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


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-24 Thread Tomasz Torcz
On Mon, Aug 24, 2020 at 09:57:58AM -0400, Dennis Putnam wrote:
> I have the following python 3 code:
> 
> *fn='/mnt/1wire/3A.'+blower.id_+'/PIO.BYTE'**
> **with open(fn,'wb') as fh:**
> **   fh.write(onOff.to_bytes(1,byteorder=sys.byteorder))
> 
> *This produces the error:
> 
> *OSError: [Errno 22] Invalid argument
> 

  Could you use "strace -etrace=file ./youscript.py" to see what
_exactly_ is being written?  Or better yet, switch to ownet and do not
use FUSE.


-- 
Tomasz TorczTo co nierealne – tutaj jest normalne.
to...@pipebreaker.pl  Ziomale na życie mają tu patenty specjalne.



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


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-24 Thread Mick Sulley
Yes I would second that.  It is a  little ironic that in the owfs suite 
of programs the module called owfs it the only one you really should not 
use.  Basically hte best way is to run owserver which talks to all the 
devices, and then your python code talks to owserver.


I have been using pyownet since I dropped fuse, it really is very good, 
documentation here https://pyownet.readthedocs.io/en/latest/


With python3 you need something like this -

import pyownet

DevAddress = 'enter your device address here'
owp = pyownet.protocol.proxy(persistent=True)
owp.write('/DevAddress/PIO.BYTE',b'0')
print('PIO.BYTE = ', owp.read('/uncached/DevAddress/PIO.BYTE')
print('sensed.BYTE = ', owp.read('/uncached/DevAddress/sensed.BYTE')

With Python3 the value ina write MUST be a byte value, hence b'0' in 
that line, Python2 didn't seem to care, that threw me for a while.


Also from command line you can use the commands from ow-shell, so owdir 
lists all devices, owread 28.A59F9D0B/latesttemp reads the value 
from that device.


Hope that helps.

Mick


On 24/08/2020 16:47, Martin Patzak wrote:
For python I would highly recommend you use the library *pyownet *by 
Stefano Miccoli

/https://github.com/miccoli/pyownet/

/using Fuse can lead to weird problems... (not saying that it is the 
reason in your specific case)


or you can use the buil-in functions in owserver owread/owwrite/owdir 
instead.


On 24.08.20 15:57, Dennis Putnam wrote:

I have the following python 3 code:

*fn='/mnt/1wire/3A.'+blower.id_+'/PIO.BYTE'**
**with open(fn,'wb') as fh:**
**   fh.write(onOff.to_bytes(1,byteorder=sys.byteorder))

*This produces the error:

*OSError: [Errno 22] Invalid argument

*The value of onOff will be either 1 or 0. In this particular case 
the value is 1. The value of blower.id_ is 0BE14D00. This is what 
that OWFS directory contains:


*ls -l /mnt/1wire/3A.0BE14D00*
total 0
-r--r--r-- 1 root root  16 Aug 19 21:17 address
-rw-rw-rw- 1 root root 256 Aug 19 21:17 alias
-r--r--r-- 1 root root   2 Aug 19 21:17 crc8
-r--r--r-- 1 root root   2 Aug 19 21:17 family
-r--r--r-- 1 root root  12 Aug 19 21:17 id
-r--r--r-- 1 root root  16 Aug 19 21:17 locator
-rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.A
-rw-rw-rw- 1 root root   3 Aug 19 21:17 PIO.ALL
-rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.B
-rw-rw-rw- 1 root root  12 Aug 19 21:17 PIO.BYTE
-r--r--r-- 1 root root  16 Aug 19 21:17 r_address
-r--r--r-- 1 root root  12 Aug 19 21:17 r_id
-r--r--r-- 1 root root  16 Aug 19 21:17 r_locator
-r--r--r-- 1 root root   1 Aug 19 21:17 sensed.A
-r--r--r-- 1 root root   3 Aug 19 21:17 sensed.ALL
-r--r--r-- 1 root root   1 Aug 19 21:17 sensed.B
-r--r--r-- 1 root root  12 Aug 19 21:17 sensed.BYTE
-r--r--r-- 1 root root  32 Aug 19 21:17 type

I cannot see anything wrong with the code or permissions and the 
error is so generic I don't know to what it refers. Can someone spot 
what is invalid or help me debug this problem? TIA.



___
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
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-24 Thread Dennis Putnam
Hi Laurent,

I have not. I am a OWFS noob so I don't know what either of those
are/do. I only read an article that indicated I should use BYTE.

On 8/24/2020 12:34 PM, Laurent FAILLIE via Owfs-developers wrote:
> Hi,
>
> I'm controlling several things using DS2406 or DS2408 thru OWFS/Fuse
> (from C code but it's the same), and it's working pretty well for years.
> I.e:
> * Some explanations (in French) : Commande d'actionneurs par 1-wire
> 
>
>
>   
>
>
> Commande d'actionneurs par 1-wire
>
> Par DS2406
>
> 
>
>
> * my pool's pump, Commande d'une pompe de piscine par 1-Wire
>  (in french too)
>
>
>   
>
>
> Commande d'une pompe de piscine par 1-Wire
>
> DS2406 en sortie
>
> 
>
>
> Did you tried with DS2406 ?
> Or using PORT.A/B instead of BYTE ?
>
> - Laurent
>
>
>
> Le lundi 24 août 2020 à 17:47:53 UTC+2, Martin Patzak
>  a écrit :
>
>
> For python I would highly recommend you use the library *pyownet *by
> Stefano Miccoli
> /https://github.com/miccoli/pyownet/
>
> /using Fuse can lead to weird problems... (not saying that it is the
> reason in your specific case)
>
> or you can use the buil-in functions in owserver  owread/owwrite/owdir
> instead.
>
> On 24.08.20 15:57, Dennis Putnam wrote:
> I have the following python 3 code:
>
> *fn='/mnt/1wire/3A.'+blower.id_+'/PIO.BYTE'**
> **with open(fn,'wb') as fh:**
> **   fh.write(onOff.to_bytes(1,byteorder=sys.byteorder))
>
> *This produces the error:
>
> *OSError: [Errno 22] Invalid argument
>
> *The value of onOff will be either 1 or 0. In this particular case the
> value is 1. The value of blower.id_ is 0BE14D00. This is what that
> OWFS directory contains:
>
> *ls -l /mnt/1wire/3A.0BE14D00*
> total 0
> -r--r--r-- 1 root root  16 Aug 19 21:17 address
> -rw-rw-rw- 1 root root 256 Aug 19 21:17 alias
> -r--r--r-- 1 root root   2 Aug 19 21:17 crc8
> -r--r--r-- 1 root root   2 Aug 19 21:17 family
> -r--r--r-- 1 root root  12 Aug 19 21:17 id
> -r--r--r-- 1 root root  16 Aug 19 21:17 locator
> -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.A
> -rw-rw-rw- 1 root root   3 Aug 19 21:17 PIO.ALL
> -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.B
> -rw-rw-rw- 1 root root  12 Aug 19 21:17 PIO.BYTE
> -r--r--r-- 1 root root  16 Aug 19 21:17 r_address
> -r--r--r-- 1 root root  12 Aug 19 21:17 r_id
> -r--r--r-- 1 root root  16 Aug 19 21:17 r_locator
> -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.A
> -r--r--r-- 1 root root   3 Aug 19 21:17 sensed.ALL
> -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.B
> -r--r--r-- 1 root root  12 Aug 19 21:17 sensed.BYTE
> -r--r--r-- 1 root root  32 Aug 19 21:17 type
>
> I cannot see anything wrong with the code or permissions and the error
> is so generic I don't know to what it refers. Can someone spot what is
> invalid or help me debug this problem? TIA.
>
>
> ___
> 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
>
>
> ___
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers



signature.asc
Description: OpenPGP digital signature
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-24 Thread Laurent FAILLIE via Owfs-developers
Hi,
I'm controlling several things using DS2406 or DS2408 thru OWFS/Fuse (from C 
code but it's the same), and it's working pretty well for years.I.e: 
* Some explanations (in French) : Commande d'actionneurs par 1-wire

| 
| 
|  | 
Commande d'actionneurs par 1-wire

Par DS2406
 |

 |

 |



* my pool's pump, Commande d'une pompe de piscine par 1-Wire (in french too)


| 
| 
|  | 
Commande d'une pompe de piscine par 1-Wire

DS2406 en sortie
 |

 |

 |



Did you tried with DS2406 ?Or using PORT.A/B instead of BYTE ?
- Laurent



Le lundi 24 août 2020 à 17:47:53 UTC+2, Martin Patzak 
 a écrit :  
 
  For python I would highly recommend you use the library pyownet by Stefano 
Miccoli
 https://github.com/miccoli/pyownet/
 
 using Fuse can lead to weird problems... (not saying that it is the reason in 
your specific case)
 
 or you can use the buil-in functions in owserver  owread/owwrite/owdir instead.
 
 On 24.08.20 15:57, Dennis Putnam wrote:
  
 
 I have the following python 3 code:
 
 fn='/mnt/1wire/3A.'+blower.id_+'/PIO.BYTE'
 with open(fn,'wb') as fh:
    fh.write(onOff.to_bytes(1,byteorder=sys.byteorder))
 
 This produces the error:
 
 OSError: [Errno 22] Invalid argument
 
 The value of onOff will be either 1 or 0. In this particular case the value is 
1. The value of blower.id_ is 0BE14D00. This is what that OWFS directory 
contains:
 
 ls -l /mnt/1wire/3A.0BE14D00
 total 0
 -r--r--r-- 1 root root  16 Aug 19 21:17 address
 -rw-rw-rw- 1 root root 256 Aug 19 21:17 alias
 -r--r--r-- 1 root root   2 Aug 19 21:17 crc8
 -r--r--r-- 1 root root   2 Aug 19 21:17 family
 -r--r--r-- 1 root root  12 Aug 19 21:17 id
 -r--r--r-- 1 root root  16 Aug 19 21:17 locator
 -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.A
 -rw-rw-rw- 1 root root   3 Aug 19 21:17 PIO.ALL
 -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.B
 -rw-rw-rw- 1 root root  12 Aug 19 21:17 PIO.BYTE
 -r--r--r-- 1 root root  16 Aug 19 21:17 r_address
 -r--r--r-- 1 root root  12 Aug 19 21:17 r_id
 -r--r--r-- 1 root root  16 Aug 19 21:17 r_locator
 -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.A
 -r--r--r-- 1 root root   3 Aug 19 21:17 sensed.ALL
 -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.B
 -r--r--r-- 1 root root  12 Aug 19 21:17 sensed.BYTE
 -r--r--r-- 1 root root  32 Aug 19 21:17 type
 
 I cannot see anything wrong with the code or permissions and the error is so 
generic I don't know to what it refers. Can someone spot what is invalid or 
help me debug this problem? TIA.
 
  
  ___
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
  ___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers


Re: [Owfs-developers] Writing to DS2413 Device with Python 3

2020-08-24 Thread Martin Patzak
For python I would highly recommend you use the library *pyownet *by
Stefano Miccoli
/https://github.com/miccoli/pyownet/

/using Fuse can lead to weird problems... (not saying that it is the
reason in your specific case)

or you can use the buil-in functions in owserver  owread/owwrite/owdir
instead.

On 24.08.20 15:57, Dennis Putnam wrote:
> I have the following python 3 code:
>
> *fn='/mnt/1wire/3A.'+blower.id_+'/PIO.BYTE'**
> **with open(fn,'wb') as fh:**
> **   fh.write(onOff.to_bytes(1,byteorder=sys.byteorder))
>
> *This produces the error:
>
> *OSError: [Errno 22] Invalid argument
>
> *The value of onOff will be either 1 or 0. In this particular case the
> value is 1. The value of blower.id_ is 0BE14D00. This is what that
> OWFS directory contains:
>
> *ls -l /mnt/1wire/3A.0BE14D00*
> total 0
> -r--r--r-- 1 root root  16 Aug 19 21:17 address
> -rw-rw-rw- 1 root root 256 Aug 19 21:17 alias
> -r--r--r-- 1 root root   2 Aug 19 21:17 crc8
> -r--r--r-- 1 root root   2 Aug 19 21:17 family
> -r--r--r-- 1 root root  12 Aug 19 21:17 id
> -r--r--r-- 1 root root  16 Aug 19 21:17 locator
> -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.A
> -rw-rw-rw- 1 root root   3 Aug 19 21:17 PIO.ALL
> -rw-rw-rw- 1 root root   1 Aug 19 21:17 PIO.B
> -rw-rw-rw- 1 root root  12 Aug 19 21:17 PIO.BYTE
> -r--r--r-- 1 root root  16 Aug 19 21:17 r_address
> -r--r--r-- 1 root root  12 Aug 19 21:17 r_id
> -r--r--r-- 1 root root  16 Aug 19 21:17 r_locator
> -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.A
> -r--r--r-- 1 root root   3 Aug 19 21:17 sensed.ALL
> -r--r--r-- 1 root root   1 Aug 19 21:17 sensed.B
> -r--r--r-- 1 root root  12 Aug 19 21:17 sensed.BYTE
> -r--r--r-- 1 root root  32 Aug 19 21:17 type
>
> I cannot see anything wrong with the code or permissions and the error
> is so generic I don't know to what it refers. Can someone spot what is
> invalid or help me debug this problem? TIA.
>
>
> ___
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers



signature.asc
Description: OpenPGP digital signature
___
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers