python3 and fousb.py

68 views
Skip to first unread message

Hartmut Schweidler

unread,
May 29, 2019, 8:14:13 AM5/29/19
to weewx-development
Hallo

I  have 2to3 by foub.py  and changed the code in

fousb.py in line 1174  for Python 3.7.3

    def _read_usb_block(self, address):
       
addr1 = (address // 256) & 0xff
        addr2
= address & 0xff
       
self.devh.controlMsg(usb.TYPE_CLASS + usb.RECIP_INTERFACE,
                             
0x0000009,
                             
[0xA1,addr1,addr2,0x20,0xA1,addr1,addr2,0x20],
                             
0x0000200,
                             
0x0000000,
                             
1000)
        data
= self.devh.interruptRead(self.usb_endpoint,
                                       
self.usb_read_size, # bytes to read
                                       
int(self.timeout*1000))
       
return list(data)

and in line 1198

    def _write_usb(self, address, data):
       
addr1 = (address // 256) & 0xff
        addr2
= address & 0xff
        buf
= [0xA2,addr1,addr2,0x20,0xA2,data,0,0x20]
        result
= self.devh.controlMsg(
            usb
.ENDPOINT_OUT + usb.TYPE_CLASS + usb.RECIP_INTERFACE,
            usb
.REQ_SET_CONFIGURATION,  # 0x09
            buf
,
            value
= 0x200,
            index
= 0,
            timeout
= int(self.timeout*1000))
       
if result != len(buf):
           
return False
        buf
= self._read_usb_bytes(8)
       
if buf is None:
           
return False
       
for byte in buf:
           
if byte != 0xA5:
               
return False
       
return True

otherwise the operator "/" will be interpreted incorrectly, it must be right  "//"

and it works

Hartmut

Susan Mackay

unread,
May 29, 2019, 10:58:27 PM5/29/19
to weewx-development
Out of interest, what problem does this solve?
What are the symptoms you experienced that made you look for this?
Susan

Hartmut Schweidler

unread,
May 30, 2019, 3:43:44 AM5/30/19
to weewx-development
Hi Susan,


Hartmut

Susan Mackay

unread,
May 30, 2019, 11:58:49 PM5/30/19
to weewx-development
I take it from that, that the software was crashing and stopping weewx when run with that version of Python, where it would run correctly and produce the correct results under all previous versions.\

Thanks for finding this out.

Susan
Reply all
Reply to author
Forward
0 new messages