OK, that fixed it, thanks!  For anyone else running into this problem, just 
replace /usr/share/weewx/weewx/crc16.py with @Tom Keffer's earlier version.

On Monday, 20 October 2025 at 16:42:50 UTC+13 Joe Garcia wrote:

> Thanks, I'll give it a go and report back.
>
> If by "the author" you mean the developer of the Meteostick driver, I'm 
> not sure how useful that'll be, a lot of his (very useful) WeeWX-related 
> tools date from around the 2020 time frame and haven't been updated since 
> then.  For example there's multi-year-old PRs for the driver still active.  
> Not meant as a criticism, everyone has a day job they need to deal with, 
> just pointing out that a fix at the meteostick.py end may be awhile 
> forthcoming.
>
> On Monday, 20 October 2025 at 02:38:09 UTC+13 Tom Keffer wrote:
>
>> It appears that this part of the meteostick driver was never updated to 
>> Python 3. 
>>
>> The crc16() function could work with either Python 2 or 3 until V5.2, at 
>> which point the Python 2 code was removed.
>>
>> For the moment, replace the file /usr/share/weewx/weewx/crc16.py with the 
>> older version, attached below.
>>
>> I'll file an issue with the author.
>>
>> -tk
>>
>> On Sun, Oct 19, 2025 at 6:16 AM Joe Garcia <[email protected]> wrote:
>>
>>> Yeah, sorry, the post took awhile to appear so I couldn't update it with 
>>> the full log, whole thing is attached below.  Looking at the repo, there 
>>> was a change to crc16.py 11 months ago that may have caused this:
>>>
>>> - def crc16(bytes, crc_start=0):
>>> + def crc16(byte_buf, crc_start=0): 
>>>
>>> - return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ 
>>> (crc_sum << 8)) & 0xffff, byte_buf, crc_start)
>>> + crc_sum = reduce(lambda crc, ch : (_table[(crc >> 8) ^ ch] ^ (crc << 
>>> 8)) & 0xffff, byte_iter, crc_start)
>>>
>>> but see my earlier comment about no hablo Python :).
>>>
>>> CRITICAL __main__: Caught unrecoverable exception:
>>> CRITICAL __main__:     ****  unsupported operand type(s) for ^: 'int' 
>>> and 'str'
>>> CRITICAL __main__:     ****  Traceback (most recent call last):
>>> CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd.py", line 
>>> 127, in main
>>> CRITICAL __main__:     ****      engine.run()
>>> CRITICAL __main__:     ****      ~~~~~~~~~~^^
>>> CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", 
>>> line 204, in run
>>> CRITICAL __main__:     ****      for packet in 
>>> self.console.genLoopPackets():
>>> CRITICAL __main__:     ****                   
>>>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
>>> CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", 
>>> line 311, in genLoopPackets
>>> CRITICAL __main__:     ****      data = 
>>> self.station.parse_readings(readings, self.rain_per_tip)
>>> CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", 
>>> line 638, in parse_readings
>>> CRITICAL __main__:     ****      data = self.parse_raw(raw,
>>> CRITICAL __main__:     ****                           
>>>  self.channels['iss'],
>>> CRITICAL __main__:     ****      ...<3 lines>...
>>> CRITICAL __main__:     ****                           
>>>  self.channels['temp_hum_2'],
>>> CRITICAL __main__:     ****                            rain_per_tip)
>>> CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", 
>>> line 687, in parse_raw
>>> CRITICAL __main__:     ****      Meteostick._check_crc(raw_msg_crc, 
>>> chksum)
>>> CRITICAL __main__:     ****     
>>>  ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
>>> CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", 
>>> line 505, in _check_crc
>>> CRITICAL __main__:     ****      crc_result = crc16(msg)
>>> CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", 
>>> line 49, in crc16
>>> CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: 
>>> (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff,
>>> CRITICAL __main__:     ****                    byte_buf, crc_start)
>>> CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", 
>>> line 49, in <lambda>
>>> CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: 
>>> (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff,
>>> CRITICAL __main__:     ****                           
>>>  ~~~~~~~~~~~~~~~^~~~
>>> CRITICAL __main__:     ****  TypeError: unsupported operand type(s) for 
>>> ^: 'int' and 'str'
>>> CRITICAL __main__:     ****  Exiting.
>>> Traceback (most recent call last):
>>>   File "/usr/share/weewx/weewxd.py", line 226, in <module>
>>>     main()
>>>     ~~~~^^
>>>   File "/usr/share/weewx/weewxd.py", line 127, in main
>>>     engine.run()
>>>     ~~~~~~~~~~^^
>>>   File "/usr/share/weewx/weewx/engine.py", line 204, in run
>>>     for packet in self.console.genLoopPackets():
>>>                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
>>>   File "/etc/weewx/bin/user/meteostick.py", line 311, in genLoopPackets
>>>     data = self.station.parse_readings(readings, self.rain_per_tip)
>>>   File "/etc/weewx/bin/user/meteostick.py", line 638, in parse_readings
>>>     data = self.parse_raw(raw,
>>>                           self.channels['iss'],
>>>     ...<3 lines>...
>>>                           self.channels['temp_hum_2'],
>>>                           rain_per_tip)
>>>   File "/etc/weewx/bin/user/meteostick.py", line 687, in parse_raw
>>>     Meteostick._check_crc(raw_msg_crc, chksum)
>>>     ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
>>>   File "/etc/weewx/bin/user/meteostick.py", line 505, in _check_crc
>>>     crc_result = crc16(msg)
>>>   File "/usr/share/weewx/weewx/crc16.py", line 49, in crc16
>>>     return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ 
>>> (crc_sum << 8)) & 0xffff,
>>>                   byte_buf, crc_start)
>>>   File "/usr/share/weewx/weewx/crc16.py", line 49, in <lambda>
>>>     return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ 
>>> (crc_sum << 8)) & 0xffff,
>>>                                               ~~~~~~~~~~~~~~~^~~~
>>> TypeError: unsupported operand type(s) for ^: 'int' and 'str'
>>>
>>> On Sunday, 19 October 2025 at 03:12:18 UTC+13 Tom Keffer wrote:
>>>
>>>> I'm sorry but the lines in your snippet are so truncated it's hard to 
>>>> tell what's going on. Can we see the full lines?
>>>>
>>>> On Sat, Oct 18, 2025 at 7:02 AM Joe Garcia <[email protected]> wrote:
>>>>
>>>>> Another instance of 5.2 breakage, Meteostick support no longer works:
>>>>>
>>>>> CRITICAL __main__:     ****    File 
>>>>> "/etc/weewx/bin/user/meteostick.py", l>
>>>>> CRITICAL __main__:     ****      crc_result = crc16(msg)
>>>>> CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", 
>>>>> lin>
>>>>> CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: 
>>>>> (_table>
>>>>> CRITICAL __main__:     ****                    byte_buf, crc_start)
>>>>> CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", 
>>>>> lin>
>>>>> CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: 
>>>>> (_table>
>>>>> CRITICAL __main__:     ****                                           
>>>>>     >
>>>>> CRITICAL __main__:     ****  TypeError: unsupported operand type(s) 
>>>>> for ^:>
>>>>> CRITICAL __main__:     ****  Exiting.
>>>>>
>>>>> This may also have come about from an update to Python that occurred 
>>>>> at the same time, not 5.2-specific.  Unfortunately I don't speak Python 
>>>>> so 
>>>>> I'm not sure what's required to fix meteostick.py, and the original on 
>>>>> Github hasn't been updated since 2019.
>>>>>
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "weewx-user" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>> To view this discussion visit 
>>>>> https://groups.google.com/d/msgid/weewx-user/56358b16-66c3-41f6-b500-5cd3e6f9aad6n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/weewx-user/56358b16-66c3-41f6-b500-5cd3e6f9aad6n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "weewx-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>>
>> To view this discussion visit 
>>> https://groups.google.com/d/msgid/weewx-user/eebc86d4-933e-480b-a5d4-6cdb1b49403fn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/weewx-user/eebc86d4-933e-480b-a5d4-6cdb1b49403fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/weewx-user/ff4f389e-395c-496c-a543-10d2f6e191c8n%40googlegroups.com.

Reply via email to