btmon for python 3?
-
- Posts: 68
- Joined: Sat Oct 08, 2011 2:48 am
- Location: Sweden
btmon for python 3?
Has anyone done or seen a updated btmon that works with python 3? I am updating my server, and of course 2.7 is no longer with us..
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: btmon for python 3?
Try the attached conversion to see if it works. Report back any errors.
EDIT: Attached a new copy.
- Attachments
-
- btmon3.zip
- (41.43 KiB) Downloaded 546 times
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 68
- Joined: Sat Oct 08, 2011 2:48 am
- Location: Sweden
Re: btmon for python 3?
So, finally, I had some time to test btmon3.
It has some issues, that I fixed (configparser issue and I also removed "options.ip_poll_interval > 0" check).
After this, I get no errors, it starts up and prints the same stuff that I get on the 2.7 version on my old server, but it does not work. Not sure why. Only thing I know, is that it never sends anything to the broker.
Is there any prefered way to debug this?
It has some issues, that I fixed (configparser issue and I also removed "options.ip_poll_interval > 0" check).
After this, I get no errors, it starts up and prints the same stuff that I get on the 2.7 version on my old server, but it does not work. Not sure why. Only thing I know, is that it never sends anything to the broker.
Is there any prefered way to debug this?
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: btmon for python 3?
Does it show packets being processed?vespaman wrote: ↑Mon Dec 28, 2020 2:12 pmSo, finally, I had some time to test btmon3.
It has some issues, that I fixed (configparser issue and I also removed "options.ip_poll_interval > 0" check).
After this, I get no errors, it starts up and prints the same stuff that I get on the 2.7 version on my old server, but it does not work. Not sure why. Only thing I know, is that it never sends anything to the broker.
Is there any prefered way to debug this?
Does the MQTT settings show up when you start the script?
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 68
- Joined: Sat Oct 08, 2011 2:48 am
- Location: Sweden
Re: btmon for python 3?
No, I don't think any packets are processed, this is probably where it fails. Here's a sample output:
The last four lines are repeated for each call to the gem. (every 12'th second), (for some reason I did not see them the last time I test, maybe I did not wait enougth time). I don't really know where this is done in the code, I have tried to 'breakpoint()' here and there, but without finding the actual place where the gem polling is done.
Code: Select all
oxygen /etc/btmon # /usr/bin/python /etc/btmon/btmon3.py -c /etc/btmon/gem2.cfg
2020/12/30 14:10:38 btmon: 3.3.1
2020/12/30 14:10:38 python: 3.8.7 (default, Dec 25 2020, 16:06:21)
[GCC 10.2.0]
2020/12/30 14:10:38 platform: linux
2020/12/30 14:10:38 polarity is reversed
2020/12/30 14:10:38 device type: gem
2020/12/30 14:10:38 device list: ['']
2020/12/30 14:10:38 packet format: gem48ptbin
2020/12/30 14:10:38 schema: counters
2020/12/30 14:10:38 SOCKET: timeout: 60
2020/12/30 14:10:38 SOCKET: server host: 10.1.200.11
2020/12/30 14:10:38 SOCKET: server port: 8000
2020/12/30 14:10:38 SOCKET: poll interval: 12
2020/12/30 14:10:38 MQTT: mqtt:localhost:1883?clientid=btmon-gem2
2020/12/30 14:10:38 MQTT: user: <not-specified>
2020/12/30 14:10:38 MQTT: tls: <not-specified>
2020/12/30 14:10:38 MQTT: topic: /house/energy
2020/12/30 14:10:38 MQTT: qos: 0
2020/12/30 14:10:38 MQTT: retain: False
2020/12/30 14:10:38 MQTT: will: <not-specified>
2020/12/30 14:10:38 MQTT: upload period: 12
2020/12/30 14:10:38 MQTT: map:
2020/12/30 14:10:51 a bytes-like object is required, not 'str'
2020/12/30 14:10:51 a bytes-like object is required, not 'str'
2020/12/30 14:10:51 a bytes-like object is required, not 'str'
2020/12/30 14:10:51 3 requests failed for device
The last four lines are repeated for each call to the gem. (every 12'th second), (for some reason I did not see them the last time I test, maybe I did not wait enougth time). I don't really know where this is done in the code, I have tried to 'breakpoint()' here and there, but without finding the actual place where the gem polling is done.
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: btmon for python 3?
Line 1501, try changing :vespaman wrote: ↑Wed Dec 30, 2020 8:14 amNo, I don't think any packets are processed, this is probably where it fails. Here's a sample output:
Code: Select all
oxygen /etc/btmon # /usr/bin/python /etc/btmon/btmon3.py -c /etc/btmon/gem2.cfg 2020/12/30 14:10:38 btmon: 3.3.1 2020/12/30 14:10:38 python: 3.8.7 (default, Dec 25 2020, 16:06:21) [GCC 10.2.0] 2020/12/30 14:10:38 platform: linux 2020/12/30 14:10:38 polarity is reversed 2020/12/30 14:10:38 device type: gem 2020/12/30 14:10:38 device list: [''] 2020/12/30 14:10:38 packet format: gem48ptbin 2020/12/30 14:10:38 schema: counters 2020/12/30 14:10:38 SOCKET: timeout: 60 2020/12/30 14:10:38 SOCKET: server host: 10.1.200.11 2020/12/30 14:10:38 SOCKET: server port: 8000 2020/12/30 14:10:38 SOCKET: poll interval: 12 2020/12/30 14:10:38 MQTT: mqtt:localhost:1883?clientid=btmon-gem2 2020/12/30 14:10:38 MQTT: user: <not-specified> 2020/12/30 14:10:38 MQTT: tls: <not-specified> 2020/12/30 14:10:38 MQTT: topic: /house/energy 2020/12/30 14:10:38 MQTT: qos: 0 2020/12/30 14:10:38 MQTT: retain: False 2020/12/30 14:10:38 MQTT: will: <not-specified> 2020/12/30 14:10:38 MQTT: upload period: 12 2020/12/30 14:10:38 MQTT: map: 2020/12/30 14:10:51 a bytes-like object is required, not 'str' 2020/12/30 14:10:51 a bytes-like object is required, not 'str' 2020/12/30 14:10:51 a bytes-like object is required, not 'str' 2020/12/30 14:10:51 3 requests failed for device
The last four lines are repeated for each call to the gem. (every 12'th second), (for some reason I did not see them the last time I test, maybe I did not wait enougth time). I don't really know where this is done in the code, I have tried to 'breakpoint()' here and there, but without finding the actual place where the gem polling is done.
Code: Select all
def requestpacket(self, com, gemid=''):
idstr = ''
if len(gemid) > 0:
idstr = 'NMB%s' % gemid
com.send('^^^%sAPISPK' % idstr)
Code: Select all
def requestpacket(self, com, gemid=''):
idstr = ''
if len(gemid) > 0:
idstr = 'NMB%s' % gemid
output = '^^^%sAPISPK' % idstr
com.sendall(output.encode('utf-8'))
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 68
- Joined: Sat Oct 08, 2011 2:48 am
- Location: Sweden
Re: btmon for python 3?
So, after doing that, I get these outputs instead (repeated for each poll);
Code: Select all
2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'
2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'
2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'
2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'
2021/01/01 12:33:08 3 requests failed for device
2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'
2021/01/01 12:33:08 3 requests failed for device
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: btmon for python 3?
Revert it to send. Thought that was a direct reference to a socket but the socket is located within the ClientCollector.vespaman wrote: ↑Fri Jan 01, 2021 6:36 amSo, after doing that, I get these outputs instead (repeated for each poll);
Code: Select all
2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall' 2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall'2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall' 2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall' 2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall' 2021/01/01 12:33:08 3 requests failed for device 2021/01/01 12:33:08 'PollingSocketClientCollector' object has no attribute 'sendall' 2021/01/01 12:33:08 3 requests failed for device
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com
-
- Posts: 68
- Joined: Sat Oct 08, 2011 2:48 am
- Location: Sweden
Re: btmon for python 3?
OK, so changing into send, gives me;
I don't think this happens at the same place though.
Sorry for being so clueless with python...
Code: Select all
2021/01/07 17:01:00 can only concatenate str (not "bytes") to str
2021/01/07 17:01:00 3 requests failed for device
Sorry for being so clueless with python...
-
- Site Admin
- Posts: 4269
- Joined: Fri Jun 04, 2010 9:39 am
Re: btmon for python 3?
NP, attach your config file (feel free to remove your serial number, etc) and I'll try running it.vespaman wrote: ↑Thu Jan 07, 2021 11:13 amOK, so changing into send, gives me;I don't think this happens at the same place though.Code: Select all
2021/01/07 17:01:00 can only concatenate str (not "bytes") to str 2021/01/07 17:01:00 3 requests failed for device
Sorry for being so clueless with python...
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Brultech Research Inc.
E: ben(at)brultech.com