lib/t7_flash_operations.js
function(address, innerSize, writeValues)
    {
        return function (lastResults) {
            var innerDeferred = q.defer();

            var addresses = [];
            var values = [];
            var directions = [];
            var numFrames;
            var numValues;

            // Flash memory pointer
            directions.push(driver_const.LJM_WRITE);

            // Key
            if (key === undefined) {
                numFrames = 2;
                numValues = [1];
            } else {
                // Write for key
                directions.push(driver_const.LJM_WRITE);
                addresses.push(driver_const.T7_MA_EXF_KEY);
                values.push(key);
                numFrames = 3;
                numValues = [1, 1];
            }

            if (isReadOp)
                directions.push(driver_const.LJM_READ);
            else
                directions.push(driver_const.LJM_WRITE);

            addresses.push(ptrAddress);
            values.push(address);
            addresses.push(flashAddress);

            if (isReadOp) {
                for (var i=0; i<innerSize; i++) {
                    values.push(null);
                }
            } else {
                values.push.apply(values, writeValues);
            }

            numValues.push(innerSize);
            device.rwMany(
                addresses,
                directions,
                numValues,
                values,
                // createSafeReject(innerDeferred),
                function(err) {
                    // console.log('tseries_upgrade: calling rwMany', isReadOp, addresses, directions, numValues, values);
                    // console.log('tseries_upgrade: rwMany Error', err);
                    // console.log('Throwing Upgrade Error', err);
                    if(!isReadOp) {
                        // console.log('Failed to write flash data', addresses, numValues, values, err);
                    }
                    var callFunc = createSafeReject(innerDeferred);
                    callFunc(err);
                },
                function (newResults) {
                    if(!isReadOp) {
                        // console.log('Successfully wrote flash data', addresses, numValues, values);
                    }
                    lastResults.push.apply(lastResults, newResults);
                    innerDeferred.resolve(lastResults);
                }
            );

            return innerDeferred.promise;
        };
    }
function(address, innerSize, writeValues)
    {
        return function (lastResults) {
            var innerDeferred = q.defer();

            var addresses = [];
            var values = [];
            var directions = [];
            var numFrames;
            var numValues;

            // Flash memory pointer
            directions.push(driver_const.LJM_WRITE);

            // Key
            if (key === undefined) {
                numFrames = 2;
                numValues = [1];
            } else {
                // Write for key
                directions.push(driver_const.LJM_WRITE);
                addresses.push(driver_const.T7_MA_EXF_KEY);
                values.push(key);
                numFrames = 3;
                numValues = [1, 1];
            }

            if (isReadOp)
                directions.push(driver_const.LJM_READ);
            else
                directions.push(driver_const.LJM_WRITE);

            addresses.push(ptrAddress);
            values.push(address);
            addresses.push(flashAddress);

            if (isReadOp) {
                for (var i=0; i<innerSize; i++) {
                    values.push(null);
                }
            } else {
                values.push.apply(values, writeValues);
            }

            numValues.push(innerSize);
            device.rwMany(
                addresses,
                directions,
                numValues,
                values,
                // createSafeReject(innerDeferred),
                function(err) {
                    // console.log('tseries_upgrade: calling rwMany', isReadOp, addresses, directions, numValues, values);
                    // console.log('tseries_upgrade: rwMany Error', err);
                    // console.log('Throwing Upgrade Error', err);
                    if(!isReadOp) {
                        // console.log('Failed to write flash data', addresses, numValues, values, err);
                    }
                    var callFunc = createSafeReject(innerDeferred);
                    callFunc(err);
                },
                function (newResults) {
                    if(!isReadOp) {
                        // console.log('Successfully wrote flash data', addresses, numValues, values);
                    }
                    lastResults.push.apply(lastResults, newResults);
                    innerDeferred.resolve(lastResults);
                }
            );

            return innerDeferred.promise;
        };
    }
function ( address , innerSize , writeValues ) { return function ( lastResults ) { var innerDeferred = q . defer ( ) ; var addresses = [ ] ; var values = [ ] ; var directions = [ ] ; var numFrames ; var numValues ; // Flash memory pointer directions . push ( driver_const . LJM_WRITE ) ; // Key if ( key === undefined ) { numFrames = 2 ; numValues = [ 1 ] ; } else { // Write for key directions . push ( driver_const . LJM_WRITE ) ; addresses . push ( driver_const . T7_MA_EXF_KEY ) ; values . push ( key ) ; numFrames = 3 ; numValues = [ 1 , 1 ] ; } if ( isReadOp ) directions . push ( driver_const . LJM_READ ) ; else directions . push ( driver_const . LJM_WRITE ) ; addresses . push ( ptrAddress ) ; values . push ( address ) ; addresses . push ( flashAddress ) ; if ( isReadOp ) { for ( var i = 0 ; i < innerSize ; i ++ ) { values . push ( null ) ; } } else { values . push . apply ( values , writeValues ) ; } numValues . push ( innerSize ) ; device . rwMany ( addresses , directions , numValues , values , // createSafeReject(innerDeferred), function ( err ) { // console.log('tseries_upgrade: calling rwMany', isReadOp, addresses, directions, numValues, values); // console.log('tseries_upgrade: rwMany Error', err); // console.log('Throwing Upgrade Error', err); if ( ! isReadOp ) { // console.log('Failed to write flash data', addresses, numValues, values, err); } var callFunc = createSafeReject ( innerDeferred ) ; callFunc ( err ) ; } , function ( newResults ) { if ( ! isReadOp ) { // console.log('Successfully wrote flash data', addresses, numValues, values); } lastResults . push . apply ( lastResults , newResults ) ; innerDeferred . resolve ( lastResults ) ; } ) ; return innerDeferred . promise ; } ; }
Creates a closure over a rw excutiong with an address and size
Creates a closure over a rw excutiong with an address and size