nogo: driver "ws23xx" and Python V3

149 views
Skip to first unread message

P Simmons

unread,
Feb 3, 2020, 5:49:03 PM2/3/20
to weewx-user
I've attempted to move from Python2 to Python3, and have encountered a problem with ws23xx.py

Thank you,
Paul
weewx.log

Thomas Keffer

unread,
Feb 4, 2020, 9:09:36 PM2/4/20
to weewx-user
Thanks for your report, Paul!

I think I fixed this in commit 223fafc.

Can you give it a try?

-tk

--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/2cfe7671-0233-4197-aecc-c0f5d6b0b7d0%40googlegroups.com.

P Simmons

unread,
Feb 5, 2020, 12:45:11 AM2/5/20
to weewx-user
Well, weewx doesn't terminate with the new driver under Python3, but there seems to be another issue.  The reports don't update under Python3.

It's been a long time since I modified the weewx.conf (and I'm sure I have done so); don't discount the possibility that I've munged something!

Here are the outputs from the gitlog of the version that I used, weewx_debug, and the weewx.log from the time I stopped the daemon, switched Python to "3", restarted, then stopped and switched back to Python "2" (and restarted).

Sorry if I'm being a "pain".  I love this software!  I'm very grateful for all the effort you folks put into it.

This issue isn't "mission critical", so feel free to move on to more serious problems.

p.
weewx.gitlog.txt
weewx.debug.txt
weewx.log

Thomas Keffer

unread,
Feb 5, 2020, 10:03:44 AM2/5/20
to weewx-user
Could you please go into the file ws23xx.py and change the global variable DEBUG_SERIAL to True (line 803)? Then try running the driver directly. For example:

PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings

While you're at it, try both python2 and python3.

-tk

--
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 weewx-user+...@googlegroups.com.

P Simmons

unread,
Feb 5, 2020, 6:29:21 PM2/5/20
to weewx-user


On Wednesday, February 5, 2020 at 9:03:44 AM UTC-6, Thomas Keffer wrote:
Could you please go into the file ws23xx.py and change the global variable DEBUG_SERIAL to True (line 803)? Then try running the driver directly. For example:

PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings

While you're at it, try both python2 and python3.

-tk


Here are the results for both versions.  Note: I overrode the port setting, as it defaulted to USB, but mine is serial (/dev/ttyS0).

Thanks!
Paul
ws23xx.py.txt

Thomas Keffer

unread,
Feb 5, 2020, 6:53:34 PM2/5/20
to weewx-user
Guess I forgot to mention one important detail: send the log!

-tk

--
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 weewx-user+...@googlegroups.com.

P Simmons

unread,
Feb 5, 2020, 7:46:21 PM2/5/20
to weewx-user


On Wednesday, February 5, 2020 at 5:53:34 PM UTC-6, Thomas Keffer wrote:
Guess I forgot to mention one important detail: send the log!

-tk


Repeated test... no log entries in /var/log/weewx.log during driver runs... only console results.  Next?

Thomas Keffer

unread,
Feb 5, 2020, 7:54:41 PM2/5/20
to weewx-user
/var/log/weewx.log? What's that? Did you try /var/log/syslog?

--
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 weewx-user+...@googlegroups.com.

P Simmons

unread,
Feb 5, 2020, 8:02:26 PM2/5/20
to weewx-user


On Wednesday, February 5, 2020 at 6:54:41 PM UTC-6, Thomas Keffer wrote:
/var/log/weewx.log? What's that? Did you try /var/log/syslog?

On Wed, Feb 5, 2020 at 4:46 PM P Simmons <mbat...@gmail.com> wrote:


On Wednesday, February 5, 2020 at 5:53:34 PM UTC-6, Thomas Keffer wrote:
Guess I forgot to mention one important detail: send the log!

-tk


Repeated test... no log entries in /var/log/weewx.log during driver runs... only console results.  Next?

-

Whoops... loose nut on keyboard... wilco.

p.

P Simmons

unread,
Feb 5, 2020, 8:26:48 PM2/5/20
to weewx-user
Appended a "testing bookmark" in /var/log/syslog with "echo". Repeated testing command series. No additional entries in /var/log/syslog either.

Thomas Keffer

unread,
Feb 6, 2020, 11:20:53 AM2/6/20
to weewx-user
This remote debugging is hard!

Give this version a try.

-tk

On Wed, Feb 5, 2020 at 5:26 PM P Simmons <mbat...@gmail.com> wrote:
Appended a "testing bookmark" in /var/log/syslog with "echo". Repeated testing command series. No additional entries in /var/log/syslog either.

--
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 weewx-user+...@googlegroups.com.
ws23xx.py

P Simmons

unread,
Feb 6, 2020, 11:52:14 AM2/6/20
to weewx-user


On Thursday, February 6, 2020 at 10:20:53 AM UTC-6, Thomas Keffer wrote:
This remote debugging is hard!

Give this version a try.

-tk



I can appreciate the difficulty, having done remote development (in assembly language, on an obscure Sharp platform, in the distant past).  Thank you for your diligence.

Here's the output from the latest driver.


ws23xx.console.log

Thomas Keffer

unread,
Feb 6, 2020, 12:13:28 PM2/6/20
to weewx-user
I guess that's progress. Try this one.

I'm just blinding replacing python 2 idioms with six idioms. No idea about the underlying logic.

-tk

--
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 weewx-user+...@googlegroups.com.
ws23xx.py

P Simmons

unread,
Feb 6, 2020, 12:25:32 PM2/6/20
to weewx-user


On Thursday, February 6, 2020 at 11:13:28 AM UTC-6, Thomas Keffer wrote:
I guess that's progress. Try this one.

I'm just blinding replacing python 2 idioms with six idioms. No idea about the underlying logic.

-tk


Result:

# PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings --port=/dev/ttyS0
Traceback (most recent call last):
  File "bin/weewx/drivers/ws23xx.py", line 2117, in <module>
    data = s.get_raw_data(SENSOR_IDS)
  File "bin/weewx/drivers/ws23xx.py", line 790, in get_raw_data
    raw_data = read_measurements(self.ws, measures)
  File "bin/weewx/drivers/ws23xx.py", line 2030, in read_measurements
    nybbles = ws2300.read_batch(batches)
  File "bin/weewx/drivers/ws23xx.py", line 1202, in read_batch
    response = self.read_data(address + start_pos, bytes_)
  File "bin/weewx/drivers/ws23xx.py", line 1175, in read_data
    checksum = sum([ord(b) for b in response]) % 256
  File "bin/weewx/drivers/ws23xx.py", line 1175, in <listcomp>
    checksum = sum([ord(b) for b in response]) % 256
TypeError: ord() expected string of length 1, but int found

Thomas Keffer

unread,
Feb 6, 2020, 12:36:40 PM2/6/20
to weewx-user
Steady progress.



--
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 weewx-user+...@googlegroups.com.
ws23xx.py

P Simmons

unread,
Feb 6, 2020, 12:48:11 PM2/6/20
to weewx-user


On Thursday, February 6, 2020 at 11:36:40 AM UTC-6, Thomas Keffer wrote:
Steady progress.



 # PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings --port=/dev/ttyS0
Traceback (most recent call last):
  File "bin/weewx/drivers/ws23xx.py", line 2117, in <module>
    data = s.get_raw_data(SENSOR_IDS)
  File "bin/weewx/drivers/ws23xx.py", line 790, in get_raw_data
    raw_data = read_measurements(self.ws, measures)
  File "bin/weewx/drivers/ws23xx.py", line 2030, in read_measurements
    nybbles = ws2300.read_batch(batches)
  File "bin/weewx/drivers/ws23xx.py", line 1202, in read_batch
    response = self.read_data(address + start_pos, bytes_)
  File "bin/weewx/drivers/ws23xx.py", line 1175, in read_data
    checksum = sum([six.byte2int(b) for b in response]) % 256

  File "bin/weewx/drivers/ws23xx.py", line 1175, in <listcomp>
    checksum = sum([six.byte2int(b) for b in response]) % 256
TypeError: 'int' object is not subscriptable

Thomas Keffer

unread,
Feb 6, 2020, 2:01:32 PM2/6/20
to weewx-user
--
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 weewx-user+...@googlegroups.com.
ws23xx.py

P Simmons

unread,
Feb 6, 2020, 2:17:20 PM2/6/20
to weewx-user
# PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings --port=/dev/ttyS0
Traceback (most recent call last):
  File "bin/weewx/drivers/ws23xx.py", line 2120, in <module>

    data = s.get_raw_data(SENSOR_IDS)
  File "bin/weewx/drivers/ws23xx.py", line 790, in get_raw_data
    raw_data = read_measurements(self.ws, measures)
  File "bin/weewx/drivers/ws23xx.py", line 2033, in read_measurements
    nybbles = ws2300.read_batch(batches)
  File "bin/weewx/drivers/ws23xx.py", line 1205, in read_batch

    response = self.read_data(address + start_pos, bytes_)
  File "bin/weewx/drivers/ws23xx.py", line 1177, in read_data
    checksum += six.byte2int(b)

Thomas Keffer

unread,
Feb 6, 2020, 2:59:11 PM2/6/20
to weewx-user
--
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 weewx-user+...@googlegroups.com.
ws23xx.py

P Simmons

unread,
Feb 6, 2020, 6:01:42 PM2/6/20
to weewx-user
Sorry for delay, needed a nap.  |-)

# PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings --port=/dev/ttyS0
Traceback (most recent call last):
  File "bin/weewx/drivers/ws23xx.py", line 2117, in <module>

    data = s.get_raw_data(SENSOR_IDS)
  File "bin/weewx/drivers/ws23xx.py", line 790, in get_raw_data
    raw_data = read_measurements(self.ws, measures)
  File "bin/weewx/drivers/ws23xx.py", line 2030, in read_measurements
    nybbles = ws2300.read_batch(batches)
  File "bin/weewx/drivers/ws23xx.py", line 1202, in read_batch

    response = self.read_data(address + start_pos, bytes_)
  File "bin/weewx/drivers/ws23xx.py", line 1180, in read_data
    return reduce(flatten, response, ())[:nybble_count]
  File "bin/weewx/drivers/ws23xx.py", line 1179, in <lambda>
    flatten = lambda a,b: a + (ord(b) % 16, ord(b) / 16)

gjr80

unread,
Feb 6, 2020, 9:20:39 PM2/6/20
to weewx-user
Makes me feel less guilty :)

Gsry

Thomas Keffer

unread,
Feb 7, 2020, 7:46:40 AM2/7/20
to weewx-user
I'm going to need an aspirin.


--
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 weewx-user+...@googlegroups.com.
ws23xx.py
Message has been deleted

P Simmons

unread,
Feb 7, 2020, 2:29:26 PM2/7/20
to weewx-user


On Friday, February 7, 2020 at 6:46:40 AM UTC-6, Thomas Keffer wrote:
I'm going to need an aspirin.


On Thu, Feb 6, 2020 at 3:01 PM P Simmons <mbat...@gmail.com> wrote:
Sorry for delay, needed a nap.  |-)

# PYTHONPATH=bin python3 bin/weewx/drivers/ws23xx.py --readings --port=/dev/ttyS0
Traceback (most recent call last):
  File "bin/weewx/drivers/ws23xx.py", line 2117, in <module>
    data = s.get_raw_data(SENSOR_IDS)
  File "bin/weewx/drivers/ws23xx.py", line 790, in get_raw_data
    raw_data = read_measurements(self.ws, measures)
  File "bin/weewx/drivers/ws23xx.py", line 2030, in read_measurements
    nybbles = ws2300.read_batch(batches)
  File "bin/weewx/drivers/ws23xx.py", line 1202, in read_batch
    response = self.read_data(address + start_pos, bytes_)
  File "bin/weewx/drivers/ws23xx.py", line 1180, in read_data
    return reduce(flatten, response, ())[:nybble_count]
  File "bin/weewx/drivers/ws23xx.py", line 1179, in <lambda>
    flatten = lambda a,b: a + (ord(b) % 16, ord(b) / 16)
TypeError: ord() expected string of length 1, but int found

--
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 weewx...@googlegroups.com.


I may have inadvertently munged an earlier reply...

The latest ws23xx.py is happily running, outputting acceptable records, and weewx is showing the results.

Kudos!

I appreciate your patience and assistance.

Paul 

mwall

unread,
Feb 7, 2020, 3:28:34 PM2/7/20
to weewx-user
confirmed that the ws23xx driver is now working with both python3 and python2.  tested with:

station: lacrosse 2310
os: debian7
python: 3.7.4 and 2.7.3
weewx: 4.0.0b11
ws23xx driver: 0.41

i just bumped the driver version number to 0.41

sorry so late to the party...

P Simmons

unread,
Feb 7, 2020, 3:32:46 PM2/7/20
to weewx-user
No worries (on my end).  We probably owe TK some primo beers  - I know I do!

All the contributors are the best I've ever witnessed.  What a great project!

Paul

Thomas Keffer

unread,
Feb 7, 2020, 4:22:02 PM2/7/20
to weewx-user
I'll be damned. I really didn't know what I was doing --- just charging ahead, finding ways to silence the Python interpreter. 

I don't know how much ownership you claim, Matthew, but that's some of the most convoluted Python code I've had to debug. 21 different classes just to deal with conversions?

-tk

--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/e3c78854-a4ec-4d00-a627-e4c8bc1be9f6%40googlegroups.com.

mwall

unread,
Feb 7, 2020, 4:45:35 PM2/7/20
to weewx-user


On Friday, February 7, 2020 at 4:22:02 PM UTC-5, Thomas Keffer wrote:

I don't know how much ownership you claim, Matthew, but that's some of the most convoluted Python code I've had to debug. 21 different classes just to deal with conversions?

it kinda smells like it was adapted from a c implementation.  the ws23xx code was written by others - i adapted/wrapped it to work in weewx

at one point i tried to write a new implementation so that it would work on windows and macos - the current implementation is pretty linux-specific.  but there were lots of timing issues, and my skillz were not up to the task.

m

Thomas Keffer

unread,
Feb 7, 2020, 5:13:03 PM2/7/20
to weewx-user
Thank goodness it's not that common a station!

--
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 weewx-user+...@googlegroups.com.

P Simmons

unread,
Feb 7, 2020, 6:03:46 PM2/7/20
to weewx-user


On Friday, February 7, 2020 at 4:13:03 PM UTC-6, Thomas Keffer wrote:
Thank goodness it's not that common a station!



Yeah, mine was a gift from a neighbor, received a few years ago.  He doesn't live out here full time.  I watch over his property, and he wants me to keep him apprised of local conditions.  The closest NWS location is 50+ miles away, has different topology, and rarely has the same readings as we do.

When I get one of the grandkids out here, I hope to install the wind sensors (I'm not supposed to get on a ladder or the roof these days).

If I had the funds, I'd get a more serious station (but it'd have to be supported under weewx, of course).  I'd also get a reliable 'net connection (HughesNot is... well... NOT).

Thank you again for this project, and thanks to ALL who contribute!

Paul
Reply all
Reply to author
Forward
0 new messages