Esempio n. 1
0
File: main.c Progetto: OPSF/uClinux
/**
 * If our C library can get malloc statistics, then show them to FINFO
 **/
static void show_malloc_stats(void)
{
#ifdef HAVE_MALLINFO
	struct mallinfo mi;

	mi = mallinfo();

	rprintf(FINFO, "\n" RSYNC_NAME "[%d] (%s%s%s) heap statistics:\n",
		getpid(), am_server ? "server " : "",
		am_daemon ? "daemon " : "", who_am_i());
	rprintf(FINFO, "  arena:     %10ld   (bytes from sbrk)\n",
		(long)mi.arena);
	rprintf(FINFO, "  ordblks:   %10ld   (chunks not in use)\n",
		(long)mi.ordblks);
	rprintf(FINFO, "  smblks:    %10ld\n",
		(long)mi.smblks);
	rprintf(FINFO, "  hblks:     %10ld   (chunks from mmap)\n",
		(long)mi.hblks);
	rprintf(FINFO, "  hblkhd:    %10ld   (bytes from mmap)\n",
		(long)mi.hblkhd);
	rprintf(FINFO, "  allmem:    %10ld   (bytes from sbrk + mmap)\n",
		(long)mi.arena + mi.hblkhd);
	rprintf(FINFO, "  usmblks:   %10ld\n",
		(long)mi.usmblks);
	rprintf(FINFO, "  fsmblks:   %10ld\n",
		(long)mi.fsmblks);
	rprintf(FINFO, "  uordblks:  %10ld   (bytes used)\n",
		(long)mi.uordblks);
	rprintf(FINFO, "  fordblks:  %10ld   (bytes free)\n",
		(long)mi.fordblks);
	rprintf(FINFO, "  keepcost:  %10ld   (bytes in releasable chunk)\n",
		(long)mi.keepcost);
#endif /* HAVE_MALLINFO */
}
Esempio n. 2
0
File: main.c Progetto: OPSF/uClinux
/* Start the remote shell.   cmd may be NULL to use the default. */
static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
		    int *f_in, int *f_out)
{
	int i, argc = 0;
	char *args[MAX_ARGS];
	pid_t ret;
	char *tok, *dir = NULL;
	int dash_l_set = 0;

	if (!read_batch && !local_server) {
		char *rsh_env = getenv(RSYNC_RSH_ENV);
		if (!cmd)
			cmd = rsh_env;
		if (!cmd)
			cmd = RSYNC_RSH;
		cmd = strdup(cmd);
		if (!cmd)
			goto oom;

		for (tok = strtok(cmd, " "); tok; tok = strtok(NULL, " ")) {
			/* Comparison leaves rooms for server_options(). */
			if (argc >= MAX_ARGS - MAX_SERVER_ARGS) {
				rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
				exit_cleanup(RERR_SYNTAX);
			}
			args[argc++] = tok;
		}

		/* check to see if we've already been given '-l user' in
		 * the remote-shell command */
		for (i = 0; i < argc-1; i++) {
			if (!strcmp(args[i], "-l") && args[i+1][0] != '-')
				dash_l_set = 1;
		}

#ifdef HAVE_REMSH
		/* remsh (on HPUX) takes the arguments the other way around */
		args[argc++] = machine;
		if (user && !(daemon_over_rsh && dash_l_set)) {
			args[argc++] = "-l";
			args[argc++] = user;
		}
#else
		if (user && !(daemon_over_rsh && dash_l_set)) {
			args[argc++] = "-l";
			args[argc++] = user;
		}
		args[argc++] = machine;
#endif

		args[argc++] = rsync_path;

		if (blocking_io < 0) {
			char *cp;
			if ((cp = strrchr(cmd, '/')) != NULL)
				cp++;
			else
				cp = cmd;
			if (strcmp(cp, "rsh") == 0 || strcmp(cp, "remsh") == 0)
				blocking_io = 1;
		}

		server_options(args,&argc);

		if (argc >= MAX_ARGS - 2) {
			rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
			exit_cleanup(RERR_SYNTAX);
		}
	}

	args[argc++] = ".";

	if (!daemon_over_rsh && path && *path)
		args[argc++] = path;

	args[argc] = NULL;

	if (verbose > 3) {
		rprintf(FINFO,"cmd=");
		for (i = 0; i < argc; i++)
			rprintf(FINFO, "%s ", safe_fname(args[i]));
		rprintf(FINFO,"\n");
	}

	if (read_batch) {
		int from_gen_pipe[2];
		if (fd_pair(from_gen_pipe) < 0) {
			rsyserr(FERROR, errno, "pipe");
			exit_cleanup(RERR_IPC);
		}
		batch_gen_fd = from_gen_pipe[0];
		*f_out = from_gen_pipe[1];
		*f_in = batch_fd;
		ret = -1; /* no child pid */
	} else if (local_server) {
		/* If the user didn't request --[no-]whole-file, force
		 * it on, but only if we're not batch processing. */
		if (whole_file < 0 && !write_batch)
			whole_file = 1;
		ret = local_child(argc, args, f_in, f_out, child_main);
	} else
		ret = piped_child(args,f_in,f_out);

	if (dir)
		free(dir);

	return ret;

oom:
	out_of_memory("do_cmd");
	return 0; /* not reached */
}
Esempio n. 3
0
//sets the range of a color bin (0-9)
//example:	vc0090255000255000255      returns ##vc0
//          012345678901234567890
//sets color bin #0 using Y mean, 255, 0, 255, 0, 255 so
//pixels of higher than average brightness will appear in blob search
void Blackfin_Bin_Range(int bin, int y_min, int y_max, int u_min, int u_max, int v_min, int v_max)
	{
	rprintfInit(uart3SendByte);//change UART to Blackfin
	uartFlushReceiveBuffer(3);//flush out receive camera buffer to stop phase shifting

	rprintf("vc%d",bin);//start command, send bin #
	rprintf("%d%d%d",y_min/100,y_min%100/10,y_min%100%10);
	rprintf("%d%d%d",y_max/100,y_max%100/10,y_max%100%10);
	rprintf("%d%d%d",u_min/100,u_min%100/10,u_min%100%10);
	rprintf("%d%d%d",u_max/100,u_max%100/10,u_max%100%10);
	rprintf("%d%d%d",v_min/100,v_min%100/10,v_min%100%10);
	rprintf("%d%d%d",v_max/100,v_max%100/10,v_max%100%10);

	Blackfin_Echo(6);//maybe 5?

	
	//test code
	rprintfInit(uart0SendByte);//change UART to bluetooth

	rprintf("vc%d",bin);//start command, send bin #
	rprintf("%d%d%d",y_min/100,y_min%100/10,y_min%100%10);
	rprintf("%d%d%d",y_max/100,y_max%100/10,y_max%100%10);
	rprintf("%d%d%d",u_min/100,u_min%100/10,u_min%100%10);
	rprintf("%d%d%d",u_max/100,u_max%100/10,u_max%100%10);
	rprintf("%d%d%d",v_min/100,v_min%100/10,v_min%100%10);
	rprintf("%d%d%d\r\n",v_max/100,v_max%100/10,v_max%100%10);
	}
Esempio n. 4
0
File: main.c Progetto: OPSF/uClinux
static void output_summary(void)
{
	if (do_stats) {
		rprintf(FINFO,"\nNumber of files: %d\n", stats.num_files);
		rprintf(FINFO,"Number of files transferred: %d\n",
			stats.num_transferred_files);
		rprintf(FINFO,"Total file size: %.0f bytes\n",
			(double)stats.total_size);
		rprintf(FINFO,"Total transferred file size: %.0f bytes\n",
			(double)stats.total_transferred_size);
		rprintf(FINFO,"Literal data: %.0f bytes\n",
			(double)stats.literal_data);
		rprintf(FINFO,"Matched data: %.0f bytes\n",
			(double)stats.matched_data);
		rprintf(FINFO,"File list size: %d\n", stats.flist_size);
		if (stats.flist_buildtime) {
			rprintf(FINFO,
				"File list generation time: %.3f seconds\n",
				(double)stats.flist_buildtime / 1000);
			rprintf(FINFO,
				"File list transfer time: %.3f seconds\n",
				(double)stats.flist_xfertime / 1000);
		}
		rprintf(FINFO,"Total bytes sent: %.0f\n",
			(double)total_written);
		rprintf(FINFO,"Total bytes received: %.0f\n",
			(double)total_read);
	}

	if (verbose || do_stats) {
		rprintf(FINFO,
			"\nsent %.0f bytes  received %.0f bytes  %.2f bytes/sec\n",
			(double)total_written, (double)total_read,
			(total_written + total_read)/(0.5 + (endtime - starttime)));
		rprintf(FINFO, "total size is %.0f  speedup is %.2f\n",
			(double)stats.total_size,
			(double)stats.total_size / (total_written+total_read));
	}

	fflush(stdout);
	fflush(stderr);
}
Esempio n. 5
0
File: main.c Progetto: OPSF/uClinux
/**
 * Start a client for either type of remote connection.  Work out
 * whether the arguments request a remote shell or rsyncd connection,
 * and call the appropriate connection function, then run_client.
 *
 * Calls either start_socket_client (for sockets) or do_cmd and
 * client_run (for ssh).
 **/
static int start_client(int argc, char *argv[])
{
	char *p;
	char *shell_machine = NULL;
	char *shell_path = NULL;
	char *shell_user = NULL;
	int ret;
	pid_t pid;
	int f_in,f_out;
	int rc;

	/* Don't clobber argv[] so that ps(1) can still show the right
	 * command line. */
	if ((rc = copy_argv(argv)))
		return rc;

	if (!read_batch) { /* for read_batch, NO source is specified */
		argc--;
		shell_path = check_for_hostspec(argv[0], &shell_machine, &rsync_port);
		if (shell_path) { /* source is remote */
			argv++;
			if (filesfrom_host && *filesfrom_host
			    && strcmp(filesfrom_host, shell_machine) != 0) {
				rprintf(FERROR,
					"--files-from hostname is not the same as the transfer hostname\n");
				exit_cleanup(RERR_SYNTAX);
			}
			if (rsync_port) {
				if (!shell_cmd) {
					return start_socket_client(shell_machine,
								   shell_path,
								   argc, argv);
				}
				daemon_over_rsh = 1;
			}

			am_sender = 0;
		} else { /* source is local, check dest arg */
			am_sender = 1;

			if (argc < 1) { /* destination required */
				usage(FERROR);
				exit_cleanup(RERR_SYNTAX);
			}

			shell_path = check_for_hostspec(argv[argc], &shell_machine, &rsync_port);
			if (shell_path && filesfrom_host && *filesfrom_host
			    && strcmp(filesfrom_host, shell_machine) != 0) {
				rprintf(FERROR,
					"--files-from hostname is not the same as the transfer hostname\n");
				exit_cleanup(RERR_SYNTAX);
			}
			if (!shell_path) { /* no hostspec found, so src & dest are local */
				local_server = 1;
				if (filesfrom_host) {
					rprintf(FERROR,
						"--files-from cannot be remote when the transfer is local\n");
					exit_cleanup(RERR_SYNTAX);
				}
				shell_machine = NULL;
				shell_path = argv[argc];
			} else if (rsync_port) {
				if (!shell_cmd) {
					return start_socket_client(shell_machine,
								   shell_path,
								   argc, argv);
				}
				daemon_over_rsh = 1;
			}
		}
	} else {  /* read_batch */
		local_server = 1;
		shell_path = argv[argc-1];
		if (check_for_hostspec(shell_path, &shell_machine, &rsync_port)) {
			rprintf(FERROR, "remote destination is not allowed with --read-batch\n");
			exit_cleanup(RERR_SYNTAX);
		}
	}

	if (shell_machine) {
		p = strrchr(shell_machine,'@');
		if (p) {
			*p = 0;
			shell_user = shell_machine;
			shell_machine = p+1;
		}
	}

	if (verbose > 3) {
		rprintf(FINFO,"cmd=%s machine=%s user=%s path=%s\n",
			shell_cmd ? safe_fname(shell_cmd) : "",
			shell_machine ? safe_fname(shell_machine) : "",
			shell_user ? safe_fname(shell_user) : "",
			shell_path ? safe_fname(shell_path) : "");
	}

	/* for remote source, only single dest arg can remain ... */
	if (!am_sender && argc > 1) {
		usage(FERROR);
		exit_cleanup(RERR_SYNTAX);
	}

	/* ... or no dest at all */
	if (!am_sender && argc == 0)
		list_only |= 1;

	pid = do_cmd(shell_cmd,shell_machine,shell_user,shell_path,
		     &f_in,&f_out);

	/* if we're running an rsync server on the remote host over a
	 * remote shell command, we need to do the RSYNCD protocol first */
	if (daemon_over_rsh) {
		int tmpret;
		tmpret = start_inband_exchange(shell_user, shell_path,
					       f_in, f_out, argc);
		if (tmpret < 0)
			return tmpret;
	}

	ret = client_run(f_in, f_out, pid, argc, argv);

	fflush(stdout);
	fflush(stderr);

	return ret;
}
Esempio n. 6
0
void LKProfileSave(const TCHAR *szFile)
{
  #if TESTBENCH
  StartupStore(_T("... SaveProfile <%s>%s"),szFile,NEWLINE);
  #endif

  
  if (_tcslen(szFile)>0)
	pfp = _tfopen(szFile, TEXT("wb")); // 'w' will overwrite content, 'b' for no crlf translation

  if(pfp == NULL) {
	StartupStore(_T("...... SaveProfile <%s> open for write FAILED!%s"),szFile,NEWLINE);
	return;
  }

  //
  // Standard header
  //
  fprintf(pfp,"### LK8000 PROFILE - DO NOT EDIT%s",PNEWLINE);
  fprintf(pfp,"### THIS FILE IS ENCODED IN UTF8%s",PNEWLINE);
  fprintf(pfp,"LKVERSION=\"%s.%s\"%s",LKVERSION,LKRELEASE,PNEWLINE);
  fprintf(pfp,"PROFILEVERSION=2%s",PNEWLINE);

  // 
  // RESPECT LKPROFILE.H ALPHA ORDER OR WE SHALL GET LOST SOON!
  //
  // -- USE _CONFIG VARIABLES WHEN A RUNTIME VALUE CAN BE CHANGED --
  // WE DONT WANT TO SAVE RUNTIME TEMPORARY CONFIGURATIONS, ONLY SYSTEM CONFIG!
  // FOR EXAMPLE: ActiveMap can be set by default in system config, but also changed
  // at runtime with a button and with a customkey. We must save in profile ONLY
  // the _Config, not the temporary setup!
  // 



  rprintf(szRegistryAcknowledgementTime, AcknowledgementTime);
  rprintf(szRegistryAdditionalAirspaceFile, szAdditionalAirspaceFile);
  rprintf(szRegistryAdditionalWayPointFile, szAdditionalWaypointFile);
//  >> Moved to AircraftFile <<
//  rprintf(szRegistryAircraftCategory, AircraftCategory);
//  rprintf(szRegistryAircraftRego, AircraftRego_Config);
//  rprintf(szRegistryAircraftType, AircraftType_Config);
  rprintf(szRegistryAirfieldFile, szAirfieldFile); 
  rprintf(szRegistryAirspaceFile, szAirspaceFile);
  rprintf(szRegistryAirspaceFillType, MapWindow::GetAirSpaceFillType()); 
  rprintf(szRegistryAirspaceOpacity, MapWindow::GetAirSpaceOpacity()); 
  rprintf(szRegistryAirspaceWarningDlgTimeout, AirspaceWarningDlgTimeout);
  rprintf(szRegistryAirspaceWarningMapLabels, AirspaceWarningMapLabels);
  rprintf(szRegistryAirspaceAckAllSame, AirspaceAckAllSame);
  rprintf(szRegistryAirspaceWarningRepeatTime, AirspaceWarningRepeatTime);
  rprintf(szRegistryAirspaceWarningVerticalMargin, AirspaceWarningVerticalMargin);
  rprintf(szRegistryAirspaceWarning, AIRSPACEWARNINGS);
  rprintf(szRegistryAlarmMaxAltitude1, AlarmMaxAltitude1); // saved *1000, /1000 when used
  rprintf(szRegistryAlarmMaxAltitude2, AlarmMaxAltitude2);
  rprintf(szRegistryAlarmMaxAltitude3, AlarmMaxAltitude3);
  rprintf(szRegistryAlarmTakeoffSafety, AlarmTakeoffSafety);
  rprintf(szRegistryAltMargin, AltWarningMargin);
  rprintf(szRegistryAltMode, AltitudeMode_Config);
  rprintf(szRegistryAlternate1, Alternate1); // these are not part of configuration, but saved all the same
  rprintf(szRegistryAlternate2, Alternate2);
  rprintf(szRegistryAltitudeUnitsValue, AltitudeUnit_Config);
  rprintf(szRegistryAppDefaultMapWidth, Appearance.DefaultMapWidth);
  rprintf(szRegistryAppIndLandable,Appearance.IndLandable);
//  rprintf(szRegistryAppInfoBoxModel,GlobalModelType); // We save GlobalModelType, not InfoBoxModel
  rprintf(szRegistryAppInverseInfoBox,InverseInfoBox_Config);
  rprintf(szRegistryArrivalValue,ArrivalValue);
  rprintf(szRegistryAutoAdvance,AutoAdvance_Config);
  rprintf(szRegistryAutoBacklight,EnableAutoBacklight);
  rprintf(szRegistryAutoForceFinalGlide,AutoForceFinalGlide);
  rprintf(szRegistryAutoMcMode,AutoMcMode_Config);
/*
  rprintf(szRegistryAutoMcMode,AutoMcMode);
  int tmp = (int)(MACCREADY*100.0);
  rprintf(szRegistryMacCready,tmp);*/
  rprintf(szRegistryAutoMcStatus,AutoMacCready_Config);
 // rprintf(szRegistryAutoMcStatus,AutoMacCready);
  rprintf(szRegistryAutoOrientScale,AutoOrientScale*10);
  rprintf(szRegistryAutoSoundVolume,EnableAutoSoundVolume);
  rprintf(szRegistryAutoWind,AutoWindMode_Config);
  rprintf(szRegistryAutoZoom,AutoZoom_Config);
  rprintf(szRegistryAverEffTime,AverEffTime);
//  >> Moved to AircraftFile <<
//  rprintf(szRegistryBallastSecsToEmpty,BallastSecsToEmpty);
  rprintf(szRegistryBarOpacity,BarOpacity);
  rprintf(szRegistryBestWarning,BestWarning);
  rprintf(szRegistryBgMapColor,BgMapColor_Config);
//  rprintf(szRegistryBit1Index,dwBit1Index);
//  rprintf(szRegistryBit2Index,dwBit2Index);
  rprintf(szRegistryBugs,BUGS_Config*100);
//  rprintf(szRegistryCheckSum,CheckSum);
  rprintf(szRegistryCircleZoom,MapWindow::zoom.CircleZoom());
  rprintf(szRegistryClipAlt,ClipAltitude);
//  >> Moved to AircraftFile <<
//  rprintf(szRegistryCompetitionClass,CompetitionClass_Config);
//  rprintf(szRegistryCompetitionID,CompetitionID_Config);
  rprintf(szRegistryConfBB0,ConfBB0);
  rprintf(szRegistryConfBB1,ConfBB1);
  rprintf(szRegistryConfBB2,ConfBB2);
  rprintf(szRegistryConfBB3,ConfBB3);
  rprintf(szRegistryConfBB4,ConfBB4);
  rprintf(szRegistryConfBB5,ConfBB5);
  rprintf(szRegistryConfBB6,ConfBB6);
  rprintf(szRegistryConfBB7,ConfBB7);
  rprintf(szRegistryConfBB8,ConfBB8);
  rprintf(szRegistryConfBB9,ConfBB9);
  rprintf(szRegistryConfBB0Auto,ConfBB0Auto);
  rprintf(szRegistryConfIP11,ConfIP11);
  rprintf(szRegistryConfIP12,ConfIP12);
  rprintf(szRegistryConfIP13,ConfIP13);
  rprintf(szRegistryConfIP14,ConfIP14);
  rprintf(szRegistryConfIP15,ConfIP15);
  rprintf(szRegistryConfIP16,ConfIP16);
  rprintf(szRegistryConfIP17,ConfIP17);
  rprintf(szRegistryConfIP21,ConfIP21);
  rprintf(szRegistryConfIP22,ConfIP22);
  rprintf(szRegistryConfIP23,ConfIP23);
  rprintf(szRegistryConfIP24,ConfIP24);
  rprintf(szRegistryConfIP31,ConfIP31);
  rprintf(szRegistryConfIP32,ConfIP32);
  rprintf(szRegistryConfIP33,ConfIP33);
  rprintf(szRegistryCustomKeyModeAircraftIcon,CustomKeyModeAircraftIcon);
  rprintf(szRegistryCustomKeyModeCenterScreen,CustomKeyModeCenterScreen);
  rprintf(szRegistryCustomKeyModeCenter,CustomKeyModeCenter);
  rprintf(szRegistryCustomKeyModeLeftUpCorner,CustomKeyModeLeftUpCorner);
  rprintf(szRegistryCustomKeyModeLeft,CustomKeyModeLeft);
  rprintf(szRegistryCustomKeyModeRightUpCorner,CustomKeyModeRightUpCorner);
  rprintf(szRegistryCustomKeyModeRight,CustomKeyModeRight);
  rprintf(szRegistryCustomKeyTime,CustomKeyTime);
  rprintf(szRegistryCustomMenu1,CustomMenu1);
  rprintf(szRegistryCustomMenu2,CustomMenu2);
  rprintf(szRegistryCustomMenu3,CustomMenu3);
  rprintf(szRegistryCustomMenu4,CustomMenu4);
  rprintf(szRegistryCustomMenu5,CustomMenu5);
  rprintf(szRegistryCustomMenu6,CustomMenu6);
  rprintf(szRegistryCustomMenu7,CustomMenu7);
  rprintf(szRegistryCustomMenu8,CustomMenu8);
  rprintf(szRegistryCustomMenu9,CustomMenu9);
  rprintf(szRegistryCustomMenu10,CustomMenu10);
  rprintf(szRegistryDebounceTimeout,debounceTimeout);
  rprintf(szRegistryDeclutterMode,DeclutterMode);
  ///rprintf(szRegistryDeviceA,dwDeviceName1);
  ///rprintf(szRegistryDeviceB,dwDeviceName2);
  rprintf(szRegistryDisableAutoLogger,DisableAutoLogger);
  rprintf(szRegistryDisplayText,DisplayTextType);
  rprintf(szRegistryDisplayUpValue,DisplayOrientation_Config);
  rprintf(szRegistryDistanceUnitsValue,DistanceUnit_Config );
  rprintf(szRegistryEnableFLARMMap,EnableFLARMMap);
  rprintf(szRegistryEnableNavBaroAltitude,EnableNavBaroAltitude_Config);
  rprintf(szRegistryFAIFinishHeight,EnableFAIFinishHeight);
  rprintf(szRegistryFAISector,SectorType);
  rprintf(szRegistryFinalGlideTerrain,FinalGlideTerrain);
  rprintf(szRegistryFinishLine,FinishLine);
  rprintf(szRegistryFinishMinHeight,FinishMinHeight); // saved *1000, /1000 when used
  rprintf(szRegistryFinishRadius,FinishRadius);
  rprintf(szRegistryFontRenderer,FontRenderer);

  rprintf(szRegistryFontMapWaypoint,FontMapWaypoint);
  rprintf(szRegistryFontMapTopology,FontMapTopology);
  rprintf(szRegistryFontInfopage1L,FontInfopage1L);
  rprintf(szRegistryFontInfopage2L,FontInfopage2L);
  rprintf(szRegistryFontBottomBar,FontBottomBar);
  rprintf(szRegistryFontOverlayBig,FontOverlayBig);
  rprintf(szRegistryFontOverlayMedium,FontOverlayMedium);
  rprintf(szRegistryFontCustom1,FontCustom1);
  rprintf(szRegistryFontVisualGlide,FontVisualGlide);

  rprintf(szRegistryGlideBarMode,GlideBarMode);
  rprintf(szRegistryGliderScreenPosition,MapWindow::GliderScreenPosition);
  rprintf(szRegistryGpsAltitudeOffset,GPSAltitudeOffset);
//  >> Moved to AircraftFile <<
//  rprintf(szRegistryHandicap,Handicap);
  rprintf(szRegistryHideUnits,HideUnits);
  rprintf(szRegistryHomeWaypoint,HomeWaypoint);

  // InfoType for infoboxes configuration
  for (int i=0;i<MAXINFOWINDOWS;i++) rprintf(szRegistryDisplayType[i], InfoType[i]);

  rprintf(szRegistryInputFile,szInputFile);
  rprintf(szRegistryIphoneGestures,IphoneGestures);
  rprintf(szRegistryLKMaxLabels,LKMaxLabels);
  rprintf(szRegistryLKTopoZoomCat05,LKTopoZoomCat05*1000);
  rprintf(szRegistryLKTopoZoomCat100,LKTopoZoomCat100*1000);
  rprintf(szRegistryLKTopoZoomCat10,LKTopoZoomCat10*1000);
  rprintf(szRegistryLKTopoZoomCat110,LKTopoZoomCat110*1000);
  rprintf(szRegistryLKTopoZoomCat20,LKTopoZoomCat20*1000);
  rprintf(szRegistryLKTopoZoomCat30,LKTopoZoomCat30*1000);
  rprintf(szRegistryLKTopoZoomCat40,LKTopoZoomCat40*1000);
  rprintf(szRegistryLKTopoZoomCat50,LKTopoZoomCat50*1000);
  rprintf(szRegistryLKTopoZoomCat60,LKTopoZoomCat60*1000);
  rprintf(szRegistryLKTopoZoomCat70,LKTopoZoomCat70*1000);
  rprintf(szRegistryLKTopoZoomCat80,LKTopoZoomCat80*1000);
  rprintf(szRegistryLKTopoZoomCat90,LKTopoZoomCat90*1000);
  rprintf(szRegistryLKVarioBar,LKVarioBar);
  rprintf(szRegistryLKVarioVal,LKVarioVal);
  rprintf(szRegistryLanguageFile,szLanguageFile);
  rprintf(szRegistryLatLonUnits, Units::CoordinateFormat);
  rprintf(szRegistryLiftUnitsValue,LiftUnit_Config );
  rprintf(szRegistryLockSettingsInFlight,LockSettingsInFlight);
  rprintf(szRegistryLoggerShort,LoggerShortName);
  rprintf(szRegistryLoggerTimeStepCircling,LoggerTimeStepCircling);
  rprintf(szRegistryLoggerTimeStepCruise,LoggerTimeStepCruise);
  rprintf(szRegistryMapBox,MapBox);
  rprintf(szRegistryMapFile,szMapFile);
  rprintf(szRegistryMenuTimeout,MenuTimeout_Config);
  rprintf(szRegistryNewMapDeclutter,NewMapDeclutter);
  rprintf(szRegistryOrbiter,Orbiter_Config);
  rprintf(szRegistryOutlinedTp,OutlinedTp_Config);
  rprintf(szRegistryOverColor,OverColor);
  rprintf(szRegistryOverlayClock,OverlayClock);
  rprintf(szRegistryUseTwoLines,UseTwoLines);
  rprintf(szRegistryOverlaySize,OverlaySize);
  rprintf(szRegistryPGAutoZoomThreshold,PGAutoZoomThreshold);
  rprintf(szRegistryPGClimbZoom,PGClimbZoom);
  rprintf(szRegistryPGCruiseZoom,PGCruiseZoom);
  rprintf(szRegistryPGOptimizeRoute,PGOptimizeRoute_Config);
// >> Moved to PilotFile <<
//  rprintf(szRegistryPilotName,PilotName_Config);
//  >> Moved to AircraftFile <<
//  rprintf(szRegistryPolarFile,szPolarFile);
//  rprintf(szRegistryPollingMode,PollingMode);
//  rprintf(szRegistryPort1Index,dwPortIndex1);
//  rprintf(szRegistryPort2Index,dwPortIndex2);
  rprintf(szRegistryPressureHg,PressureHg);
  rprintf(szRegistrySafetyAltitudeArrival,SAFETYALTITUDEARRIVAL);
  rprintf(szRegistrySafetyAltitudeMode,SafetyAltitudeMode);
  rprintf(szRegistrySafetyAltitudeTerrain,SAFETYALTITUDETERRAIN);
  rprintf(szRegistrySafetyMacCready,GlidePolar::SafetyMacCready*10);
//  >> Moved to AircraftFile <<
//  rprintf(szRegistrySafteySpeed,SAFTEYSPEED*1000); // m/s x1000
  rprintf(szRegistrySectorRadius,SectorRadius);
  rprintf(szRegistrySetSystemTimeFromGPS,SetSystemTimeFromGPS);
  rprintf(szRegistrySaveRuntime,SaveRuntime);
  rprintf(szRegistryShading,Shading_Config);
  rprintf(szRegistrySnailTrail,TrailActive_Config);
  rprintf(szRegistrySnailWidthScale,MapWindow::SnailWidthScale);
//  rprintf(szRegistrySpeed1Index,dwSpeedIndex1);
//  rprintf(szRegistrySpeed2Index,dwSpeedIndex2);
  rprintf(szRegistrySpeedUnitsValue,SpeedUnit_Config);
  rprintf(szRegistryStartHeightRef,StartHeightRef);
  rprintf(szRegistryStartLine,StartLine);
  rprintf(szRegistryStartMaxHeightMargin,StartMaxHeightMargin);	// saved *1000, /1000 when used
  rprintf(szRegistryStartMaxHeight,StartMaxHeight);		// saved *1000, /1000 when used
  rprintf(szRegistryStartMaxSpeedMargin,StartMaxSpeedMargin);	// saved *1000, /1000 when used
  rprintf(szRegistryStartMaxSpeed,StartMaxSpeed);		// saved *1000, /1000 when used
  rprintf(szRegistryStartRadius,StartRadius);
  rprintf(szRegistryTaskSpeedUnitsValue,TaskSpeedUnit_Config);
  rprintf(szRegistryTeamcodeRefWaypoint,TeamCodeRefWaypoint);
  rprintf(szRegistryTerrainBrightness,TerrainBrightness);
  rprintf(szRegistryTerrainContrast,TerrainContrast);
  rprintf(szRegistryTerrainFile,szTerrainFile);
  rprintf(szRegistryTerrainRamp,TerrainRamp_Config);
  rprintf(szRegistryThermalBar,ThermalBar);
  rprintf(szRegistryThermalLocator,EnableThermalLocator);
  rprintf(szRegistryTpFilter,TpFilter);
  rprintf(szRegistryTrackBar,TrackBar);
  rprintf(szRegistryTrailDrift,EnableTrailDrift_Config);
  rprintf(szRegistryUTCOffset,UTCOffset);
//  rprintf(szRegistryUseGeoidSeparation,UseGeoidSeparation);
  rprintf(szRegistryUseUngestures,UseUngestures);
  rprintf(szRegistryUseTotalEnergy,UseTotalEnergy_Config);
  rprintf(szRegistryWarningTime,WarningTime);
  rprintf(szRegistryWayPointFile,szWaypointFile);
  rprintf(szRegistryWaypointsOutOfRange,WaypointsOutOfRange);
  rprintf(szRegistryWindCalcSpeed,WindCalcSpeed*1000); // m/s x1000
  rprintf(szRegistryWindCalcTime,WindCalcTime);

  for(int i=0;i<AIRSPACECLASSCOUNT;i++) {
	rprintf(szRegistryAirspaceMode[i],MapWindow::iAirspaceMode[i]);
	rprintf(szRegistryColour[i],MapWindow::iAirspaceColour[i]);
#ifdef HAVE_HATCHED_BRUSH
	rprintf(szRegistryBrush[i],MapWindow::iAirspaceBrush[i]);
#endif
  }


  rprintf(szRegistryUseWindRose,UseWindRose);

  //
  // Multimaps added 121003
  //

 if (SaveRuntime) {
  rprintf(szRegistryMultiTerr0,Multimap_Flags_Terrain[MP_MOVING]);
  rprintf(szRegistryMultiTerr1,Multimap_Flags_Terrain[MP_MAPTRK]);
  rprintf(szRegistryMultiTerr2,Multimap_Flags_Terrain[MP_MAPWPT]);
  rprintf(szRegistryMultiTerr3,Multimap_Flags_Terrain[MP_MAPASP]);
  rprintf(szRegistryMultiTerr4,Multimap_Flags_Terrain[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiTopo0,Multimap_Flags_Topology[MP_MOVING]);
  rprintf(szRegistryMultiTopo1,Multimap_Flags_Topology[MP_MAPTRK]);
  rprintf(szRegistryMultiTopo2,Multimap_Flags_Topology[MP_MAPWPT]);
  rprintf(szRegistryMultiTopo3,Multimap_Flags_Topology[MP_MAPASP]);
  rprintf(szRegistryMultiTopo4,Multimap_Flags_Topology[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiAsp0,Multimap_Flags_Airspace[MP_MOVING]);
  rprintf(szRegistryMultiAsp1,Multimap_Flags_Airspace[MP_MAPTRK]);
  rprintf(szRegistryMultiAsp2,Multimap_Flags_Airspace[MP_MAPWPT]);
  rprintf(szRegistryMultiAsp3,Multimap_Flags_Airspace[MP_MAPASP]);
  rprintf(szRegistryMultiAsp4,Multimap_Flags_Airspace[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiLab0,Multimap_Labels[MP_MOVING]);
  rprintf(szRegistryMultiLab1,Multimap_Labels[MP_MAPTRK]);
  rprintf(szRegistryMultiLab2,Multimap_Labels[MP_MAPWPT]);
  rprintf(szRegistryMultiLab3,Multimap_Labels[MP_MAPASP]);
  rprintf(szRegistryMultiLab4,Multimap_Labels[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiWpt0,Multimap_Flags_Waypoints[MP_MOVING]);
  rprintf(szRegistryMultiWpt1,Multimap_Flags_Waypoints[MP_MAPTRK]);
  rprintf(szRegistryMultiWpt2,Multimap_Flags_Waypoints[MP_MAPWPT]);
  rprintf(szRegistryMultiWpt3,Multimap_Flags_Waypoints[MP_MAPASP]);
  rprintf(szRegistryMultiWpt4,Multimap_Flags_Waypoints[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiOvrT0,Multimap_Flags_Overlays_Text[MP_MOVING]);
  rprintf(szRegistryMultiOvrT1,Multimap_Flags_Overlays_Text[MP_MAPTRK]);
  rprintf(szRegistryMultiOvrT2,Multimap_Flags_Overlays_Text[MP_MAPWPT]);
  rprintf(szRegistryMultiOvrT3,Multimap_Flags_Overlays_Text[MP_MAPASP]);
  rprintf(szRegistryMultiOvrT4,Multimap_Flags_Overlays_Text[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiOvrG0,Multimap_Flags_Overlays_Gauges[MP_MOVING]);
  rprintf(szRegistryMultiOvrG1,Multimap_Flags_Overlays_Gauges[MP_MAPTRK]);
  rprintf(szRegistryMultiOvrG2,Multimap_Flags_Overlays_Gauges[MP_MAPWPT]);
  rprintf(szRegistryMultiOvrG3,Multimap_Flags_Overlays_Gauges[MP_MAPASP]);
  rprintf(szRegistryMultiOvrG4,Multimap_Flags_Overlays_Gauges[MP_VISUALGLIDE]);

  rprintf(szRegistryMultiSizeY1,Multimap_SizeY[MP_MAPTRK]);
  rprintf(szRegistryMultiSizeY2,Multimap_SizeY[MP_MAPWPT]);
  rprintf(szRegistryMultiSizeY3,Multimap_SizeY[MP_MAPASP]);
  rprintf(szRegistryMultiSizeY4,Multimap_SizeY[MP_VISUALGLIDE]);
 }

  rprintf(szRegistryMultimap1,Multimap1);
  rprintf(szRegistryMultimap2,Multimap2);
  rprintf(szRegistryMultimap3,Multimap3);
  rprintf(szRegistryMultimap4,Multimap4);

 if (SaveRuntime) {
  rprintf(szRegistryMMNorthUp1,MMNorthUp_Runtime[0]);
  rprintf(szRegistryMMNorthUp2,MMNorthUp_Runtime[1]);
  rprintf(szRegistryMMNorthUp3,MMNorthUp_Runtime[2]);
  rprintf(szRegistryMMNorthUp4,MMNorthUp_Runtime[3]);
 }

  rprintf(szRegistryAspPermanent  ,AspPermanentChanged);
  rprintf(szRegistryFlarmDirection,iFlarmDirection);
 if (SaveRuntime) {
  rprintf(szRegistryDrawTask      ,Flags_DrawTask);
  rprintf(szRegistryDrawFAI       ,Flags_DrawFAI);
 }
  rprintf(szRegistryGearMode      ,GearWarningMode);
  rprintf(szRegistryGearAltitude  ,GearWarningAltitude);
  rprintf(szRegistryBigFAIThreshold,FAI28_45Threshold);
  if (SaveRuntime) rprintf(szRegistryBottomMode    ,BottomMode);
  rprintf(szRegistrySonarWarning    ,SonarWarning_Config);

  rprintf(szRegistryOverlay_TopLeft, Overlay_TopLeft);
  rprintf(szRegistryOverlay_TopMid, Overlay_TopMid);
  rprintf(szRegistryOverlay_TopRight, Overlay_TopRight);
  rprintf(szRegistryOverlay_TopDown, Overlay_TopDown);
  rprintf(szRegistryOverlay_LeftTop, Overlay_LeftTop);
  rprintf(szRegistryOverlay_LeftMid, Overlay_LeftMid);
  rprintf(szRegistryOverlay_LeftBottom, Overlay_LeftBottom);
  rprintf(szRegistryOverlay_LeftDown, Overlay_LeftDown);
  rprintf(szRegistryOverlay_RightTop, Overlay_RightTop);
  rprintf(szRegistryOverlay_RightMid, Overlay_RightMid);
  rprintf(szRegistryOverlay_RightBottom, Overlay_RightBottom);


  #if SAVESCREEN
  extern bool CommandResolution;
  if(!IsEmbedded() && !CommandResolution) {
    rprintf(szRegistryScreenSize   ,ScreenSize);
    rprintf(szRegistryScreenSizeX  ,ScreenSizeX);
    rprintf(szRegistryScreenSizeY  ,ScreenSizeY);
  }
  #endif

  fprintf(pfp,PNEWLINE); // end of file
  fflush(pfp);
  fclose(pfp);

}
Esempio n. 7
0
void _currentDump(const CURRENT* device){
	rprintf("(%u amps)", device->amps);
}
Esempio n. 8
0
File: main.c Progetto: OPSF/uClinux
static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
{
	int status;
	struct file_list *flist;
	char *local_name = NULL;
	char *dir = NULL;
	int save_verbose = verbose;

	if (filesfrom_fd >= 0) {
		/* We can't mix messages with files-from data on the socket,
		 * so temporarily turn off verbose messages. */
		verbose = 0;
	}

	if (verbose > 2) {
		rprintf(FINFO, "server_recv(%d) starting pid=%ld\n",
			argc, (long)getpid());
	}

	if (am_daemon && lp_read_only(module_id)) {
		rprintf(FERROR,"ERROR: module is read only\n");
		exit_cleanup(RERR_SYNTAX);
		return;
	}


	if (argc > 0) {
		dir = argv[0];
		argc--;
		argv++;
		if (!am_daemon && !push_dir(dir)) {
			rsyserr(FERROR, errno, "push_dir#4 %s failed",
				full_fname(dir));
			exit_cleanup(RERR_FILESELECT);
		}
	}

	io_start_buffering_in();
	recv_filter_list(f_in);

	if (filesfrom_fd >= 0) {
		/* We need to send the files-from names to the sender at the
		 * same time that we receive the file-list from them, so we
		 * need the IO routines to automatically write out the names
		 * onto our f_out socket as we read the file-list.  This
		 * avoids both deadlock and extra delays/buffers. */
		io_set_filesfrom_fds(filesfrom_fd, f_out);
		filesfrom_fd = -1;
	}

	flist = recv_file_list(f_in);
	verbose = save_verbose;
	if (!flist) {
		rprintf(FERROR,"server_recv: recv_file_list error\n");
		exit_cleanup(RERR_FILESELECT);
	}
	the_file_list = flist;

	if (argc > 0) {
		if (strcmp(dir,".")) {
			argv[0] += strlen(dir);
			if (argv[0][0] == '/')
				argv[0]++;
		}
		local_name = get_local_name(flist,argv[0]);
	}

	status = do_recv(f_in,f_out,flist,local_name);
	exit_cleanup(status);
}
Esempio n. 9
0
/* Use the ATA IDENTIFY command to find out what kind of drive is
* attached to the given bus/slot.  */
uint32
ata_identify (uint32 bus, uint32 drive)
 {
   uint8 status;
   uint16 buffer[256];

   
   ata_drive_select (bus, drive);

   // while(!(status=inb(ATA_COMMAND(bus)) & 0x60)){
   //  rprintf("loop0");
   // }

   outb (ATA_COMMAND (bus),0xEC);       /* Send IDENTIFY command */
   
   ATA_SELECT_DELAY (bus);
 
   status = inb (ATA_COMMAND (bus));
   if (status == 0) {
     // rprintf ("ATA bus %X drive %X does not exist\n", bus, drive);
     return NOTCD;
   }
 
   if (status & 0x1) {
     /* Drive does not support IDENTIFY.  Probably a CD-ROM. */
     goto guess_identity;
   }
 
   /* Poll the Status port (0x1F7) until bit 7 (BSY, value = 0x80)
    * clears, and bit 3 (DRQ, value = 8) sets -- or until bit 0 (ERR,
    * value = 1) sets. */
 
   while ((status = inb (ATA_COMMAND (bus))) & 0x80){
     asm volatile ("pause");
     // printf("%s\n","busy");
   }     /* BUSY */

  while (!((status = inb (ATA_COMMAND (bus))) & 0x8) && !(status & 0x01)){
     // printf("%x",status);
     asm volatile ("pause");
  }

  if (status & 0x1) {
    // rprintf ("ATA bus %X drive %X caused error.\n", bus, drive);
    goto guess_identity;
  }
 
   /* Read 256 words */
   insw (ATA_DATA (bus), buffer, 256);
 
 #ifdef DEBUG_ATA
   {
     int i, j;
 
     // DLOG ("IDENTIFY (bus: %X drive: %X) command output:", bus, drive);
     /* dump to com1 */
     for (i = 0; i < 32; i++) {
       for (j = 0; j < 8; j++) {
        rprintf ("%.4X ", buffer[i * 32 + j]);
       }
       rprintf ("\n");
     }
   }
 #endif
 
   if (buffer[83] & (1 << 10))
   // rprintf ("LBA48 mode supported.\n");
   // rprintf ("LBA48 addressable sectors: %.4X %.4X %.4X %.4X\n",
   //                buffer[100], buffer[101], buffer[102], buffer[103]);
   rprintf("not a cd");   
   return NOTCD;

  guess_identity:{
     uint8 b1, b2;
 
     b1 = inb (ATA_ADDRESS2 (bus));
     b2 = inb (ATA_ADDRESS3 (bus));
      
     // rprintf ("ata_detect: %.2X %.2X\n", b1, b2);
 
     if (b1 == 0x14 && b2 == 0xEB) {
       rprintf("is a CD");
       // rprintf("P-ATAPI detected\n");
       return ISCD;
     }

     //TODO: probar eliminar estos
     if (b1 == 0x69 && b2 == 0x96) {
      rprintf("is a CD");
       // rprintf ("S-ATAPI detected\n");
       return ISCD;
     }
     if (b1 == 0x3C && b2 == 0xC3) {
       rprintf("is a CD");
       // rprintf ("SATA detected\n");
       return ISCD;
     }
     rprintf("NOT a CD");
     return NOTCD;
   }
}
Esempio n. 10
0
  int atapi_drive_startstop(uint32 drive,uint32 bus){
    printf("\n%s\n","entre");
   //Operation code and bit 1 of byte 4 -LoEj(eject)- as 1.
   uint8 startstop_cmd[12]={0x1B,0,0,0,2,0,0,0,0,0,0,0}; 
   uint8 allowremoval_cmd[12]={0x1E,0,0,0,0,0,0,0,0,0,0,0};
   uint8 status;
 

   // while((status=inb(ATA_COMMAND(bus))) & 0x80){
   //  rprintf("while1-busy");
   //  //BUSY
   //  // If the first bit of the status register (BUSY) isn't 0, the device is busy,
   //  // so keep looping until it isn't.
   // }

    // // _Cli();
   // while(!((status=inb(ATA_COMMAND(bus))) & 0x60)){
   //  rprintf("%x%s",status,"2");
   //  //NOT READY
   // }
   // /* DRQ or ERROR */
   // if(status & 0x1){
   //    return -1;
   // }

   ata_drive_select (bus, drive);
   //TODO reemplazar por drive
   // outb(ATA_DRIVE_SELECT(bus),0x10); //0 master, 10h slave

   outb(ATA_FEATURES(bus),0);

   /* Set Nien on device control register to 1 to skip waiting state. 
   nIEN is the second bit from the right here */
   // outb(ATA_DCR(bus),0x10); 

  /* Send the ATAPI PACKAGE command to the command register */
   outb(ATA_COMMAND(bus),0xA0);   
   //wait 400ns
   ATA_SELECT_DELAY(bus);
   while(status=inb(ATA_COMMAND(bus)) & 0x80){
   rprintf("while1");
    }
   while(!(status=inb(ATA_COMMAND(bus)) & 0x8)){
    rprintf("while2");
    //DATA TRANSFER REQUESTED
   }
   

  /* Send ATAPI/SCSI command as 6 words, to the data port */
   // outsw(ATA_DATA(bus), (uint16 *)allowremoval_cmd,6);
  outb(ATA_DATA(bus),0x1E);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),0);

   // inb(ATA_DCR(bus));
   while(status=inb(ATA_COMMAND(bus)) & 0x80){
   rprintf("while1-allow removal");
   //BUSY
   }
   while(!(status=inb(ATA_COMMAND(bus)) & 0x8)){
    rprintf("while2-allow removal");
    //DATA TRANSFER REQUESTED
   }

    outb(ATA_COMMAND(bus),0xA0);   
   //wait 400ns
   // ATA_SELECT_DELAY(bus);
   while(status=inb(ATA_COMMAND(bus)) & 0x80){
     rprintf("while1-2");
    }
   while(!(status=inb(ATA_COMMAND(bus)) & 0x8)){
    rprintf("while2-2");
    //DATA TRANSFER REQUESTED
   }


  /* Send ATAPI/SCSI command as 6 words, to the data port */
   // outsw(ATA_DATA(bus), (uint16 *)startstop_cmd,6);
  outb(ATA_DATA(bus),0x1B);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),2);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),0);
  outb(ATA_DATA(bus),0);  

  //wait 400ns
   // ATA_SELECT_DELAY(bus);
   // inb(ATA_DCR(bus));
   while(status=inb(ATA_COMMAND(bus)) & 0x80){
     rprintf("while 1 -BUSY- startstop_cmd");
   //BUSY
   }

   // _Sti();

   return 1;
 }
Esempio n. 11
0
int printCrashInfo ()
{
  abortDat_t *ad = (abortDat_t *) &__abort_dat;

  rprintf ("\nReport Valid? :%s, sigil=0x%08X, count=%u\n", (ad->sigil == 0xdeadc0de) ? "LIKELY" : "INVALID", ad->sigil, ad->count);
  rprintf ("Abort type: %s\n", (ad->type == 0) ? "UNDEFINED INSTRUCTION" : (ad->type == 1) ? "PREFETCH ABORT" : (ad->type == 2) ? "DATA ABORT" : "unknown");
  rprintf ("** PC=0x%08X, opcode=0x%08X **\n", ad->pc, ad->opcode);
  rprintf ("** Locate value of PC in your *.lst file to find the root cause. **\n\n");

  // wait until previous output is done.  Otherwise system will keep resetting.
  rprintf ("cpsr=0x%08X, sp=0x%08X, lr=0x%08X\n", ad->cpsr, ad->sp, ad->lr);
  rprintf ("r0=0x%08X, r1=0x%08X,  r2=0x%08X,  r3=0x%08X\n", ad->r0, ad->r1, ad->r2, ad->r3);
  rprintf ("r4=0x%08X, r5=0x%08X,  r6=0x%08X,  r7=0x%08X\n", ad->r4, ad->r5, ad->r6, ad->r7);
  rprintf ("r8=0x%08X, r9=0x%08X, r10=0x%08X, r11=0x%08X\n", ad->r8, ad->r9, ad->r10, ad->r11);
  rprintf ("r12=0x%08X\n\n", ad->r12);

  rprintf ("sp[0]=0x%08X, sp[1]=0x%08X, sp[2]=0x%08X, sp[3]=0x%08X\n", ad->stack [0], ad->stack [1], ad->stack [2], ad->stack [3]);
  rprintf ("sp[4]=0x%08X, sp[5]=0x%08X, sp[6]=0x%08X, sp[7]=0x%08X\n\n", ad->stack [4], ad->stack [5], ad->stack [6], ad->stack [7]);

  return 0;
}
Esempio n. 12
0
void rprintfTest(void)
{
	u16 val;
	u08 mydata;
	u08 mystring[10];
	float b;
	u08 small;
	u16 medium;
	u32 big;

	// print a little intro message so we know things are working
	rprintf("\r\nThis is my cool program!\r\n");

	
	rprintf("\r\nWelcome to rprintf Test!\r\n");

	// print single characters
	rprintfChar('H');
	rprintfChar('e');
	rprintfChar('l');
	rprintfChar('l');
	rprintfChar('o');
	// print a constant string stored in FLASH
	rprintfProgStrM(" World!");
	// print a carriage return, line feed combination
	rprintfCRLF();
	// note that using rprintfCRLF() is more memory-efficient than
	// using rprintf("\r\n"), especially if you do it repeatedly

	mystring[0] = 'A';
	mystring[1] = ' ';
	mystring[2] = 'S';
	mystring[3] = 't';
	mystring[4] = 'r';
	mystring[5] = 'i';
	mystring[6] = 'n';
	mystring[7] = 'g';
	mystring[8] = '!';
	mystring[9] = 0;	// null termination

	// print a null-terminated string from RAM
	rprintfStr(mystring);
	rprintfCRLF();

	// print a section of a string from RAM
	// - start at index 2
	// - print 6 characters
	rprintfStrLen(mystring, 2, 6);
	rprintfCRLF();


	val = 24060;
	mydata = 'L';

	// print a decimal number
	rprintf("This is a decimal number: %d\r\n", val);

	// print a hex number
	rprintf("This is a hex number: %x\r\n", mydata);
	
	// print a character
	rprintf("This is a character: %c\r\n", mydata);

	// print hex numbers
	small = 0x12;		// a char
	medium = 0x1234;	// a short
	big = 0x12345678;	// a long

	rprintf("This is a 2-digit hex number (char) : ");
	rprintfu08(small);
	rprintfCRLF();

	rprintf("This is a 4-digit hex number (short): ");
	rprintfu16(medium);
	rprintfCRLF();

	rprintf("This is a 8-digit hex number (long) : ");
	rprintfu32(big);
	rprintfCRLF();

	// print a formatted decimal number
	// - use base 10
	// - use 8 characters
	// - the number is signed [TRUE]
	// - pad with '.' periods
	rprintf("This is a formatted decimal number: ");
	rprintfNum(10, 8, TRUE, '.', val);
	rprintfCRLF();

	b = 1.23456;

	// print a floating point number
	// use 10-digit precision
	
	// NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h
	// use the following in your global.h: #define RPRINTF_FLOAT

	//rprintf("This is a floating point number: ");
	//rprintfFloat(8, b);
	//rprintfCRLF();
}
Esempio n. 13
0
void ax88796RegDump(void)
{
	unsigned char result;
	result = ax88796Read(TR);
	
	rprintf("Media State: ");
	if(!(result & AUTOD))
   		rprintf("Autonegotiation\r\n");
	else if(result & RST_B)
   		rprintf("PHY in Reset   \r\n");
	else if(!(result & RST_10B))
		rprintf("10BASE-T       \r\n");
	else if(!(result & RST_TXB))
		rprintf("100BASE-T      \r\n");
				
	//rprintf("TR regsiter      : %x\r\n",result);
	//result = read_mii(0x10,0);
	//rprintf("MII regsiter 0x10: %x\r\n",result);

	rprintfProgStrM("Page0: CR  BNRY PSR PST ISR TSR RSR MMR TR  GPI\r\n");
	rprintfProgStrM("       ");
	rprintfuint8_t(ax88796Read(CR));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(BNRY));
	rprintfProgStrM("   ");
	rprintfuint8_t(ax88796Read(PSTART));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(PSTOP));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(ISR));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(TSR));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(RSR));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(MEMR));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(TR));
	rprintfProgStrM("  ");
	rprintfuint8_t(ax88796Read(GPI));
	rprintfCRLF();

	ax88796Write(CR,ax88796Read(CR)|PS0);

	rprintf("Page1: CR  PAR    CPR\r\n");
	rprintfProgStrM("       ");
	rprintfuint8_t(ax88796Read(CR));
	rprintfProgStrM("  ");
	rprintfChar(ax88796Read(PAR0));
	rprintfChar(ax88796Read(PAR1));
	rprintfChar(ax88796Read(PAR2));
	rprintfChar(ax88796Read(PAR3));
	rprintfChar(ax88796Read(PAR4));
	rprintfChar(ax88796Read(PAR5));
	rprintfProgStrM(" ");
	rprintfuint8_t(ax88796Read(CPR));
	
	ax88796Write(CR,ax88796Read(CR)&~PS0);

	delay_ms(25);
}
Esempio n. 14
0
File: main.c Progetto: OPSF/uClinux
static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
{
	int i;
	struct file_list *flist;
	char *dir = argv[0];

	if (verbose > 2) {
		rprintf(FINFO, "server_sender starting pid=%ld\n",
			(long)getpid());
	}

	if (am_daemon && lp_write_only(module_id)) {
		rprintf(FERROR, "ERROR: module is write only\n");
		exit_cleanup(RERR_SYNTAX);
		return;
	}
	if (am_daemon && lp_read_only(module_id) && remove_sent_files) {
		rprintf(FERROR,
		    "ERROR: --remove-sent-files cannot be used with a read-only module\n");
		exit_cleanup(RERR_SYNTAX);
		return;
	}

	if (!relative_paths && !push_dir(dir)) {
		rsyserr(FERROR, errno, "push_dir#3 %s failed",
			full_fname(dir));
		exit_cleanup(RERR_FILESELECT);
	}
	argc--;
	argv++;

	if (strcmp(dir,".")) {
		int l = strlen(dir);
		if (strcmp(dir,"/") == 0)
			l = 0;
		for (i = 0; i < argc; i++)
			argv[i] += l+1;
	}

	if (argc == 0 && (recurse || list_only)) {
		argc = 1;
		argv--;
		argv[0] = ".";
	}

	flist = send_file_list(f_out,argc,argv);
	if (!flist || flist->count == 0) {
		exit_cleanup(0);
	}
	the_file_list = flist;

	io_start_buffering_in();
	io_start_buffering_out();

	send_files(flist,f_out,f_in);
	io_flush(FULL_FLUSH);
	handle_stats(f_out);
	if (protocol_version >= 24)
		read_final_goodbye(f_in, f_out);
	io_flush(FULL_FLUSH);
	exit_cleanup(0);
}
Esempio n. 15
0
int main(void)
{
    avr_init();
u08 even;

//    u16 i;
//u08 temp;
	command = 45;
//	actualTemp = 85;

//	u16 temp;
    for(;;)
    {
        // Tasks here.
        // Command line reception of commands...
		// pass characters received on the uart (serial port)
		// into the cmdline processor
//        while(uartReceiveByte(&c)){
//        vt100SetCursorPos(1, 0);
//        uartSendByte(c);
//        cmdlineInputFunc(c);
//
//        }
        // bounce the character, keep to the top 3 rows...

		// run the cmdline execution functions
       	vt100SetCursorPos(3, 0);
		cmdlineMainLoop();
        // Command line reception ends here



    	if (APP_STATUS_REG & BV(DO_SAMPLE))
    	{
    		readMAX6675(&tempData);		// get data to tempData variable
    		CLEAR_SAMPLE_FLAG;
    	//debug, invert pin
    	PIND ^= BV(PD5);
    
    	//update PID
    //	output = pid_Controller(command, tempData, &PID_data);
    
    	//invert PID
    //	output = PHASE_ANGLE_LIMIT_HIGH - output;
    	}


    	if(APP_STATUS_REG & BV(DO_PID))
    	{
    		#ifdef REG_PID	
    		//update PID
    		output = pid_Controller(command, tempData, &PID_data);
#ifndef CMDLINE
    #ifndef RX_DBG
    		rprintf("PID raw: ");
    		rprintfNum(10, 6,  TRUE, ' ',   output);		rprintfCRLF();
    #endif
    		//invert & limit PID
            if(output > 29700) output = 700;
            //output = PHASE_ANGLE_LIMIT_HIGH - output;
    #ifndef RX_DBG
    		rprintf("PID scaled: ");
    		rprintfNum(10, 6,  TRUE, ' ',   output);		rprintfCRLF();
    #endif
#endif
    		#endif
    
    		#ifdef REG_PD
    
    		#endif
    //		actualTemp +=10;
    //		OCR0A = output;
    		CLEAR_PID_FLAG;
    
//    	}
/*
		if((temp = 0xFFFF-output) > 30000)
		{	temp = 30000;}
		else if (temp < 1000)
		{	temp = 1000;}
*/

    // Limit to within 1 half-phase:
    	if((output > PHASE_ANGLE_LIMIT_HIGH) || (output < 0)){
#ifndef CMDLINE
#ifndef RX_DBG
    		rprintf("Max out");rprintfCRLF();
#endif
#endif
    		output = PHASE_ANGLE_LIMIT_HIGH;	// don't fire the triac at all!
    		SET_HOLD_FIRE;						// set flag to not fire triac
    	}
    	else
    	{		
    		CLEAR_HOLD_FIRE;						// set flag to fire triac
    	}
    	
    	if ((output < PHASE_ANGLE_LIMIT_LOW)){  // || (output < 0))
#ifndef CMDLINE
#ifndef RX_DBG
    		rprintf("Min out");rprintfCRLF();
#endif
#endif
    		output = PHASE_ANGLE_LIMIT_LOW;		// fire the triac at zerocrozz to get complete halfwave
    
    	}
#ifndef WALK_PHASEANGLE
		OCR1A = output;
#endif
		//OCR1A = PHASE_ANGLE_LIMIT_LOW;
		//OCR1A = PHASE_ANGLE_LIMIT_HIGH;
	}



#ifdef DEBUG_SER
//	uartPrintfNum(10, 6,  TRUE, ' ',   1234);  -->  " +1234"
//	uartPrintfNum(16, 6, FALSE, '.', 0x5AA5);  -->  "..5AA5"

//	rprintfNum(10, 4,  FALSE, ' ',   tempData);//		rprintfCRLF();
#ifndef CMDLINE
#ifndef RX_DBG

            if(sensorDisconnected)
        	{
        		rprintfProgStrM("Disconnected Probe!\r\n");
        	}
        	else
        	{

            rprintf("Process Value: ");
    		rprintfNum(10, 4,  FALSE, ' ',   tempData);		rprintfCRLF();
    
    		rprintf("Target Value: ");
    		rprintfNum(10, 4,  FALSE, ' ',   command);		rprintfCRLF();
    
    //  	rprintf("PID Phaselimit: ");
    //  	rprintfNum(10, 6,  TRUE, ' ',   output);		rprintfCRLF();
    
    		rprintf("OCR1A: ");
    		rprintfNum(10, 6,  FALSE, ' ',   OCR1A);	rprintfCRLF();
    
            //-----------
    //		rprintf("dummy: ");
    //		rprintfNum(10, 6,  TRUE, ' ',   _DUMMY);		rprintfCRLF();
    
    		rprintf("E ");
    		rprintfNum(10, 4,  TRUE, ' ',   _ERROR);		rprintfCRLF();
    
    		rprintf("P ");
    		rprintfNum(10, 8,  TRUE, ' ',   _PTERM);		rprintfCRLF();
    
    		rprintf("I ");
    		rprintfNum(10, 8,  TRUE, ' ',   _ITERM);		rprintfCRLF();
    
    		rprintf("D ");
    		rprintfNum(10, 8,  TRUE, ' ',   _DTERM);		rprintfCRLF();
    //-----------
    
            }
    
        	vt100SetCursorPos(3, 0);
        	if(even++ == 10){
        		vt100ClearScreen();
                vt100SetCursorPos(3,0);
        		even = 0;
        	}
#endif //#ifndef RX_DBG
#endif //#ifndef CMDLINE
#endif //#ifdef DEBUG_SER
    }
    
    return(0);
}
Esempio n. 16
0
File: main.c Progetto: OPSF/uClinux
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
{
	int pid;
	int status = 0;
	int error_pipe[2];

	/* The receiving side mustn't obey this, or an existing symlink that
	 * points to an identical file won't be replaced by the referent. */
	copy_links = 0;

	if (preserve_hard_links)
		init_hard_links();

	if (fd_pair(error_pipe) < 0) {
		rsyserr(FERROR, errno, "pipe failed in do_recv");
		exit_cleanup(RERR_IPC);
	}

	io_flush(NORMAL_FLUSH);

	if ((pid = do_fork()) == -1) {
		rsyserr(FERROR, errno, "fork failed in do_recv");
		exit_cleanup(RERR_IPC);
	}

	if (pid == 0) {
		close(error_pipe[0]);
		if (f_in != f_out)
			close(f_out);

		/* we can't let two processes write to the socket at one time */
		close_multiplexing_out();

		/* set place to send errors */
		set_msg_fd_out(error_pipe[1]);

		recv_files(f_in, flist, local_name);
		io_flush(FULL_FLUSH);
		handle_stats(f_in);

		send_msg(MSG_DONE, "", 0);
		io_flush(FULL_FLUSH);

		/* Handle any keep-alive packets from the post-processing work
		 * that the generator does. */
		if (protocol_version >= 29) {
			kluge_around_eof = -1;

			/* This should only get stopped via a USR2 signal. */
			while (read_int(f_in) == flist->count
			    && read_shortint(f_in) == ITEM_IS_NEW) {}

			rprintf(FERROR, "Invalid packet at end of run [%s]\n",
				who_am_i());
			exit_cleanup(RERR_PROTOCOL);
		}

		/* Finally, we go to sleep until our parent kills us with a
		 * USR2 signal.  We sleep for a short time, as on some OSes
		 * a signal won't interrupt a sleep! */
		while (1)
			msleep(20);
	}

	am_generator = 1;
	close_multiplexing_in();
	if (write_batch && !am_server)
		stop_write_batch();

	close(error_pipe[1]);
	if (f_in != f_out)
		close(f_in);

	io_start_buffering_out();

	set_msg_fd_in(error_pipe[0]);

	generate_files(f_out, flist, local_name);

	handle_stats(-1);
	io_flush(FULL_FLUSH);
	if (protocol_version >= 24) {
		/* send a final goodbye message */
		write_int(f_out, -1);
	}
	io_flush(FULL_FLUSH);

	set_msg_fd_in(-1);
	kill(pid, SIGUSR2);
	wait_process(pid, &status);
	return status;
}
Esempio n. 17
0
static void avr_init(void)
// Initializes AVR controller
{
	MAX6675S_DDR |= BV(MAX6675_CSPIN);		// setup direction for CS pin
	DISABLE_6675;							// Set CS = high for MAX6675	
	initZerocross();						// init ext Int0
	initTriac();							// init Triac pin & direction


#ifdef REG_PID
//	initPID(&PID_data, 1, 0, 10, 10, -10);

//void pid_Init(int16_t p_factor, int16_t i_factor, int16_t d_factor, struct PID_DATA *pid);
	pid_Init(P_FACTOR, I_FACTOR, D_FACTOR, &PID_data);
#endif

#ifdef REG_PD
	initPD(&PD_data, 800, 1000);
#endif


	//attach functions to timer interrupts
	timerAttach(TIMER0OVERFLOW_INT, sample);
	timerAttach(TIMER2OUTCOMPAREA_INT, stopTriac);
	timerAttach(TIMER1OUTCOMPAREA_INT, fireTriac);

	//enable output compare for timers
	sbi(TIMSK0, TOIE0);
	sbi(TIMSK1, OCIE1A);
	sbi(TIMSK2, OCIE2A);

	//set OCR values. 
//	OCR0A = PHASE_ANGLE_LIMIT_HIGH;				//firing angle of triac
	OCR2A = 1;									//length of firing pulse
	OCR1A = PHASE_ANGLE_LIMIT_HIGH;				//temperature sample frequency

	timer0SetPrescaler(TIMER_CLK_DIV1024);		//start temp. sampling

/*************************************** 
  * Timer0 runs at 24Mhz/1024 = 
  *
  * 
  *
  ***************************************/

#ifndef DEBUG_SIM
	#ifdef DEBUG_SER
	// initialize the UART (serial port)
	uartInit();

	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(57600);

	// make all rprintf statements use uart for output
	rprintfInit(uartSendByte);

	// print a little intro message so we know things are working
	rprintf("Reflow!\r\n");

//	vt100SetCursorMode(1);
//	vt100SetAttr(VT100_BLINK_OFF);
//	vt100SetAttr(VT100_USCORE_OFF);
//	vt100SetAttr(VT100_REVERSE);

	//vt100ClearScreen();
	// start command line
//	goCmdline();
 
	#endif

	// initialize SPI interface
	spiInit();
#endif

//	SET_HALF_PHASE;
//	SET_SKIP_PHASE;
//	skips = 15;
	//enable interrupts
	sei();


    return;
}
Esempio n. 18
0
File: main.c Progetto: OPSF/uClinux
/*
 * This is called once the connection has been negotiated.  It is used
 * for rsyncd, remote-shell, and local connections.
 */
int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
{
	struct file_list *flist = NULL;
	int status = 0, status2 = 0;
	char *local_name = NULL;

	cleanup_child_pid = pid;
	if (!read_batch) {
		set_nonblocking(f_in);
		set_nonblocking(f_out);
	}

	io_set_sock_fds(f_in, f_out);
	setup_protocol(f_out,f_in);

	if (protocol_version >= 23 && !read_batch)
		io_start_multiplex_in();

	/* We set our stderr file handle to blocking because ssh might have
	 * set it to non-blocking.  This can be particularly troublesome if
	 * stderr is a clone of stdout, because ssh would have set our stdout
	 * to non-blocking at the same time (which can easily cause us to lose
	 * output from our print statements).  This kluge shouldn't cause ssh
	 * any problems for how we use it.  Note also that we delayed setting
	 * this until after the above protocol setup so that we know for sure
	 * that ssh is done twiddling its file descriptors.  */
	set_blocking(STDERR_FILENO);

	if (am_sender) {
		keep_dirlinks = 0; /* Must be disabled on the sender. */
		io_start_buffering_out();
		if (!filesfrom_host)
			set_msg_fd_in(f_in);
		send_filter_list(f_out);
		if (filesfrom_host)
			filesfrom_fd = f_in;

		if (write_batch && !am_server)
			start_write_batch(f_out);
		flist = send_file_list(f_out, argc, argv);
		set_msg_fd_in(-1);
		if (verbose > 3)
			rprintf(FINFO,"file list sent\n");
		the_file_list = flist;

		io_flush(NORMAL_FLUSH);
		send_files(flist,f_out,f_in);
		io_flush(FULL_FLUSH);
		handle_stats(-1);
		if (protocol_version >= 24)
			read_final_goodbye(f_in, f_out);
		if (pid != -1) {
			if (verbose > 3)
				rprintf(FINFO,"client_run waiting on %d\n", (int) pid);
			io_flush(FULL_FLUSH);
			wait_process(pid, &status);
		}
		output_summary();
		io_flush(FULL_FLUSH);
		exit_cleanup(status);
	}

	if (need_messages_from_generator && !read_batch)
		io_start_multiplex_out();

	if (argc == 0)
		list_only |= 1;

	send_filter_list(read_batch ? -1 : f_out);

	if (filesfrom_fd >= 0) {
		io_set_filesfrom_fds(filesfrom_fd, f_out);
		filesfrom_fd = -1;
	}

	if (write_batch && !am_server)
		start_write_batch(f_in);
	flist = recv_file_list(f_in);
	the_file_list = flist;

	if (flist && flist->count > 0) {
		local_name = get_local_name(flist, argv[0]);

		status2 = do_recv(f_in, f_out, flist, local_name);
	} else {
		handle_stats(-1);
		output_summary();
	}

	if (pid != -1) {
		if (verbose > 3)
			rprintf(FINFO,"client_run2 waiting on %d\n", (int) pid);
		io_flush(FULL_FLUSH);
		wait_process(pid, &status);
	}

	return MAX(status, status2);
}
Esempio n. 19
0
/**
 * Eventually calls exit(), passing @p code, therefore does not return.
 *
 * @param code one of the RERR_* codes from errcode.h.
 **/
void _exit_cleanup(int code, const char *file, int line)
{
	int ocode = code;
	static int inside_cleanup = 0;

	if (inside_cleanup > 10) {
		/* prevent the occasional infinite recursion */
		return;
	}
	inside_cleanup++;

	signal(SIGUSR1, SIG_IGN);
	signal(SIGUSR2, SIG_IGN);

	if (verbose > 3) {
		rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
			code, safe_fname(file), line);
	}

	if (cleanup_child_pid != -1) {
		int status;
		if (waitpid(cleanup_child_pid, &status, WNOHANG) == cleanup_child_pid) {
			status = WEXITSTATUS(status);
			if (status > code)
				code = status;
		}
	}

	if (cleanup_got_literal && cleanup_fname && keep_partial
	    && handle_partial_dir(cleanup_new_fname, PDIR_CREATE)) {
		char *fname = cleanup_fname;
		cleanup_fname = NULL;
		if (cleanup_fd_r != -1)
			close(cleanup_fd_r);
		if (cleanup_fd_w != -1) {
			flush_write_file(cleanup_fd_w);
			close(cleanup_fd_w);
		}
		finish_transfer(cleanup_new_fname, fname, cleanup_file, 0,
				!partial_dir);
	}
	io_flush(FULL_FLUSH);
	if (cleanup_fname)
		do_unlink(cleanup_fname);
	if (code)
		kill_all(SIGUSR1);
	if (cleanup_pid && cleanup_pid == getpid()) {
		char *pidf = lp_pid_file();
		if (pidf && *pidf)
			unlink(lp_pid_file());
	}

	if (code == 0) {
		if (io_error & IOERR_DEL_LIMIT)
			code = RERR_DEL_LIMIT;
		if (io_error & IOERR_VANISHED)
			code = RERR_VANISHED;
		if (io_error & IOERR_GENERAL || log_got_error)
			code = RERR_PARTIAL;
	}

	if (code)
		log_exit(code, file, line);

	if (verbose > 2) {
		rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): about to call exit(%d)\n",
			ocode, safe_fname(file), line, code);
	}

	close_all();
	exit(code);
}
Esempio n. 20
0
void netstackTCPIPProcess(unsigned int len, tcpip_hdr* packet)
{
	rprintf("Received TCP/IP Packet: len=%d\r\n", len);
}
Esempio n. 21
0
/*************************************************************************
* This function is the entry point of the initial balancing algorithm.
* This algorithm assembles the graph to all the processors and preceeds
* with the balancing step.
**************************************************************************/
void Balance_Partition(ctrl_t *ctrl, graph_t *graph)
{
  idx_t i, j, nvtxs, nedges, ncon;
  idx_t mype, npes, srnpes, srmype; 
  idx_t *vtxdist, *xadj, *adjncy, *adjwgt, *vwgt, *vsize;
  idx_t *part, *lwhere, *home;
  idx_t lnparts, fpart, fpe, lnpes, ngroups;
  idx_t *rcounts, *rdispls;
  idx_t twoparts=2, moptions[METIS_NOPTIONS], edgecut, max_cut;
  idx_t sr_pe, gd_pe, sr, gd, who_wins;
  real_t my_cut, my_totalv, my_cost = -1.0, my_balance = -1.0, wsum;
  real_t rating, max_rating, your_cost = -1.0, your_balance = -1.0;
  real_t lbsum, min_lbsum, *lbvec, *tpwgts, *tpwgts2, buffer[2];
  graph_t *agraph, cgraph;
  ctrl_t *myctrl;
  MPI_Status status;
  MPI_Comm ipcomm, srcomm;
  struct {
    double cost;
    int rank;
  } lpecost, gpecost;

  IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->InitPartTmr));
  WCOREPUSH;

  vtxdist = graph->vtxdist;
  agraph  = AssembleAdaptiveGraph(ctrl, graph);
  nvtxs   = cgraph.nvtxs  = agraph->nvtxs;
  nedges  = cgraph.nedges = agraph->nedges;
  ncon    = cgraph.ncon   = agraph->ncon;
  xadj    = cgraph.xadj   = icopy(nvtxs+1, agraph->xadj, iwspacemalloc(ctrl, nvtxs+1));
  vwgt    = cgraph.vwgt   = icopy(nvtxs*ncon, agraph->vwgt, iwspacemalloc(ctrl, nvtxs*ncon));
  vsize   = cgraph.vsize  = icopy(nvtxs, agraph->vsize, iwspacemalloc(ctrl, nvtxs));
  adjncy  = cgraph.adjncy = icopy(nedges, agraph->adjncy, iwspacemalloc(ctrl, nedges));
  adjwgt  = cgraph.adjwgt = icopy(nedges, agraph->adjwgt, iwspacemalloc(ctrl, nedges));
  part    = cgraph.where  = agraph->where = iwspacemalloc(ctrl, nvtxs);

  lwhere = iwspacemalloc(ctrl, nvtxs);
  home   = iwspacemalloc(ctrl, nvtxs);
  lbvec  = rwspacemalloc(ctrl, graph->ncon);


  /****************************************/
  /****************************************/
  if (ctrl->ps_relation == PARMETIS_PSR_UNCOUPLED) {
    WCOREPUSH;
    rcounts = iwspacemalloc(ctrl, ctrl->npes);
    rdispls = iwspacemalloc(ctrl, ctrl->npes+1);

    for (i=0; i<ctrl->npes; i++) 
      rdispls[i] = rcounts[i] = vtxdist[i+1]-vtxdist[i];
    MAKECSR(i, ctrl->npes, rdispls);

    gkMPI_Allgatherv((void *)graph->home, graph->nvtxs, IDX_T,
        (void *)part, rcounts, rdispls, IDX_T, ctrl->comm);

    for (i=0; i<agraph->nvtxs; i++)
      home[i] = part[i];

    WCOREPOP;  /* local frees */
  }
  else {
    for (i=0; i<ctrl->npes; i++) {
      for (j=vtxdist[i]; j<vtxdist[i+1]; j++)
        part[j] = home[j] = i;
    }
  }

  /* Ensure that the initial partitioning is legal */
  for (i=0; i<agraph->nvtxs; i++) {
    if (part[i] >= ctrl->nparts)
      part[i] = home[i] = part[i] % ctrl->nparts;
    if (part[i] < 0)
      part[i] = home[i] = (-1*part[i]) % ctrl->nparts;
  }
  /****************************************/
  /****************************************/

  IFSET(ctrl->dbglvl, DBG_REFINEINFO, 
      ComputeSerialBalance(ctrl, agraph, agraph->where, lbvec));
  IFSET(ctrl->dbglvl, DBG_REFINEINFO, 
      rprintf(ctrl, "input cut: %"PRIDX", balance: ", ComputeSerialEdgeCut(agraph)));
  for (i=0; i<agraph->ncon; i++)
    IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "%.3"PRREAL" ", lbvec[i]));
  IFSET(ctrl->dbglvl, DBG_REFINEINFO, rprintf(ctrl, "\n"));

  /****************************************/
  /* Split the processors into two groups */
  /****************************************/
  sr = (ctrl->mype % 2 == 0) ? 1 : 0;
  gd = (ctrl->mype % 2 == 1) ? 1 : 0;

  if (graph->ncon > MAX_NCON_FOR_DIFFUSION || ctrl->npes == 1) {
    sr = 1;
    gd = 0;
  }

  sr_pe = 0;
  gd_pe = 1;

  gkMPI_Comm_split(ctrl->gcomm, sr, 0, &ipcomm);
  gkMPI_Comm_rank(ipcomm, &mype);
  gkMPI_Comm_size(ipcomm, &npes);

  if (sr == 1) { /* Half of the processors do scratch-remap */
    ngroups = gk_max(gk_min(RIP_SPLIT_FACTOR, npes), 1);
    gkMPI_Comm_split(ipcomm, mype % ngroups, 0, &srcomm);
    gkMPI_Comm_rank(srcomm, &srmype);
    gkMPI_Comm_size(srcomm, &srnpes);

    METIS_SetDefaultOptions(moptions);
    moptions[METIS_OPTION_SEED] = ctrl->sync + (mype % ngroups) + 1;

    tpwgts  = ctrl->tpwgts;
    tpwgts2 = rwspacemalloc(ctrl, 2*ncon);

    iset(nvtxs, 0, lwhere);
    lnparts = ctrl->nparts;
    fpart = fpe = 0;
    lnpes = srnpes;
    while (lnpes > 1 && lnparts > 1) {
      PASSERT(ctrl, agraph->nvtxs > 1);
      /* determine the weights of the two partitions as a function of the 
         weight of the target partition weights */
      for (j=(lnparts>>1), i=0; i<ncon; i++) {
        tpwgts2[i]      = rsum(j, tpwgts+fpart*ncon+i, ncon);
        tpwgts2[ncon+i] = rsum(lnparts-j, tpwgts+(fpart+j)*ncon+i, ncon);
        wsum            = 1.0/(tpwgts2[i] + tpwgts2[ncon+i]);
        tpwgts2[i]      *= wsum;
        tpwgts2[ncon+i] *= wsum;
      }

      METIS_PartGraphRecursive(&agraph->nvtxs, &ncon, agraph->xadj, 
            agraph->adjncy, agraph->vwgt, NULL, agraph->adjwgt, 
            &twoparts, tpwgts2, NULL, moptions, &edgecut, part);

      /* pick one of the branches */
      if (srmype < fpe+lnpes/2) {
        KeepPart(ctrl, agraph, part, 0);
        lnpes   = lnpes/2;
        lnparts = lnparts/2;
      }
      else {
        KeepPart(ctrl, agraph, part, 1);
        fpart   = fpart + lnparts/2;
        fpe     = fpe + lnpes/2;
        lnpes   = lnpes - lnpes/2;
        lnparts = lnparts - lnparts/2;
      }
    }

    if (lnparts == 1) { /* Case in which srnpes is greater or equal to nparts */
      /* Only the first process will assign labels (for the reduction to work) */
      if (srmype == fpe) {
        for (i=0; i<agraph->nvtxs; i++) 
          lwhere[agraph->label[i]] = fpart;
      }
    }
    else { /* Case in which srnpes is smaller than nparts */
      /* create the normalized tpwgts for the lnparts from ctrl->tpwgts */
      tpwgts = rwspacemalloc(ctrl, lnparts*ncon);
      for (j=0; j<ncon; j++) {
        for (wsum=0.0, i=0; i<lnparts; i++) {
          tpwgts[i*ncon+j] = ctrl->tpwgts[(fpart+i)*ncon+j];
          wsum += tpwgts[i*ncon+j];
        }
        for (wsum=1.0/wsum, i=0; i<lnparts; i++)
          tpwgts[i*ncon+j] *= wsum;
      }

      METIS_PartGraphKway(&agraph->nvtxs, &ncon, agraph->xadj, agraph->adjncy, 
	    agraph->vwgt, NULL, agraph->adjwgt, &lnparts, tpwgts, NULL, moptions, 
            &edgecut, part);

      for (i=0; i<agraph->nvtxs; i++) 
        lwhere[agraph->label[i]] = fpart + part[i];
    }

    gkMPI_Allreduce((void *)lwhere, (void *)part, nvtxs, IDX_T, MPI_SUM, srcomm);

    edgecut = ComputeSerialEdgeCut(&cgraph);
    ComputeSerialBalance(ctrl, &cgraph, part, lbvec);
    lbsum = rsum(ncon, lbvec, 1);
    gkMPI_Allreduce((void *)&edgecut, (void *)&max_cut, 1, IDX_T, MPI_MAX, ipcomm);
    gkMPI_Allreduce((void *)&lbsum, (void *)&min_lbsum, 1, REAL_T, MPI_MIN, ipcomm);
    lpecost.rank = ctrl->mype;
    lpecost.cost = lbsum;
    if (min_lbsum < UNBALANCE_FRACTION * (real_t)(ncon)) {
      if (lbsum < UNBALANCE_FRACTION * (real_t)(ncon))
        lpecost.cost = (double)edgecut;
      else
        lpecost.cost = (double)max_cut + lbsum;
    }
    gkMPI_Allreduce((void *)&lpecost, (void *)&gpecost, 1, MPI_DOUBLE_INT,
        MPI_MINLOC, ipcomm);

    if (ctrl->mype == gpecost.rank && ctrl->mype != sr_pe) 
      gkMPI_Send((void *)part, nvtxs, IDX_T, sr_pe, 1, ctrl->comm);

    if (ctrl->mype != gpecost.rank && ctrl->mype == sr_pe) 
      gkMPI_Recv((void *)part, nvtxs, IDX_T, gpecost.rank, 1, ctrl->comm, &status);

    if (ctrl->mype == sr_pe) {
      icopy(nvtxs, part, lwhere);
      SerialRemap(ctrl, &cgraph, ctrl->nparts, home, lwhere, part, ctrl->tpwgts);
    }

    gkMPI_Comm_free(&srcomm);
  }
Esempio n. 22
0
//
// Save only Device related parameters
//
void LKDeviceSave(const TCHAR *szFile)
{
  #if TESTBENCH
  StartupStore(_T("... DeviceSave <%s>%s"),szFile,NEWLINE);
  #endif

  if (_tcslen(szFile)>0)
	pfp = _tfopen(szFile, TEXT("wb")); // 'w' will overwrite content, 'b' for no crlf translation

  if(pfp == NULL) {
	StartupStore(_T("......  DeviceSaveProfile <%s> open for write FAILED!%s"),szFile,NEWLINE);
	return;
  }

  //
  // Standard header
  //
  fprintf(pfp,"### LK8000 DEVICE PROFILE - DO NOT EDIT%s",PNEWLINE);
  fprintf(pfp,"### THIS FILE IS ENCODED IN UTF8%s",PNEWLINE);
  fprintf(pfp,"LKVERSION=\"%s.%s\"%s",LKVERSION,LKRELEASE,PNEWLINE);
  fprintf(pfp,"PROFILEVERSION=2%s",PNEWLINE);

  rprintf(szRegistryDeviceA,dwDeviceName1);
  rprintf(szRegistryDeviceB,dwDeviceName2);

  rprintf(szRegistryPort1Name,szPort1);
  rprintf(szRegistryPort2Name,szPort2);

  rprintf(szRegistrySpeed1Index,dwSpeedIndex1);
  rprintf(szRegistrySpeed2Index,dwSpeedIndex2);

  rprintf(szRegistryBit1Index,dwBit1Index);
  rprintf(szRegistryBit2Index,dwBit2Index);

  rprintf(szRegistryUseExtSound1,UseExtSound1);
  rprintf(szRegistryUseExtSound2,UseExtSound2);

  rprintf(szRegistryUseGeoidSeparation,UseGeoidSeparation);
  rprintf(szRegistryPollingMode,PollingMode);
  rprintf(szRegistryCheckSum,CheckSum);

  rprintf(szRegistryAppInfoBoxModel,GlobalModelType); // We save GlobalModelType, not InfoBoxModel

  fprintf(pfp,PNEWLINE); // end of file
  fflush(pfp);
  fclose(pfp);

}
Esempio n. 23
0
// NetcdfFile::WriteVIDs()
void NetcdfFile::WriteVIDs() const {
  rprintf("TempVID_=%i  coordVID_=%i  velocityVID_=%i frcVID_=%i  cellAngleVID_=%i"
          "  cellLengthVID_=%i  indicesVID_=%i\n",
          TempVID_, coordVID_, velocityVID_, frcVID_, cellAngleVID_, cellLengthVID_, indicesVID_);
}