GithubHelp home page GithubHelp logo

python-mbus's People

Contributors

cougar avatar rscada avatar sjlongland avatar xmocellin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-mbus's Issues

segfault calling python-mbus

Just running the tests that come with python-mbus causes the Python interpreter to segfault.

libmbus is git head as of this morning, tried both with commit widesky/libmbus@716d712 and widesky/libmbus@ef6c4be. libmbus itself appears to work judging from the test/example programs it comes with, so it looks to be something funny with python-mbus.

RC=0 stuartl@rikishi /tmp/python-mbus $ py.test 
======================================================================== test session starts ========================================================================
platform linux2 -- Python 2.7.7 -- py-1.4.30 -- pytest-2.7.2
rootdir: /tmp/python-mbus, inifile: pytest.ini
plugins: cov
collected 16 items 

tests/test_MBus_connect.py Segmentation fault

Changes to python-mbus:

diff --git a/mbus/MBus.py b/mbus/MBus.py
index 7f26165..671a18f 100644
--- a/mbus/MBus.py
+++ b/mbus/MBus.py
@@ -60,7 +60,7 @@ class MBus:
                 raise TypeError("port number not given as integer")

         if None == libpath:
-            libpath = "/usr/local/lib/libmbus.so"
+            libpath = "/usr/local/lib64/libmbus.so"

         self._libmbus = cdll.LoadLibrary(libpath)

diff --git a/pytest.ini b/pytest.ini
index f84356a..0cd849c 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,8 +1,8 @@
 [pytest]
-addopts = --pep8 --cov-config .coveragerc --cov . tests/
+addopts = --cov-config .coveragerc --cov . tests/

-serialdevice = /dev/adjustme
+serialdevice = /dev/ttyS0
 ;serialdevice = /dev/ttyUSB0

 markers =
-       serial: mark a test to be run with serial device attached
\ No newline at end of file
+       serial: mark a test to be run with serial device attached

Missing field "type" in MBusFrame

I think there is a typo in https://github.com/rscada/python-mbus/blob/master/mbus/MBusFrame.py#L21
the field stop is a duplicate and the second instance probably should be type, according to https://github.com/rscada/libmbus/blob/master/mbus/mbus-protocol.h#L91.

I tried redefining the field as:

diff --git a/mbus/MBusFrame.py b/mbus/MBusFrame.py
index 36358e8..1b9c677 100644
--- a/mbus/MBusFrame.py
+++ b/mbus/MBusFrame.py
@@ -1,4 +1,4 @@
-from ctypes import Structure, c_uint8, c_long, c_size_t, POINTER
+from ctypes import Structure, c_int, c_uint8, c_long, c_size_t, POINTER
 
 c_time_t = c_long
 
@@ -18,7 +18,7 @@ MBusFrame._fields_ = [
         ("stop",     c_uint8),
         ("data",     c_uint8 * 252),
         ("data_size", c_size_t),
-        ("stop",      c_uint8),
+        ("type",      c_int),
         ("timestamp", c_time_t),
         ("next",      POINTER(MBusFrame))
 ]

However, even with this change, I wasn't able to read the type of the MBusFrame (also tried c_uint8 for the type). I'm not that familiar with ctypes, so maybe there is another place where the C struct is mapped to the Python object MBusFrame?

For testing I called the function frame_type from the C library directly and it returned 4 while queryting the type attribute in Python always returned 0.

MBusFrame._fields_.start1 wrong size

Hi,

Is this a typo or why is start1 type c_uint8 * 16 in MBusFrame._fields_? According to https://github.com/rscada/libmbus/blob/master/mbus/mbus-protocol.h#L77 it shoul also be just c_uint8.

typedef struct _mbus_frame {
    unsigned char start1;
    unsigned char length1;
    unsigned char length2;
    unsigned char start2;
...

How do you fill and use the frame structure with such array definition?

I locally changed it to c_uint8

diff --git a/mbus/MBusFrame.py b/mbus/MBusFrame.py
index 9d1b2b5..8f511b6 100644
--- a/mbus/MBusFrame.py
+++ b/mbus/MBusFrame.py
@@ -7,7 +7,7 @@ class MBusFrame(Structure):
         return "MBusFrame: XXX"
 
 MBusFrame._fields_ = [
-        ("start1",   c_uint8 * 16),  # MBusFrameFixed
+        ("start1",   c_uint8),
         ("length1",  c_uint8),
         ("length2",  c_uint8),
         ("start2",   c_uint8),

Now I can easily create MBus frames with code like this:

        mbus_frame = MBusFrame()
        mbus_frame.start1 = MBUS_FRAME_LONG_START
        mbus_frame.length1 = data_size + 3 
        mbus_frame.length2 = mbus_frame.length1
        mbus_frame.start2 = mbus_frame.start1
...

Is this a mistake and should I send a pull request for that or is it possible to use this structure in any other way?

Problems wrong .so

Hello

I've been testing this code but I can't do much. Seems that this was not designed for the latest version of libmbus.

Can you give me some help on this?

Mbus serial port instance

Hi,
I managed to get the libmbus library compiled and working on my pi.
I would like to use the python wrapper
to develop my Mbus scanner application on Python.

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.

change baudrate

is it possible to change the baudrate? i tried to call the function 'serial_set_baudrate' of MBusLowLevel but i don't know what mbus_handle_p object to pass.

license

The original code states no specific FLOSS-license. Which one to choose? I would go for a 3-clause BSD license like libmbus, but AGPL is also fine.

Cheers,
tpltnt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.