Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaminfo #4

Open
onaclov2000 opened this issue Jan 5, 2015 · 5 comments
Open

Streaminfo #4

onaclov2000 opened this issue Jan 5, 2015 · 5 comments

Comments

@onaclov2000
Copy link
Contributor

With the following code ( chaining things per your suggestion with the last issue).

var hdhr = require('hdhomerun');

hdhr.discover(function (err, res) {
    console.log(res);

    var device = hdhr.create({device_id: res[0]['device_id'],
       device_ip: res[0]['device_ip']});

   device.set('/tuner0/channel', 'auto:51', function (err, res) {
        console.log(res);
       device.get('/tuner0/streaminfo', function (err, res) {
           console.log(res);
      });
     });

 //device.get('/tuner0/streaminfo', function(err, res) {
 //  console.log(res);
 //});
});

produces the following output:

[ { len: 15,
device_id: '103DA852',
device_type: 'tuner',
tuner_count: 2,
checksum: 120479540,
_offset: 23,
device_ip: '192.168.0.26' } ]
{ name: '/tuner0/channel', value: 'auto:51' }
{ name: '/tuner0/streaminfo', value: 'none\n' }

However uncommenting out the "last" streaminfo,
[ { len: 15,
device_id: '103DA852',
device_type: 'tuner',
tuner_count: 2,
checksum: 120479540,
_offset: 23,
device_ip: '192.168.0.26' } ]
{ name: '/tuner0/channel', value: 'auto:51' }
undefined
{ name: '/tuner0/streaminfo',
value: '1: 30.1 KYNM-HD\n2: 30.2 TUFF-TV\n3: 30.3 Retro\n4: 30.4 PBJ-TV\n5: 30.5 QVC\ntsid=0x1383\n' }

Commenting out the former streaminfo (thinking that maybe it didn't need to be chained?) results in the following:
[ { len: 15,
device_id: '103DA852',
device_type: 'tuner',
tuner_count: 2,
checksum: 120479540,
_offset: 23,
device_ip: '192.168.0.26' } ]
{ name: '/tuner0/channel', value: 'auto:51' }
undefined

I'll be happy to update the documentation if I can figure out the "proper" way to use it.

:)

Thank you,
Tyson

@onaclov2000
Copy link
Contributor Author

I was thinking about this, and wonder if this is also timing related, i swear i read somewhere there was a 5000 wait to tune a channel so it could stabilize the symbols or somehing, but the _request has a max timeout of 2500, so putting a second one right after the first, causes a 'extra' 2500 timeout, which allows stabilization and finally returns the right result. I havent tried just reading stream info without a combined channel change, ill try that tonight maybe

@mharsch
Copy link
Owner

mharsch commented Jan 5, 2015

Yes, they do wait 5 seconds for the device to settle on a channel: https://github.com/mharsch/libhdhomerun/blob/master/hdhomerun_channelscan.c#L88

@onaclov2000
Copy link
Contributor Author

Yep, confirmed,,
var hdhr = require('hdhomerun');

hdhr.discover(function (err, res) {
console.log(res);

var device = hdhr.create({device_id: res[0]['device_id'],
device_ip: res[0]['device_ip']});

//device.set('/tuner0/channel', 'auto:51', function (err, res) {
// console.log(res);
// device.get('/tuner0/streaminfo', function (err, res) {
// console.log(res);
// });
//});

device.get('/tuner0/streaminfo', function(err, res) {
console.log(res);
});

Produces the correct output.
I'm wondering in the case of tuning a channel, if an additional timeout should be added, so when it returns with the function, we know its on the channel and everything is stable.

@mharsch
Copy link
Owner

mharsch commented Jan 5, 2015

I implemented the logic for polling channel status in my example code:
https://github.com/mharsch/node-hdhomerun/blob/master/examples/channelscan.js#L105

See poll_lock and poll_seq, called by test_channel.

@onaclov2000
Copy link
Contributor Author

That should be handy, I'll have to look into that, I will want to (myself) expose that as a function call, with a callback that has the data..... If I do I can show you the updates, and if you want to include them, we can do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants