rem: if(pwm[pin.pwm.path] && pwm[pin.pwm.path].key) { if(pwm[pin.pwm.path].key != pin.key) { throw(pin.key + ' requires pwm ' + pin.pwm.name + ' but it is already in use by ' + pwm[pin.pwm].key ); } 
add:   if((typeof pwm[pin.pwm.name] != 'undefined') && (pin.key != pwm[pin.pwm.name].key)) { throw(pin.key + ' requires pwm ' + pin.pwm.name + ' but it is already in use by ' + pwm[pin.pwm].key ); }   if(typeof pwm[pin.pwm.name] == 'undefined') { pwm[pin.pwm.name] = {}; pwm[pin.pwm.name].key = pin.key; var fragment = 'bone_pwm_' + pin.key; if(load_dt('am33xx_pwm') && load_dt(fragment)) { var ocp = file_find('/sys/devices', 'ocp.'); var pwm_test = file_find(ocp, 'pwm_test_' + pin.key + '.', 10000); pwm[pin.pwm.name].pwm_test_path = pwm_test; pwm[pin.pwm.name].freq = 0; } else { pwm[pin.pwm.name].old_pwm_path = '/sys/class/pwm/' + pin.pwm.path;  f.pinMode(pin, gOUTPUT, pin.pwm.muxmode, 'disabled', 'fast');   fs.writeFileSync(path+'/request', '0');   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; } pwm[pin.pwm.name].key = pin.key; }   if(typeof pwm[pin.pwm.name].pwm_test_path === 'string') { if(pwm[pin.pwm.name].freq != freq) { var period = Math.round( 1.0e9 / freq ); fs.writeFileSync(pwm[pin.pwm.name].pwm_test_path+'/period', period); } var duty = Math.round( period * value ); fs.writeFileSync(pwm[pin.pwm.name].pwm_test_path+'/duty', duty); 
context: f.analogWrite = function(pin, value, freq, callback) {    pin = getpin(pin);    freq = freq || 1000;    var path = '/sys/class/pwm/' + pin.pwm.path;    //var curMode = getPinMode(pin);    // Not yet possible to implement this test    //if(curMode.direction != OUTPUT) {    //    throw(pin.key + ' must be configured as OUTPUT for analogWrite()');    //}    if(!pin.pwm) {        throw(pin.key + ' does not support analogWrite()');    }    if(pwm[pin.pwm.path] && pwm[pin.pwm.path].key) {        if(pwm[pin.pwm.path].key != pin.key) {            throw(pin.key + ' requires pwm ' + pin.pwm.name +                ' but it is already in use by ' +                pwm[pin.pwm].key            );         }    } else {        pwm[pin.pwm.path] = {};        pwm[pin.pwm.path].key = '' + pin.key;        pwm[pin.pwm.path].freq = freq;        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', freq);        fs.writeFileSync(path+'/polarity', '0');        fs.writeFileSync(path+'/run', '1');    }    if(pwm[pin.pwm.path].freq != freq) {        fs.writeFileSync(path+'/run', '0');        fs.writeFileSync(path+'/duty_percent', '0');        fs.writeFileSync(path+'/period_freq', freq);        fs.writeFileSync(path+'/run', '1');        pwm[pin.pwm.path].freq = freq;    }    fs.writeFileSync(path+'/duty_percent', Math.round(value*100));    if(callback) callback();};
meta: 3863	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/3863/ce011b7f00c4b14c71589e8986ebe4bce3c6f151/index.js/buggy/node_modules/bonescript/index.js