lib/manufacturing_info_operations.js
function readManufacturingInfoFlashData(bundle) {
		debugRMIOps('in readManufacturingInfoFlashData');
		var defered = q.defer();
		var startingAddress = 0x3C6000;
		var numIntsToRead = 8*8;
		self.readFlash(startingAddress, numIntsToRead)
		.then(function(res) {
			// res is an object with an attribute "results" that is an array
			// of bytes.  Therefore this debug call outputs a lot of data:
			// debugRMIOps('in readManufacturingInfoFlashData res', res);
			var str = '';
			var rawData = [];
			res.results.forEach(function(val) {
				var bA = (val >> 24) & 0xFF;
				rawData.push(bA);
				var bB = (val >> 16) & 0xFF;
				rawData.push(bB);
				var bC = (val >> 8) & 0xFF;
				rawData.push(bC);
				var bD = (val >> 0) & 0xFF;
				rawData.push(bD);
			});
			function isASCII(str, extended) {
			    return (extended ? /^[\x00-\xFF]*$/ : /^[\x00-\x7F]*$/).test(str);
			}
			// debugRMIOps('in readManufacturingInfoFlashData', rawData);
			rawData.forEach(function(raw) {
				var newStrPartial = String.fromCharCode(raw);
				if(isASCII(newStrPartial)) {
					str += newStrPartial;
				}
			});
			debugRMIOps('in readManufacturingInfoFlashData', str);
			// console.log('Data:');
			// console.log(str);
			var noReturnChars = str.split('\r').join('');
			strPartials = noReturnChars.split('\n');

			var manufacturingInfoStr = '';
			// console.log('Processing partials');
			strPartials.forEach(function(strPartial) {
				try {
					// console.log('Checking partial', strPartial);
					if(isData.test(strPartial)) {
						// console.log('Parsing partial', strPartial);
						var parsedInfo = parseManufacturingInfo(strPartial);
						// console.log('Saving partial', strPartial, parsedInfo);
						manufacturingInfoStr += parsedInfo.str;
						manufacturingInfoStr += ': ';
						manufacturingInfoStr += parsedInfo.rawData;
						manufacturingInfoStr += '\n';
						bundle = saveParsedDataToBundle(bundle, parsedInfo);
					} else {
						// console.log('Not Checking partial', strPartial);
					}
				} catch(err) {
					errorLog('Error parsing partial (t7_manufacturing_info_ops.js)', err, strPartial);
					errorLog(err.stack);
					console.error('Error parsing partial (t7_manufacturing_info_ops.js)', err, strPartial);
				}
			});
			// console.log(noReturnChars);
			bundle.infoString = manufacturingInfoStr;
			// console.log(bundle.info);
			defered.resolve(bundle);
		}, function(err) {
			debugRMIOps('in readManufacturingInfoFlashData err', err);
			bundle.isError = true;
			bundle.errorStep = 'readManufacturingInfoFlashData';
			bundle.error = modbusMap.getErrorInfo(err);
			bundle.errorCode = err;
			defered.reject(bundle);
		});
		return defered.promise;
	}
function readManufacturingInfoFlashData(bundle) {
		debugRMIOps('in readManufacturingInfoFlashData');
		var defered = q.defer();
		var startingAddress = 0x3C6000;
		var numIntsToRead = 8*8;
		self.readFlash(startingAddress, numIntsToRead)
		.then(function(res) {
			// res is an object with an attribute "results" that is an array
			// of bytes.  Therefore this debug call outputs a lot of data:
			// debugRMIOps('in readManufacturingInfoFlashData res', res);
			var str = '';
			var rawData = [];
			res.results.forEach(function(val) {
				var bA = (val >> 24) & 0xFF;
				rawData.push(bA);
				var bB = (val >> 16) & 0xFF;
				rawData.push(bB);
				var bC = (val >> 8) & 0xFF;
				rawData.push(bC);
				var bD = (val >> 0) & 0xFF;
				rawData.push(bD);
			});
			function isASCII(str, extended) {
			    return (extended ? /^[\x00-\xFF]*$/ : /^[\x00-\x7F]*$/).test(str);
			}
			// debugRMIOps('in readManufacturingInfoFlashData', rawData);
			rawData.forEach(function(raw) {
				var newStrPartial = String.fromCharCode(raw);
				if(isASCII(newStrPartial)) {
					str += newStrPartial;
				}
			});
			debugRMIOps('in readManufacturingInfoFlashData', str);
			// console.log('Data:');
			// console.log(str);
			var noReturnChars = str.split('\r').join('');
			strPartials = noReturnChars.split('\n');

			var manufacturingInfoStr = '';
			// console.log('Processing partials');
			strPartials.forEach(function(strPartial) {
				try {
					// console.log('Checking partial', strPartial);
					if(isData.test(strPartial)) {
						// console.log('Parsing partial', strPartial);
						var parsedInfo = parseManufacturingInfo(strPartial);
						// console.log('Saving partial', strPartial, parsedInfo);
						manufacturingInfoStr += parsedInfo.str;
						manufacturingInfoStr += ': ';
						manufacturingInfoStr += parsedInfo.rawData;
						manufacturingInfoStr += '\n';
						bundle = saveParsedDataToBundle(bundle, parsedInfo);
					} else {
						// console.log('Not Checking partial', strPartial);
					}
				} catch(err) {
					errorLog('Error parsing partial (t7_manufacturing_info_ops.js)', err, strPartial);
					errorLog(err.stack);
					console.error('Error parsing partial (t7_manufacturing_info_ops.js)', err, strPartial);
				}
			});
			// console.log(noReturnChars);
			bundle.infoString = manufacturingInfoStr;
			// console.log(bundle.info);
			defered.resolve(bundle);
		}, function(err) {
			debugRMIOps('in readManufacturingInfoFlashData err', err);
			bundle.isError = true;
			bundle.errorStep = 'readManufacturingInfoFlashData';
			bundle.error = modbusMap.getErrorInfo(err);
			bundle.errorCode = err;
			defered.reject(bundle);
		});
		return defered.promise;
	}
function readManufacturingInfoFlashData ( bundle ) { debugRMIOps ( 'in readManufacturingInfoFlashData' ) ; var defered = q . defer ( ) ; var startingAddress = 0x3C6000 ; var numIntsToRead = 8 * 8 ; self . readFlash ( startingAddress , numIntsToRead ) . then ( function ( res ) { // res is an object with an attribute "results" that is an array // of bytes.  Therefore this debug call outputs a lot of data: // debugRMIOps('in readManufacturingInfoFlashData res', res); var str = '' ; var rawData = [ ] ; res . results . forEach ( function ( val ) { var bA = ( val >> 24 ) & 0xFF ; rawData . push ( bA ) ; var bB = ( val >> 16 ) & 0xFF ; rawData . push ( bB ) ; var bC = ( val >> 8 ) & 0xFF ; rawData . push ( bC ) ; var bD = ( val >> 0 ) & 0xFF ; rawData . push ( bD ) ; } ) ; function isASCII ( str , extended ) { return ( extended ? / ^[\x00-\xFF]*$ / : / ^[\x00-\x7F]*$ / ) . test ( str ) ; } // debugRMIOps('in readManufacturingInfoFlashData', rawData); rawData . forEach ( function ( raw ) { var newStrPartial = String . fromCharCode ( raw ) ; if ( isASCII ( newStrPartial ) ) { str += newStrPartial ; } } ) ; debugRMIOps ( 'in readManufacturingInfoFlashData' , str ) ; // console.log('Data:'); // console.log(str); var noReturnChars = str . split ( '\r' ) . join ( '' ) ; strPartials = noReturnChars . split ( '\n' ) ; var manufacturingInfoStr = '' ; // console.log('Processing partials'); strPartials . forEach ( function ( strPartial ) { try { // console.log('Checking partial', strPartial); if ( isData . test ( strPartial ) ) { // console.log('Parsing partial', strPartial); var parsedInfo = parseManufacturingInfo ( strPartial ) ; // console.log('Saving partial', strPartial, parsedInfo); manufacturingInfoStr += parsedInfo . str ; manufacturingInfoStr += ': ' ; manufacturingInfoStr += parsedInfo . rawData ; manufacturingInfoStr += '\n' ; bundle = saveParsedDataToBundle ( bundle , parsedInfo ) ; } else { // console.log('Not Checking partial', strPartial); } } catch ( err ) { errorLog ( 'Error parsing partial (t7_manufacturing_info_ops.js)' , err , strPartial ) ; errorLog ( err . stack ) ; console . error ( 'Error parsing partial (t7_manufacturing_info_ops.js)' , err , strPartial ) ; } } ) ; // console.log(noReturnChars); bundle . infoString = manufacturingInfoStr ; // console.log(bundle.info); defered . resolve ( bundle ) ; } , function ( err ) { debugRMIOps ( 'in readManufacturingInfoFlashData err' , err ) ; bundle . isError = true ; bundle . errorStep = 'readManufacturingInfoFlashData' ; bundle . error = modbusMap . getErrorInfo ( err ) ; bundle . errorCode = err ; defered . reject ( bundle ) ; } ) ; return defered . promise ; }
Read the manufacturing data from a T7.
Read the manufacturing data from a T7 .