BBB PWM (Bonescript Analogwrite)

Hi guys. I’ve been going through the bonescript files so I can get an idea of how everything is set up and working. I ran into something I don’t understand.

On lines 532-538 of this file:
https://github.com/beagleboard/bonescript/blob/master/node_modules/bonescript/index.js

there is a “path” variable referenced, but I cannot find where that is given a value. It is defined on line 30, and maybe I’m just not getting that, but I don’t see anywhere that it is given a value.

This is the section in question:

`


            pwm[pin.pwm.name].old_pwm_path = '/sys/class/pwm/' + pin.pwm.path;

            f.pinMode(pin, gOUTPUT, pin.pwm.muxmode, 'disabled', 'fast');

            // Clear up any unmanaged usage
            fs.writeFileSync(path+'/request', '0');

            // Allocate and configure the PWM
            fs.writeFileSync(path+'/request', '1');
            fs.writeFileSync(path+'/period_freq', Math.round(freq));
            fs.writeFileSync(path+'/polarity', '0');
            fs.writeFileSync(path+'/run', '1');
            pwm[pin.pwm.name].freq = freq;

`

Can anyone help me out here?
Thanks

Hi guys. I’ve been going through the bonescript files so I can get an idea of how everything is set up and working. I ran into something I don’t understand.

On lines 532-538 of this file:
https://github.com/beagleboard/bonescript/blob/master/node_modules/bonescript/index.js

there is a “path” variable referenced, but I cannot find where that is given a value. It is defined on line 30, and maybe I’m just not getting that, but I don’t see anywhere that it is given a value.

This is the section in question:

`


            pwm[pin.pwm.name].old_pwm_path = '/sys/class/pwm/' + pin.pwm.path;

            f.pinMode(pin, gOUTPUT, pin.pwm.muxmode, 'disabled', 'fast');

            // Clear up any unmanaged usage
            fs.writeFileSync(path+'/request', '0');

            // Allocate and configure the PWM
            fs.writeFileSync(path+'/request', '1');
            fs.writeFileSync(path+'/period_freq', Math.round(freq));
            fs.writeFileSync(path+'/polarity', '0');
            fs.writeFileSync(path+'/run', '1');
            pwm[pin.pwm.name].freq = freq;

`

Can anyone help me out here?

Looks like you found a bug that would show up on kernels without capemgr. It seems to be only in the case of setting the initial conditions. Thanks for pointing this out. Are you still using an older kernel? Can I put a fix in and have you test it?

I’ve annotated the issue in the commit where it was created:

Thanks for the reply, Jason. It’s good to know that I wasn’t just missing something obvious. :slight_smile:

I’m actually using the current board release, and everything has been updated to the latest versions, so I don’t know that I would be much help there. I’ve just been learning to mess with bonescript, and was looking through the code to see how it was managing pwm behind the scenes when I saw that.