(function(exports){
	'use strict'
	
	var nRF_flash_exe = (system.os == "windows") ? "flashers/nRF_flash/nRF_flash.exe" : "nRF_flash";
	
	
	exports.write = function(filename, serial) {
		try
		{
			var args=[ filename ];
			if (serial) args.push(serial);
			var rv=system.exec(nRF_flash_exe, args, print, print);
			if (rv != 0) throw new Error("errorcode="+rv);
		} catch (e)
		{
			print("nRF_flash error: "+e+"\n");
			return false;
		}
		
		return true;
	};
})(typeof exports === 'undefined' ? this['_nrf_js']={} : exports);
