njh/node-owfs

Getting empty strings back when no devices

njh opened this issue · 2 comments

njh commented

Hello,

I have just been testing the behaviour of making requests to owserver, when there are no devices connected. I have been doing this using the fake parameter to owserver:

owserver \
  --foreground \
  --Celsius \
  --error_print=2 \
  --error_level=4 \
  --fake=

I am not expecting any "device: " or "property: " lines being logged, but I am:

var owfs = require("owfs");
var async = require("async");


var client = new owfs.Client('localhost', 4304);
client.dirall("/",function(error, directories) {
    if (!error) {
        async.mapSeries(directories,
            function(directory,cb) {
                client.dirall(directory,cb);
            },
            function(error, results) {
                if (!error) {
                    results.forEach(function(device) {
                        console.log("device: "+device);
                        device.forEach(function(property) {
                            console.log("property: "+property);
                        });
                    });
                } else {
                    console.log("Failed to get properties for device: "+error);
                }
                console.log("Done.");
            }
        );
    } else {
        console.log("Failed to get list of devices: "+error);
    }
});

Is this due to a protocol parse error, or is owserver sending back bad data?

Thank's for the bug report.

It was an error in parsing the message from owserver. owserver is sending an empty payload string and I was handling it wrong. Fixed, add test and published as 0.2.1

Have fun.

njh commented

Awesome! Thanks for the speedy fix.