Comments (9)
Hi cibermailer,
Could you test this code ?
#!/usr/bin/env python
from xml.dom import minidom
import subprocess
def read_meter(bus_id):
# Retrieve the XML data
cmd = ['mbus-serial-request-data', '-b', '2400', ' /dev/serial0', str(bus_id)]
reqdata = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
mbus_xml, err = reqdata.communicate()
if err:
raise SystemExit, '\nERROR: "' + ' '.join(cmd) + '" returned "' + err + '"'
try:
return minidom.parseString(mbus_xml)
except:
raise SystemExit, '\nERROR: Problem parsing M-Bus XML:\n"' + mbus_xml
if __name__ == '__main__':
result = read_meter(10)
print(result.toxml())
from libmbus.
I created a file test.py on Documents folder. Set chmod a+x on this file. Runned this file by
python test.py also sudo test.py...
I'm getting this error:
ERROR: "mbus-serial-request-data -b 2400 /dev/serial0 10" returned "mbus_serial_connect: failed to open tty.Failed to setup connection to M-bus gateway "
But i can do on command line this:
mbus-serial-request-data -b 2400 /dev/serial0 10
without any problem...
from libmbus.
ohhh is this raspi 3 problem because of disabled access from login shell? ...i give it a try --> IT WASN'T ... so problem exists...have i anything do previous that this communication will work?
from libmbus.
I've read a lot now -> can it be that there is some kind of problem because of:
non-ASCII characters (e.g., French or German OR some kind of timing OR Python Bug because with php it works on my raspberry 3 (raspbian).
ALSO:
your posts script does not make my slave led on Relay PW3 going on. Therefore there is realy no request to it.
My script makes the slave led going on and receiving data...i have both scripts checked but cannot find what can cause that error on your script...
On my script i'm now getting this:
[2017-07-26 14:00:39] SEND (005): 10 40 FD 3D 16 [2017-07-26 14:00:40] SEND (005): 10 40 FD 3D 16 [2017-07-26 14:00:40] SEND (005): 10 5B 0A 65 16 [2017-07-26 14:00:41] RECV (136): 68 82 82 68 08 0A 72 10 00 00 00 2D 2C 01 04 58 00 00 00 0C 07 50 77 40 00 0C 16 03 52 08 00 0C 22 67 17 03 00 0C 59 82 76 00 00 0C 5D 77 49 00 00 0C 61 05 27 00 00 0C 2E 67 00 00 00 0C 3C 15 02 00 00 4C 07 10 71 32 00 4C 16 51 85 06 00 42 6C 1F 2C 0F 10 00 00 00 00 00 63 00 00 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 41 04 00 00 00 00 02 26 07 17 00 64 16 Traceback (most recent call last): File "test.py", line 13, in <module> mbusdata = minidom.parseString(output) File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString return expatbuilder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString return builder.parseString(string) File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString parser.Parse(string, True) xml.parsers.expat.ExpatError: syntax error: line 1, column 0
from libmbus.
I do not think this will help, but you can try putting the utf8 encoding in the file.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Could you print the output and error variable ??
from libmbus.
the returning mbus frame is correct (the hex) ... on bash the hex code is the same like in python.
On bash libmbus does concert the frame automatically. With this function: mbus_frame_print: Dumping M-Bus frame [type 4, 136 bytes]
Calling mbus from python does only give the hex code. this error:
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
should mean there is something wrong, or that the hex can't be handled...some information on the ned do something like wrapping the output: + output +
i'm little confused...is there a way to transform the hex to human readable content stuff?
from libmbus.
Yes, the test directory contains the program mbus_parse_hex, which isn't compiled per default. So you must call make within the test directory.
from libmbus.
Hi,
I managed to get the libmbus library compiled and working on my pi.
I would like to use the python wrapper here
to develop my Mbus scanner application on Python.
The example code is here
In the example code, I see an Mbus instance being initialised in line 16
mbus = MBus(host="mbus-gw1", port=8888)
I would like to have Mbus on serial port /dev/TTYAMA0.
Please guide me on initialising Mbus on the serial port instead of TCP.
from libmbus.
Your question isn't specific to libmbus. Please create a new issue in python-mbus repo.
from libmbus.
Related Issues (20)
- ./build.sh Failure HOT 1
- m.bus Adapter - Current Unrecognized VIF extension: 0x3a - Stromzähler B+G Tech SDM 630 V2 HOT 4
- Cannot find or read devices because of timeouts HOT 5
- Mbus clarification HOT 3
- Finding EMU meters via mbus-tcp-scan-secondary
- Value resolution
- Negative values start with F HOT 4
- rs485 to usb converter and libmbus?
- Documentation not accesible HOT 2
- Decoding frame data
- Add manufactorer specific VIFE infos in (XML) response
- Feature Request: Eastron-SDM-Serie: instantaneous electrical information HOT 5
- Sending different init frames to a slave... HOT 2
- I'm trying to get data from mbus tc, it doesn't find any results when I scan
- Received invalid M-Bus response frame HOT 1
- IPv6 does not work HOT 4
- Pollucom E- reduced / unexpected answer?
- IME Electrical meter support HOT 2
- libmbus problem in python-script HOT 2
- Debian packaging fork HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libmbus.