Git Product home page Git Product logo

Comments (3)

aborovsky avatar aborovsky commented on September 14, 2024

Hello, @johnvestberg!
I'm sorry for not so fast response :)
We'll check how it works today with KNX gateway.

May I ask you to provide some more info (and may be error log) of your problem with floating point values?

from knx.js.

aborovsky avatar aborovsky commented on September 14, 2024

Closed with #2f6b000

from knx.js.

johnvestberg avatar johnvestberg commented on September 14, 2024

Hi, my turn to apologize for my late response! :)

The error I was experiencing was that for all data types larger than two bytes, the following code in KnxHelper.js (function GetData) was supposed to be executed:

var data = new Buffer(apdu.length);
//TODO: originally, here is utf code to char convert (String.fromCharCode).
apdu[i].copy(data);

However, the code never seemed to execute successfully, so I assume the copy method was throwing some unhandled exception or just caused the thread to abort. I am using the knx.js package as part of the node-red-contrib-knx package. I added a debug=true statement to the knx connection to get as much debug output as possible when running node-red from console. I added a console.log statement just after the apdu[i].copy(data) call, but that log never produced any output. Hence, my assumption that the thread just aborted or something similar.

My own workaround was just to convert the data to floating point when the data length was 3 (similar to your newly committed code). But short after that, I stumbled on the next issue, when I received KNX events with DPT 14 (4 bytes IEEE floating point values). My conclusion then (maybe wrong?) was that I cannot use the length of the data for deciding how to convert it, as several different data types have the same data length. For instance, DPT 13 and DPT 14 are both 4 bytes, but represent different data types.

For this reason, my current workaround is that for all data types bigger than 2 bytes, I write the values as a hex string representation. Then, in node-red when I consume the events, I have a javascript function that converts the hex strings to the respective data type depending on the group address that sent the event.

This workaround works (for now), but obviously it is not a very elegant solution.

from knx.js.

Related Issues (6)

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.