Exemple #1
0
static int
fixfrag(char *pathname, const char *gfarm_prefix)
{
	char *gfarm_url, *sec, *gfarm_file, *e;
	struct gfs_stat gst;
	int r = 1;

	gfarm_url = append_prefix_pathname(gfarm_prefix, pathname);
	if (gfarm_url == NULL) {
		print_errmsg(pathname, NULL, "not enough memory");
		return (r);
	}

	/* divide into file and section parts. */
	e = split_file_and_section(gfarm_url, &sec);
	if (e != NULL) {
		print_errmsg(pathname, NULL, e);
		delete_invalid_file_or_directory(pathname);
		goto error_gfarm_url;
	}

	e = gfs_stat(gfarm_url, &gst);
	if (e == NULL) {
		if (!GFARM_S_ISREG(gst.st_mode)) {
			gfs_stat_free(&gst);
			print_errmsg(gfarm_url, NULL, "not a regular file");
			delete_invalid_file_or_directory(pathname);
			goto error_gfarm_url;
		}
		gfs_stat_free(&gst);
	}
	else
		/* permit no fragment case */;

	e = gfarm_url_make_path(gfarm_url, &gfarm_file);
	if (e != NULL) {
		print_errmsg(gfarm_url, sec, e);
		delete_invalid_file_or_directory(pathname);
		goto error_gfarm_url;
	}

	/* check whether the fragment is already registered. */
	e = fixfrag_i(gfarm_url, pathname, gfarm_file, sec);
	if (e != NULL && e != GFARM_ERR_ALREADY_EXISTS)
		goto error_gfarm_file;

	r = 0;

error_gfarm_file:
	free(gfarm_file);
error_gfarm_url:	
	free(gfarm_url);
	return (r);
}
Exemple #2
0
int
main(int argc, char *argv[])
{
	char *e, *gfarm_prefix;
	extern int optind;
	int c;

	e = gfarm_initialize(&argc, &argv);
	if (e != NULL) {
		print_errmsg(progname, e);
		exit(1);
	}
	if (!gfarm_is_active_file_system_node) {
		print_errmsg(progname, "not a filesystem node");
		exit(1);
	}
	while ((c = getopt(argc, argv, "ad")) != EOF) {
		switch (c) {
		case 'a':
			check_all = 1;
			break;
		case 'd':
			delete_invalid_file = 1;
			break;
		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;

	if (*argv) {
		while (*argv)
			fixurl(*argv++);
		goto finish;
	}

	/* fix a whole spool directory. */
	if (chdir(gfarm_spool_root) == 0)
		gfarm_prefix = "gfarm:/";
	else
		gfarm_prefix = "gfarm:";

	fixdir(".", gfarm_prefix);

 finish:
	e = gfarm_terminate();
	if (e != NULL) {
		print_errmsg(progname, e);
		exit(1);
	}
	exit(0);
}
Exemple #3
0
int main(int argc, char *argv[])
{
	init();
	if(init_setting() != 0){
		print_errmsg("ERROR: SETTING init fail. \n");
		return 1;	
	}
	if(gc_init() != 0){
		print_errmsg("ERROR: G_CODE init fail. \n");
		return 1;
	}
	if (cm_init() == false)
	{
		print_errmsg("ERROR: USB-DEV init fail. \n");
		return 1;
	}
  
	if (cmd_init() == false)
	{
		print_errmsg("ERROR: G code init fail.\n");
		cm_close();
		return 1;
	}
	
	if (tp_init() == false)
	{
		print_errmsg("ERROR: Temperature library init fail. \n");
		cmd_close();
		cm_close();
		return 1;
	}

	plan_init();
	Config_ResetDefault();
	st_init();

	while(1) {
		LCD(10UL);
		getCommand(10UL);
		process_commands(50UL);
		stepper(1000L);
		manageHeater(10UL);
	}

	st_close();
	plan_close();
	tp_close();
	cmd_close();
	cm_close();
	//debug
	//sfp_close();
	return 0;
}
Exemple #4
0
static char *
fixfrag_i(const char *gfarm_url, char *pathname, char *gfarm_file, char *sec)
{
	char *e, *path;

	e = fixfrag_ii(pathname, gfarm_file, sec);
	if (e != NULL) {
		if (e != GFARM_ERR_ALREADY_EXISTS) {
			print_errmsg(gfarm_url, sec, e);
			if (e != GFARM_ERR_TEXT_FILE_BUSY)
				delete_invalid_file_or_directory(pathname);
		}
		/* display file name */
		if (list_local_file) {
			path = strdup(pathname);
			if (path != NULL) {
				if (split_file_and_section(path, NULL) == NULL)
					printf("%s\n", path);
				free(path);
			}
		}
	}
	else
		print_msg(gfarm_url, sec, "fixed");

	return (e);
}
Exemple #5
0
static int
unlink_dir(const char *src)
{
	struct stat sb;

	if (lstat(src, &sb)) {
		perror(src);
		return (1);
	}
	if (S_ISDIR(sb.st_mode)) {
		DIR *dirp;
		struct dirent *dp;

		/* allow read and write access always */
		chmod(src, (sb.st_mode | S_IRUSR | S_IWUSR) & 07777);

		dirp = opendir(src);
		if (dirp == NULL) {
			perror(src);
			return (1);
		}
		while ((dp = readdir(dirp)) != NULL) {
			char *f;

			if (strcmp(dp->d_name, ".") == 0
			    || strcmp(dp->d_name, "..") == 0 || dp->d_ino == 0)
				continue;

			GFARM_MALLOC_ARRAY(f, 
				strlen(src) + 1 + strlen(dp->d_name) + 1);
			if (f == NULL) {
				print_errmsg(dp->d_name, NULL,
					"not enough memory");
				return (1);
			}
			strcpy(f, src);
			strcat(f, "/");
			strcat(f, dp->d_name);

			(void)unlink_dir(f);

			free(f);
		}
		closedir(dirp);
		if (rmdir(src)) {
			perror(src);
			return (1);
		}
	}
	else if (unlink(src)) {
		/* if 'src' is not a directory, try to unlink. */
		perror(src);
		return (1);
	}
	return (0);
}
Exemple #6
0
static void
delete_invalid_file_or_directory(char *pathname)
{
	if (delete_invalid_file) {
		if (unlink_dir(pathname) == 0)
			print_msg(pathname, NULL, "deleted");
		else
			print_errmsg(pathname, NULL, "cannot delete");
	}
}
Exemple #7
0
static void
delete_invalid_file_or_directory(char *pathname)
{
	if (delete_invalid_file) {
		if (unlink_dir(pathname) == 0)
			printf("%s on %s: deleted\n",
			       pathname, gfarm_host_get_self_name());
		else
			print_errmsg(pathname, "cannot delete");
	}
}
Exemple #8
0
static int
unlink_dir(const char *src)
{
	struct stat sb;

	if (lstat(src, &sb)) {
		perror(src);
		return (1);
	}
	if (S_ISDIR(sb.st_mode)) {
		DIR *dirp;
		struct dirent *dp;

		dirp = opendir(src);
		if (dirp == NULL) {
			perror(src);
			return (1);
		}
		while ((dp = readdir(dirp)) != NULL) {
			char *f;

			if (strcmp(dp->d_name, ".") == 0
			    || strcmp(dp->d_name, "..") == 0 || dp->d_ino == 0)
				continue;

			f = malloc(strlen(src) + 1 + strlen(dp->d_name) + 1);
			if (f == NULL) {
				print_errmsg(dp->d_name, "not enough memory");
				return (1);
			}
			strcpy(f, src);
			strcat(f, "/");
			strcat(f, dp->d_name);

			(void)unlink_dir(f);

			free(f);
		}
		closedir(dirp);
		if (rmdir(src)) {
			perror(src);
			return (1);
		}
	}
	else if (unlink(src)) {
		/* if 'src' is not a directory, try to unlink. */
		perror(src);
		return (1);
	}
	return (0);
}
Exemple #9
0
static int
fixdir(char *dir, const char *gfarm_prefix)
{
	DIR* dirp;
	struct dirent *dp;
	struct stat sb;
	char *dir1;
	char *gfarm_url, *e;
	int is_directory;
	struct gfs_stat gs;

	if (lstat(dir, &sb)) {
		perror(dir);
		return (1);
	}
	if (S_ISREG(sb.st_mode))
		return (fixfrag(dir, gfarm_prefix));

	if (!S_ISDIR(sb.st_mode)) {
		print_errmsg(dir, NULL,
			"neither a regular file nor a directory");
		delete_invalid_file_or_directory(dir);
		return (1);
	}

	/* 'dir' is a directory */
	gfarm_url = append_prefix_pathname(gfarm_prefix, dir);
	if (gfarm_url == NULL) {
		print_errmsg(dir, NULL, "not enough memory");
		return (1);
	}

	e = gfs_stat(gfarm_url, &gs);
	if (e != NULL) {
		print_errmsg(gfarm_url, NULL, e);
		delete_invalid_file_or_directory(dir);
		free(gfarm_url);
		return (1);
	}
	is_directory = GFARM_S_ISDIR(gs.st_mode);
	gfs_stat_free(&gs);
	if (!is_directory) {
		print_errmsg(gfarm_url, NULL, "invalid directory");
		delete_invalid_file_or_directory(dir);
		free(gfarm_url);
		return (1);
	}
	free(gfarm_url);

	dirp = opendir(dir);
	if (dirp == NULL) {
		perror(dir);
		return (1);
	}

	if (strcmp(dir, ".") == 0)
		dir = ""; /* just a trick */

	while ((dp = readdir(dirp)) != NULL) {
		if (strcmp(dp->d_name, ".") == 0
		    || strcmp(dp->d_name, "..") == 0)
			continue;

		GFARM_MALLOC_ARRAY(dir1, strlen(dir) + strlen(dp->d_name) + 2);
		if (dir1 == NULL) {
			print_errmsg(dp->d_name, NULL, "not enough memory");
			closedir(dirp);
			return (1);
		}
		strcpy(dir1, dir);
		if (strcmp(dir, ""))
			strcat(dir1, "/");
		strcat(dir1, dp->d_name);

		fixdir(dir1, gfarm_prefix);

		free(dir1);
	}
	return (closedir(dirp));
}
Exemple #10
0
static void
fixurl(const char *gfarm_url)
{
	char *gfarm_file, *local_path, *e;
	struct stat sb;
	int len_path, is_invalid = 0, is_directory = 0;
	glob_t pglob;
	char **pathp, *pat;
	struct gfs_stat gs;

	e = gfarm_canonical_path(gfarm_url_prefix_skip(gfarm_url), &gfarm_file);
	if (e != NULL) {
		/*
		 * no path info, try to delete invalid physical files
		 * or directories
		 */
		e = gfarm_canonical_path_for_creation(
			gfarm_url_prefix_skip(gfarm_url), &gfarm_file);
		if (e != NULL) {
			/* in this case, give up searching invalid files */
			print_errmsg(gfarm_url, NULL, e);
			return;
		}
		is_invalid = 1;
	}
	else {
		/* check it is a directory or not */
		e = gfs_stat(gfarm_url, &gs);
		if (e != NULL) {
			if (e != GFARM_ERR_NO_FRAGMENT_INFORMATION) {
				/* maybe permission denied */
				print_errmsg(gfarm_url, NULL, e);
				goto error_gfarm_file;
			}
			/* no fragment information case */
		}
		else {
			is_directory = GFARM_S_ISDIR(gs.st_mode);
			gfs_stat_free(&gs);
		}
	}
	/*
	 * Check local_path; if it is invalid or not a directory,
	 * delete it.  Otherwise, check it recursively.
	 */
	e = gfarm_path_localize(gfarm_file, &local_path);
	if (e == NULL && stat(local_path, &sb) == 0) {
		if (is_invalid || !is_directory || !S_ISDIR(sb.st_mode)) {
			print_errmsg(local_path, NULL,
				"invalid file or directory");
			delete_invalid_file_or_directory(local_path);
		}
		else if (chdir(local_path) == 0)
			(void)fixdir(".", gfarm_url);
		/* continue */
	}
	if (e != NULL) {
		print_errmsg(gfarm_url, NULL, e);
		goto error_gfarm_file;
	}

	/* investigate file sections */
	len_path = strlen(local_path);
	GFARM_MALLOC_ARRAY(pat, len_path + 3);
	if (pat == NULL) {
		print_errmsg(gfarm_url, NULL, "not enough memory");
		free(local_path);
		goto error_gfarm_file;
	}
	strcpy(pat, local_path);
	strcat(pat, ":*");
	free(local_path);

	pglob.gl_offs = 0;
	glob(pat, GLOB_DOOFFS, NULL, &pglob);
	free(pat);
	
	pathp = pglob.gl_pathv;
	while (*pathp) {
		char *sec = &((*pathp)[len_path + 1]);

		if (is_invalid || is_directory) {
			print_errmsg(gfarm_url, sec, "invalid file");
			delete_invalid_file_or_directory(*pathp);
			++pathp;
			continue;
		}
		(void)fixfrag_i(gfarm_url, *pathp, gfarm_file, sec);

		++pathp;
	}
	globfree(&pglob);

 error_gfarm_file:
	free(gfarm_file);
	return;
}
Exemple #11
0
int init_setting(void) {
//
	double data;
	char temp[128] = {'\0'};
	INI_HANDLE handle = ini_open("setting.ini");
	if(handle == INI_FAIL){
		print_errmsg("%s\n", ini_geterrmsg());
		return -1;
	}
//
	if(mem_set() != 0) {
		print_errmsg("memory alloc fail!\n");
		return -1;
	}

	load_default();
	
	ini_get_key_ulong(handle, "system", "CMD_BUFFER_SIZE", &sys->cmd_buffer_size);
	ini_get_key_ulong(handle, "system", "CMD_BUFFER_NEAR_FULL", &sys->cmd_buffer_near_full);
	ini_get_key_ulong(handle, "system", "BLOCK_BUFFER_SIZE", &sys->block_buffer_size);
	ini_get_key_ulong(handle, "system", "BLOCK_BUFFER_BOUND", &sys->block_buffer_bound);
	ini_get_key_ulong(handle, "system", "MAX_CMD_SIZE", &sys->max_cmd_size);
	ini_get_key_ulong(handle, "system", "STEPPER_BUFFER_SIZE", &sys->stepper_buffer_size);
	ini_get_key_ulong(handle, "system", "STEPPER_BUFFER_BOUND", &sys->stepper_buffer_bound);
	ini_get_key_ulong(handle, "system", "MIN_STEP_PULSE_DUTY", &sys->min_step_pulse_duty);
	ini_get_key_ulong(handle, "system", "DEFAULT_PULSE_PERIOD", &sys->default_pulse_period);
	ini_get_key_ulong(handle, "system", "DEFAULT_PULSE_DUTY", &sys->default_pulse_duty);
	ini_get_key_ulong(handle, "system", "HIT_PULSE_PERIOD", &sys->hit_pulse_period);
	ini_get_key_ulong(handle, "system", "HIT_PULSE_DUTY", &sys->hit_pulse_duty);

	ini_get_key_int(handle, "machine", "MIN_SOFTWARE_LIMIT", &machine->min_software_limit);
	ini_get_key_int(handle, "machine", "MAX_SOFTWARE_LIMIT", &machine->max_software_limit);
	//TODO:改不管大小寫
	ini_get_key(handle, "machine", "TYPE", &temp[0]);
	if(strcmp(temp, "H_BOT") == 0) 
		machine->type = H_BOT;
	else if(strcmp(temp, "DELTA") == 0)
		machine->type = DELTA;
	else
		machine->type = NORMAL;
	
	ini_get_key_int(handle, "machine", "NUM_AXIS", &machine->num_axis);
	ini_get_key_double(handle, "machine", "X_MAX_POS_MM", &machine->x_max_pos_mm);
	ini_get_key_double(handle, "machine", "X_MIN_POS_MM", &machine->x_min_pos_mm);
	ini_get_key_double(handle, "machine", "X_HOME_POS_MM", &machine->x_home_pos_mm);
	ini_get_key_double(handle, "machine", "Y_MAX_POS_MM", &machine->y_max_pos_mm);
	ini_get_key_double(handle, "machine", "Y_MIN_POS_MM", &machine->y_min_pos_mm);
	ini_get_key_double(handle, "machine", "Y_HOME_POS_MM", &machine->y_home_pos_mm);
	ini_get_key_double(handle, "machine", "Z_MAX_POS_MM", &machine->z_max_pos_mm);
	ini_get_key_double(handle, "machine", "Z_MIN_POS_MM", &machine->z_min_pos_mm);
	ini_get_key_double(handle, "machine", "Z_HOME_POS_MM", &machine->z_home_pos_mm);
	ini_get_key_double(handle, "machine", "X_HOME_RETRACT_MM", &machine->x_home_retract_mm);
	ini_get_key_double(handle, "machine", "Y_HOME_RETRACT_MM", &machine->y_home_retract_mm);
	ini_get_key_double(handle, "machine", "Z_HOME_RETRACT_MM", &machine->z_home_retract_mm);
	ini_get_key_int(handle, "machine", "X_HOME_DIR", &machine->x_home_dir);;
	ini_get_key_int(handle, "machine", "Y_HOME_DIR", &machine->y_home_dir);
	ini_get_key_int(handle, "machine", "Z_HOME_DIR", &machine->z_home_dir);
	ini_get_key_double(handle, "machine", "QX_STEPS_PER_MM", &machine->qx_steps_per_mm);
	ini_get_key_double(handle, "machine", "QY_STEPS_PER_MM", &machine->qy_steps_per_mm);
	ini_get_key_double(handle, "machine", "QZ_STEPS_PER_MM", &machine->qz_steps_per_mm);
	ini_get_key_double(handle, "machine", "QE_STEPS_PER_MM", &machine->qe_steps_per_mm);	
	ini_get_key_double(handle, "machine", "X_MAX_FEEDRATE", &machine->x_max_feedrate_mps);
	ini_get_key_double(handle, "machine", "Y_MAX_FEEDRATE", &machine->y_max_feedrate_mps);
	ini_get_key_double(handle, "machine", "Z_MAX_FEEDRATE", &machine->z_max_feedrate_mps);
	ini_get_key_double(handle, "machine", "E_MAX_FEEDRATE", &machine->e_max_feedrate_mps);	
	ini_get_key_double(handle, "machine", "X_HOMING_FEEDRATE", &machine->x_homing_feedrate_mpm);
	ini_get_key_double(handle, "machine", "Y_HOMING_FEEDRATE", &machine->y_homing_feedrate_mpm);
	ini_get_key_double(handle, "machine", "Z_HOMING_FEEDRATE", &machine->z_homing_feedrate_mpm);	
	ini_get_key_double(handle, "machine", "QX_MAX_ACCELERATION", &machine->qx_max_acceleration);
	ini_get_key_double(handle, "machine", "QY_MAX_ACCELERATION", &machine->qy_max_acceleration);
	ini_get_key_double(handle, "machine", "QZ_MAX_ACCELERATION", &machine->qz_max_acceleration);
	ini_get_key_double(handle, "machine", "QE_MAX_ACCELERATION", &machine->qe_max_acceleration);	
	ini_get_key_double(handle, "machine", "DEFAULT_ACCELERATION", &machine->default_acceleration);
	ini_get_key_double(handle, "machine", "DEFAULT_RETRACT_ACCELERATION", &machine->default_retract_acceleration);
	ini_get_key_double(handle, "machine", "DEFAULT_MINIMUMFEEDRATE", &machine->default_minimumfeedrate);
	ini_get_key_double(handle, "machine", "DEFAULT_MINTRAVELFEEDRATE", &machine->default_mintravelfeedrate);
	ini_get_key_double(handle, "machine", "DEFAULT_XYJERK", &machine->default_xyjerk);
	ini_get_key_double(handle, "machine", "DEFAULT_EJERK", &machine->default_ejerk);
	ini_get_key_double(handle, "machine", "DEFAULT_ZJERK", &machine->default_zjerk);
	ini_get_key_double(handle, "machine", "MINIMUM_PLANNER_SPEED", &machine->minimum_planner_speed);
	
	//這裡必須檔0.5 跟 DUTY_MIN
	ini_get_key_double(handle, "machine", "STEP_PULSE_DUTY_RATE", &data);
	if(data < 0.5)
		machine->step_pulse_duty_ratio = 0.5;
	else if(data > 1 && data < (double)sys->min_step_pulse_duty)
		machine->step_pulse_duty_ratio = (double)sys->min_step_pulse_duty;
	else
		machine->step_pulse_duty_ratio = data;
	
	//TODO:改不管大小寫
	ini_get_key(handle, "machine", "LIMIT_SPEED", &temp[0]);
	if(strcmp(temp, "250k") == 0)
		machine->mcm_samplecycle = 25;
	else if(strcmp(temp, "200k") == 0)
		machine->mcm_samplecycle = 20;
	else if(strcmp(temp, "100k") == 0)
		machine->mcm_samplecycle = 10;
	else if(strcmp(temp, "50k") == 0)
		machine->mcm_samplecycle = 5;
	else if(strcmp(temp, "40k") == 0)
		machine->mcm_samplecycle = 4;
	else
		machine->mcm_samplecycle = 1;
	
	ini_get_key_int(handle, "machine", "MM_PER_ARC_SEGMENT", &machine->mm_per_arc_segment);
	ini_get_key_int(handle, "machine", "N_ARC_CORRECTION", &machine->n_arc_correction);	
	ini_get_key_double(handle, "machine", "X_HOME_OFFSET", &machine->home_offset[0]);
	ini_get_key_double(handle, "machine", "Y_HOME_OFFSET", &machine->home_offset[1]);
	ini_get_key_double(handle, "machine", "Z_HOME_OFFSET", &machine->home_offset[2]);

	ini_get_key_int(handle, "pins", "mc_qx", &pins->mc_qx);
	ini_get_key_int(handle, "pins", "md_qx", &pins->md_qx);
	ini_get_key_int(handle, "pins", "mc_qy", &pins->mc_qy);
	ini_get_key_int(handle, "pins", "md_qy", &pins->md_qy);
	ini_get_key_int(handle, "pins", "mc_qz", &pins->mc_qz);
	ini_get_key_int(handle, "pins", "md_qz", &pins->md_qz);
	ini_get_key_int(handle, "pins", "mc_qe", &pins->mc_qe);
	ini_get_key_int(handle, "pins", "md_qe", &pins->md_qe);
	ini_get_key_int(handle, "pins", "MC_LIMIT", &pins->mc_limit);
	ini_get_key_int(handle, "pins", "MD_LIMIT", &pins->md_limit);
	ini_get_key_int(handle, "pins", "MC_LCD", &pins->mc_lcd);
	ini_get_key_int(handle, "pins", "MD_LCD", &pins->md_lcd);

	ini_get_key_int(handle, "pins", "INVERT_X_DIR", &pins->invert_x_dir);
	ini_get_key_int(handle, "pins", "X_STEP_PIN", &pins->x_step_pin);
	ini_get_key_int(handle, "pins", "X_DIR_PIN", &pins->x_dir_pin);
	ini_get_key_int(handle, "pins", "INVERT_Y_DIR", &pins->invert_y_dir);
	ini_get_key_int(handle, "pins", "Y_STEP_PIN", &pins->y_step_pin);
	ini_get_key_int(handle, "pins", "Y_DIR_PIN", &pins->y_dir_pin);	
	ini_get_key_int(handle, "pins", "INVERT_Z_DIR", &pins->invert_z_dir);
	ini_get_key_int(handle, "pins", "Z_STEP_PIN", &pins->z_step_pin);
	ini_get_key_int(handle, "pins", "Z_DIR_PIN", &pins->z_dir_pin);
	ini_get_key_int(handle, "pins", "INVERT_E_DIR", &pins->invert_e_dir);	
	ini_get_key_int(handle, "pins", "E_STEP_PIN", &pins->e_step_pin);
	ini_get_key_int(handle, "pins", "E_DIR_PIN", &pins->e_dir_pin);	
	
	ini_get_key_int(handle, "pins", "X_ENABLE_PORT", &pins->x_enable_port);
	ini_get_key_int(handle, "pins", "X_ENABLE_PIN", &pins->x_enable_pin);
	ini_get_key_int(handle, "pins", "INVERT_X_ENABLE", &pins->invert_x_enable);
	ini_get_key_int(handle, "pins", "Y_ENABLE_PORT", &pins->y_enable_port);
	ini_get_key_int(handle, "pins", "Y_ENABLE_PIN", &pins->y_enable_pin);
	ini_get_key_int(handle, "pins", "INVERT_Y_ENABLE", &pins->invert_y_enable);
	ini_get_key_int(handle, "pins", "Z_ENABLE_PORT", &pins->z_enable_port);
	ini_get_key_int(handle, "pins", "Z_ENABLE_PIN", &pins->z_enable_pin);
	ini_get_key_int(handle, "pins", "INVERT_Z_ENABLE", &pins->invert_z_enable);
	ini_get_key_int(handle, "pins", "E_ENABLE_PORT", &pins->e_enable_port);
	ini_get_key_int(handle, "pins", "E_ENABLE_PIN", &pins->e_enable_pin);
	ini_get_key_int(handle, "pins", "INVERT_E_ENABLE", &pins->invert_e_enable);
	
	ini_get_key_int(handle, "temperature", "EXTRUDERS", &tp->extruders);
	ini_get_key_ulong(handle, "temperature", "PWM_PERIOD", &tp->pwm_period);
	
	ini_get_key_double(handle, "temperature", "HEATER_VELOCITY", &tp->heater_velocity);
	ini_get_key_double(handle, "temperature", "K1", &tp->K1);
	tp->K2 = 1 - tp->K1;
	ini_get_key_int(handle, "temperature", "AUTOTUNE_PID_ENABLE", &tp->autotune_pid_enable);
	ini_get_key_double(handle, "temperature", "DEFAULT_KP", &tp->default_Kp);
	ini_get_key_double(handle, "temperature", "DEFAULT_KI", &tp->default_Ki);
	ini_get_key_double(handle, "temperature", "DEFAULT_KD", &tp->default_Kd);
	ini_get_key_double(handle, "temperature", "DEFAULT_BEDKP", &tp->default_bedKp);
	ini_get_key_double(handle, "temperature", "DEFAULT_BEDKI", &tp->default_bedKi);
	ini_get_key_double(handle, "temperature", "DEFAULT_BEDKD", &tp->default_bedKd);

	ini_get_key_int(handle, "temperature", "BANG_MAX", &tp->bang_max);
	ini_get_key_int(handle, "temperature", "PID_MAX", &tp->pid_max);
	ini_get_key_int(handle, "temperature", "MAX_BED_POWER", &tp->max_bed_power);
	ini_get_key_int(handle, "temperature", "FAN_MAX", &tp->fan_max);	
	ini_get_key_int(handle, "temperature", "PID_INTEGRAL_DRIVE_MAX", &tp->pid_integral_drive_max);
	
	ini_get_key_double(handle, "temperature", "HEATER0_MINTEMP", &tp->heater_mintemp[0]);
	ini_get_key_double(handle, "temperature", "HEATER0_MAXTEMP", &tp->heater_maxtemp[0]);
	ini_get_key_double(handle, "temperature", "BED_MINTEMP", &tp->bed_mintemp);
	ini_get_key_double(handle, "temperature", "BED_MAXTEMP", &tp->bed_maxtemp);
	ini_get_key_int(handle, "temperature", "OVERSAMPLER", &tp->oversampler);
	ini_get_key_int(handle, "temperature", "PID_FUNCTIONAL_RANGE", &tp->pid_functional_range);
	
	// 86Duino Print3D v1.0
	ini_get_key_int(handle, "pins", "MC_PWM_HEATER0", &pins->mc_pwm[0]);
	ini_get_key_int(handle, "pins", "MD_PWM_HEATER0", &pins->md_pwm[0]);
	ini_get_key_int(handle, "pins", "MC_PWM_HEATER1", &pins->mc_pwm[1]);
	ini_get_key_int(handle, "pins", "MD_PWM_HEATER1", &pins->md_pwm[1]);
	ini_get_key_int(handle, "pins", "MC_PWM_BED", &pins->mc_pwm[2]);
	ini_get_key_int(handle, "pins", "MD_PWM_BED", &pins->md_pwm[2]);
	ini_get_key_int(handle, "pins", "MC_PWM_FAN0", &pins->mc_pwm[3]);
	ini_get_key_int(handle, "pins", "MD_PWM_FAN0", &pins->md_pwm[3]);
	ini_get_key_int(handle, "pins", "MC_PWM_FAN1", &pins->mc_pwm[4]);
	ini_get_key_int(handle, "pins", "MD_PWM_FAN1", &pins->md_pwm[4]);

	ini_get_key_int(handle, "pins", "AD_HEATER0", &pins->extruder_ad[0]);
	ini_get_key_int(handle, "pins", "AD_HEATER1", &pins->extruder_ad[1]);
	ini_get_key_int(handle, "pins", "AD_BED", &pins->hotedbed_ad);
	ini_get_key_int(handle, "pins", "AD_POWER", &pins->vin_ad);
	/*
	// 86Duino Print3D v2.0
	pins->mc_pwm[0] = 3;
	pins->md_pwm[0] = 0;
	pins->mc_pwm[1] = 3;
	pins->md_pwm[1] = 1;
	pins->mc_pwm[2] = 2;
	pins->md_pwm[2] = 2;
	pins->mc_pwm[3] = 2;
	pins->md_pwm[3] = 0;
	pins->mc_pwm[4] = 2;
	pins->md_pwm[4] = 1;

	pins->extruder_ad[0] = 0;
	pins->extruder_ad[1] = 1;
	pins->hotedbed_ad = 2;
	pins->vin_ad = 3;*/
	
	ini_get_key_int(handle, "Auto Bed Leveling", "ENABLE_AUTO_BED_LEVELING", &level->enable_auto_bed_leveling);
	ini_get_key_int(handle, "Auto Bed Leveling", "AUTO_BED_LEVELING_GRID", &level->auto_bed_leveling_grid);
	ini_get_key_double(handle, "Auto Bed Leveling", "ABL_PROBE_PT_1_X", &level->abl_probe_pt_1_x);
	ini_get_key_double(handle, "Auto Bed Leveling", "ABL_PROBE_PT_1_Y", &level->abl_probe_pt_1_y);
	ini_get_key_double(handle, "Auto Bed Leveling", "ABL_PROBE_PT_2_X", &level->abl_probe_pt_2_x);
	ini_get_key_double(handle, "Auto Bed Leveling", "ABL_PROBE_PT_2_Y", &level->abl_probe_pt_2_y );
	ini_get_key_double(handle, "Auto Bed Leveling", "ABL_PROBE_PT_3_X", &level->abl_probe_pt_3_x);
	ini_get_key_double(handle, "Auto Bed Leveling", "ABL_PROBE_PT_3_Y", &level->abl_probe_pt_3_y);
	ini_get_key_double(handle, "Auto Bed Leveling", "XY_TRAVEL_SPEED", &level->xy_travel_speed);
	ini_get_key_double(handle, "Auto Bed Leveling", "X_PROBE_OFFSET_FROM_EXTRUDER", &level->x_probe_offset_from_extruder);
	ini_get_key_double(handle, "Auto Bed Leveling", "Y_PROBE_OFFSET_FROM_EXTRUDER", &level->y_probe_offset_from_extruder);
	ini_get_key_double(handle, "Auto Bed Leveling", "Z_PROBE_OFFSET_FROM_EXTRUDER", &level->z_probe_offset_from_extruder);
	ini_get_key_int(handle, "Auto Bed Leveling", "AUTO_BED_LEVELING_GRID_POINTS", &level->auto_bed_leveling_grid_points);
	ini_get_key_double(handle, "Auto Bed Leveling", "LEFT_PROBE_BED_POSITION", &level->left_probe_bed_position);
	ini_get_key_double(handle, "Auto Bed Leveling", "RIGHT_PROBE_BED_POSITION", &level->right_probe_bed_position);
	ini_get_key_double(handle, "Auto Bed Leveling", "BACK_PROBE_BED_POSITION", &level->back_probe_bed_position);
	ini_get_key_double(handle, "Auto Bed Leveling", "FRONT_PROBE_BED_POSITION", &level->front_probe_bed_position);
	ini_get_key_double(handle, "Auto Bed Leveling", "Z_RAISE_BEFORE_PROBING", &level->z_raise_before_probing);
	ini_get_key_double(handle, "Auto Bed Leveling", "Z_RAISE_BETWEEN_PROBINGS", &level->z_raise_between_probings);
	
	if(ini_close(handle) == 1){
		print_errmsg("ini save fail\n");
	}
	return 0;
}
Exemple #12
0
static int
fixfrag(char *pathname, const char *gfarm_prefix)
{
	char *gfarm_url, *sec, *pname, *gfarm_file, *e;
	struct gfs_stat gst;
	int r = 1;

	gfarm_url = append_prefix_pathname(gfarm_prefix, pathname);
	if (gfarm_url == NULL) {
		print_errmsg(pathname, "not enough memory");
		return (r);
	}

	/* divide into file and section parts. */
	sec = &gfarm_url[strlen(gfarm_url) - 1];
	pname = sec - strlen(pathname) + 1;
	while (sec > pname && *sec != '/') {
		if (*sec == ':') {
			*sec = '\0';
			++sec;
			break;
		}
		--sec;
	}
	if (sec == pname || *sec == '/') {
		print_errmsg(pathname, "invalid filename");
		delete_invalid_file_or_directory(pathname);
		goto error_gfarm_url;
	}

	e = gfs_stat(gfarm_url, &gst);
	if (e == NULL) {
		if (!GFARM_S_ISREG(gst.st_mode)) {
			gfs_stat_free(&gst);
			print_errmsg(gfarm_url, "not a regular file");
			delete_invalid_file_or_directory(pathname);
			goto error_gfarm_url;
		}
		gfs_stat_free(&gst);
	}
	else
		/* permit no fragment case */;

	e = gfarm_url_make_path(gfarm_url, &gfarm_file);
	if (e != NULL) {
		print_errmsg_with_section(gfarm_url, sec, e);
		delete_invalid_file_or_directory(pathname);
		goto error_gfarm_url;
	}

	/* check whether the fragment is already registered. */
	e = fixfrag_i(pathname, gfarm_file, sec);
	if (e != NULL) {
		if (e != GFARM_ERR_ALREADY_EXISTS) {
			print_errmsg_with_section(pathname, sec, e);
			delete_invalid_file_or_directory(pathname);
			goto error_gfarm_file;
		}
		else
			/* no message */;
	}
	else
		printf("%s (%s) on %s: fixed\n", gfarm_url, sec,
		       gfarm_host_get_self_name());
	r = 0;

error_gfarm_file:
	free(gfarm_file);
error_gfarm_url:	
	free(gfarm_url);
	return (r);
}