Apollon77 / node-mbus

Nodejs mbus module
MIT License
21 stars 15 forks source link

Missing values #14

Closed wmmihaa closed 6 years ago

wmmihaa commented 6 years ago

Hi Ingo, sorry to bother you again. It's all working perfectly now, but I'm still missing values from my sensors:

{
  "SlaveInformation": {
    "Id": 68024764,
    "Manufacturer": "ELV",
    "Version": 31,
    "ProductName": "",
    "Medium": "Unknown medium (0x1b)",
    "AccessNumber": 17,
    "Status": 0,
    "Signature": 0
  },
  "DataRecord": [
    {
      "id": 0,
      "Function": "Instantaneous value",
      "StorageNumber": 0,
      "Unit": "Energy (1e7 J)",
      "Value": "",
      "Timestamp": "2018-04-17T21:14:21Z"
    }
  ]
}

As you can see the Value is "". This might not have anything to do with node-mbus, but I'm struggling to understand the debug output (see attached file). Question: Can you see from the output if I get a value? Thank you again. log.log

Apollon77 commented 6 years ago

Can you please try one of the available mbus Softwares or maybe Java stuff to read out the device and see what they report?! We need „second opinion“ if it is the device reporting no value or the library’s doing a passing error ...

Apollon77 commented 6 years ago

And how the device is named? Type? Manufacturer? Link? ;-)

Apollon77 commented 6 years ago

So, from my point of view your device is really sending no data ... here is the messages split fown in it's parts according to http://www.m-bus.com/mbusdoc/default.php

68111168 -> Header, Length: 0x11 = 17 bytes (starting with CI-Field)

08 -> C Field 0000 1000 (F3=1) RSP_UD,ADC/DFC=0
02 -> A Field -> Primary ID=2
72 -> CI Field 0111 0010, Mode 1, variable data response

FIXED HEADER
64470268 -> Ident Nr
9615 -> Manufactorer
1F -> Version
1B -> Medium .. undefined according to standard
17 -> Access Nr
00 -> Status
00 00 -> Signature

VARIABLE DATA
00 -> DIF, Instantaneous value, data length=0 = NO DATA!!, no DIFE
0F ->  VIF VIF (chapter 8.4.3). --> Energy 10(7) J

9C -> Checksum
16 -> Stop

Please check your device

wmmihaa commented 6 years ago

Sorry to bring this thread up again. And I totally get it if you don't have time to answer.

I installed MBSheet on my laptop and hooked up the meter, and of course everything worked fine and all values were displayed :( It did however spit out log data that I could use to compare. Looking at the header there is a difference: libmbus sent: 68 0B 0B 68 73 FD 52 64 47 02 68 96 15 1F 1B BC 16 MBSheet sent: 68 0B 0B 68 73 FD 52 64 47 02 68 FF FF FF FF D3 16

In the next frame: libmbus sent: 10 5B FD 58 16 MBSheet sent: 10 7B FD 78 16

I realize this has probobly nothing to do with your lib, but if you have any hits of what i could do to resolve the issue, I'd be most thankful!

Cheers Mikael

Full output from MBSheet:

TX-buffer:
68 0B 0B 68 73 FD 52 64 47 02 68 FF FF FF FF D3 16 
RX-buffer:
E5 
TX-buffer:
10 7B FD 78 16 
RX-buffer:
68 36 36 68 08 02 72 64 47 02 68 96 15 1F 1B 3F 00 00 00 0C 78 53 16 00 62 02 75 02 00 01 FD 71 20 2F 2F 02 65 5D 09 42 65 16 09 02 FD 1B 30 03 0D FD 0F 05 35 2E 30 2E 33 0F 6B 16
Apollon77 commented 6 years ago

What ID you had set when calling "getData" using libmbus/node-mbus?

wmmihaa commented 6 years ago

The Id I get from the scanSecondary callback. Eg:

mbusMaster.getData('6802476496151F1B', function (err, data) {
    console.log('err: ' + err);
    console.log('data: ' + JSON.stringify(data, null, 2));
    done();
});
Apollon77 commented 6 years ago

Interesting. The other Program you used makes the call with the secondaryaddress "64 47 02 68 FF FF FF FF", maybe try with node-mbus with "68024764FFFFFFFF" ?! Can you assign a primary ID with the software you found? maybe try to assign a primary ID and try query using the primary ID instead.

So it seems to be some kind of addressing problem

wmmihaa commented 6 years ago
mbusMaster.getData('68024764FFFFFFFF', function (err, data) {
    console.log('err: ' + err);
    console.log('data: ' + JSON.stringify(data, null, 2));
});

Gave the same result as before with the second frame as 10 5B FD 58 16 and no value in the output. :(

Apollon77 commented 6 years ago

With node-mbus you should get two of the short commands first to clear previous slave selections. And then the real command with the secondary I’d. After that the response.

Can you send the complete debug from libmbus please?!

wmmihaa commented 6 years ago

CODE:

var MbusMaster = require('node-mbus');
var forEach = require('async-foreach').forEach;

var mbusOptions = {
    serialPort: '/dev/ttyUSB0',
    serialBaudRate: 2400,
    autoConnect: true
};

var mbusMaster = new MbusMaster(mbusOptions);

mbusMaster.getData('68024764FFFFFFFF', function (err, data) {
    console.log('err: ' + err);
    console.log('data: ' + JSON.stringify(data, null, 2));
});

OUTPUT:

mbus_serial_connect: t.c_cflag = 9bb
mbus_serial_connect: t.c_oflag = 0
mbus_serial_connect: t.c_iflag = 0
mbus_serial_connect: t.c_lflag = 0
mbus_serial_send_frame: Dumping M-Bus frame [5 bytes]: 10 40 FD 3D 16
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 0]
mbus_serial_recv_frame: Got 1 byte [remaining 1, len 0]
E5
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 0]
mbus_serial_recv_frame: Got 0 byte [remaining 1, len 0]

mbus_serial_send_frame: Dumping M-Bus frame [5 bytes]: 10 40 FD 3D 16
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 0]
mbus_serial_recv_frame: Got 0 byte [remaining 1, len 0]

mbus_serial_send_frame: Dumping M-Bus frame [17 bytes]: 68 0B 0B 68 73 FD 52 64 47 02 68 FF FF FF FF D3 16
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 0]
mbus_serial_recv_frame: Got 1 byte [remaining 1, len 0]
E5
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 0]
mbus_serial_recv_frame: Got 0 byte [remaining 1, len 0]

mbus_serial_send_frame: Dumping M-Bus frame [5 bytes]: 10 5B FD 58 16
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 0]
mbus_serial_recv_frame: Got 1 byte [remaining 1, len 0]
68
mbus_serial_recv_frame: Attempt to read 2 bytes [len = 1]
mbus_serial_recv_frame: Got 1 byte [remaining 2, len 1]
11
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 2]
mbus_serial_recv_frame: Got 1 byte [remaining 1, len 2]
11
mbus_serial_recv_frame: Attempt to read 20 bytes [len = 3]
mbus_serial_recv_frame: Got 1 byte [remaining 20, len 3]
68
mbus_serial_recv_frame: Attempt to read 19 bytes [len = 4]
mbus_serial_recv_frame: Got 1 byte [remaining 19, len 4]
08
mbus_serial_recv_frame: Attempt to read 18 bytes [len = 5]
mbus_serial_recv_frame: Got 1 byte [remaining 18, len 5]
02
mbus_serial_recv_frame: Attempt to read 17 bytes [len = 6]
mbus_serial_recv_frame: Got 1 byte [remaining 17, len 6]
72
mbus_serial_recv_frame: Attempt to read 16 bytes [len = 7]
mbus_serial_recv_frame: Got 1 byte [remaining 16, len 7]
64
mbus_serial_recv_frame: Attempt to read 15 bytes [len = 8]
mbus_serial_recv_frame: Got 1 byte [remaining 15, len 8]
47
mbus_serial_recv_frame: Attempt to read 14 bytes [len = 9]
mbus_serial_recv_frame: Got 1 byte [remaining 14, len 9]
02
mbus_serial_recv_frame: Attempt to read 13 bytes [len = 10]
mbus_serial_recv_frame: Got 1 byte [remaining 13, len 10]
68
mbus_serial_recv_frame: Attempt to read 12 bytes [len = 11]
mbus_serial_recv_frame: Got 1 byte [remaining 12, len 11]
96
mbus_serial_recv_frame: Attempt to read 11 bytes [len = 12]
mbus_serial_recv_frame: Got 1 byte [remaining 11, len 12]
15
mbus_serial_recv_frame: Attempt to read 10 bytes [len = 13]
mbus_serial_recv_frame: Got 1 byte [remaining 10, len 13]
1F
mbus_serial_recv_frame: Attempt to read 9 bytes [len = 14]
mbus_serial_recv_frame: Got 1 byte [remaining 9, len 14]
1B
mbus_serial_recv_frame: Attempt to read 8 bytes [len = 15]
mbus_serial_recv_frame: Got 1 byte [remaining 8, len 15]
01
mbus_serial_recv_frame: Attempt to read 7 bytes [len = 16]
mbus_serial_recv_frame: Got 1 byte [remaining 7, len 16]
00
mbus_serial_recv_frame: Attempt to read 6 bytes [len = 17]
mbus_serial_recv_frame: Got 1 byte [remaining 6, len 17]
00
mbus_serial_recv_frame: Attempt to read 5 bytes [len = 18]
mbus_serial_recv_frame: Got 1 byte [remaining 5, len 18]
00
mbus_serial_recv_frame: Attempt to read 4 bytes [len = 19]
mbus_serial_recv_frame: Got 1 byte [remaining 4, len 19]
00
mbus_serial_recv_frame: Attempt to read 3 bytes [len = 20]
mbus_serial_recv_frame: Got 1 byte [remaining 3, len 20]
0F
mbus_serial_recv_frame: Attempt to read 2 bytes [len = 21]
mbus_serial_recv_frame: Got 1 byte [remaining 2, len 21]
86
mbus_serial_recv_frame: Attempt to read 1 bytes [len = 22]
mbus_serial_recv_frame: Got 1 byte [remaining 1, len 22]
16
err: null
data: {
  "SlaveInformation": {
    "Id": 68024764,
    "Manufacturer": "ELV",
    "Version": 31,
    "ProductName": "",
    "Medium": "Unknown medium (0x1b)",
    "AccessNumber": 1,
    "Status": 0,
    "Signature": 0
  },
  "DataRecord": [
    {
      "id": 0,
      "Function": "Instantaneous value",
      "StorageNumber": 0,
      "Unit": "Energy (1e7 J)",
      "Value": "",
      "Timestamp": "2018-04-22T22:52:26Z"
    }
  ]
}
Apollon77 commented 6 years ago

Ok, please try 0.5.4 (experimental tag!!). There was mainly only one difference ... after the secondary selection the next command was send without the FCB bit set ... I now try to detect it and send it then out with FCB bit set ... then it should send exactly the same as the software ... we will see ...

Please post full debug log! Thank you

wmmihaa commented 6 years ago

How can I thank you! Brilliant! log.log

Apollon77 commented 6 years ago

Ok, I will sync with libmbus how to incorporate this correctly and then release an official version