My bad, incearca cu f.write(chr(0)) si 1

On Wed, Mar 16, 2016 at 2:15 PM, Paul Lacatus (Personal) <
[email protected]> wrote:

>
>
> On 3/16/2016 12:17 PM, Mihai Tianu wrote:
>
> On Wed, Mar 16, 2016 at 11:35 AM, Paul Lacatus (Personal) <
> <[email protected]>[email protected]> wrote:
>
>>
>>
>> On 3/16/2016 11:31 AM, Claudiu Nicolaie CISMARU wrote:
>> >>    nope :
>> >>   >>> f= open ('/sys/bus/w1/devices/3a-0000002404ba/output','a')
>> >>   >>> f.write ("1\n")
>> >>   >>> f.flush()
>> > De ce deschizi fisierul in append mode? Deschide-l in write mode.
>> pentru ca si in bash fac echo 1 >> si fisierul e generat de kernel si
>> exista
>
>
> O-o
>
> Family 3A -> banuiesc ca este vorba despre DS2413 - 2-channel addressable
> switch, caz in care trebuie trebuie sa scrii in hex  (sau binar) adresa
> pinului pentru care vrei sa faci ceva
> echo -e '\x00' |dd of=/sys/bus/w1/devices/3a-0000002404ba/output bs=1
> count=1
> sleep 2
> echo -e '\x01' |dd of=/sys/bus/w1/devices/3a-0000002404ba/output bs=1
> count=1
> sleep 2
> echo -e '\x00' |dd of=/sys/bus/w1/devices/3a-0000002404ba/output bs=1
> count=1
>
> Sau in py
>
> import time
>
> with open("/sys/bus/w1/devices/3a-0000002404ba/output", "wb", 0) as f:
>         f.write(hex(0))
>         time.sleep(1)
>         f.write(hex(1))
>         time.sleep(1)
>         f.write(hex(0))
>
> Scriptul in bash merge ca uns . Cel in python  se agata cu
>
> Traceback (most recent call last):
>   File "mqtt_pulse.py", line 9, in <module>
>     f.write(hex(0))
>



-- 

~Mihai
_______________________________________________
RLUG mailing list
[email protected]
http://lists.lug.ro/mailman/listinfo/rlug

Raspunde prin e-mail lui