Beispiel #1
0
void check_finished(uint16_t command) {
  if (command == 0xFFFF) {
    pthread_mutex_lock(&log_mutex);
    fprintf(logfd, "%s", "Read command 0xFFFF, assuming parent is finished\n");
    fflush(logfd);
    pthread_mutex_unlock(&log_mutex);
    finish_up();
  }
}
/* Fill in the DateResult structure based on the given Hebrew date */
void Converter::hebrewToSecularConversion( int hyear, int hmonth, int hday,
                                           struct DateResult *result )
{
  int syear, smonth, sday;
  long absolute;

  absolute = absolute_from_hebrew( hyear, hmonth, hday );
  gregorian_from_absolute( absolute, &syear, &smonth, &sday );
  result->year = hyear;
  result->month = hmonth;
  result->day = hday;
  finish_up( absolute, hyear, hmonth, syear, smonth, result );
}
/* Fill in the DateResult structure based on the given secular date */
void Converter::secularToHebrewConversion( int syear, int smonth, int sday,
                                           struct DateResult *result )
{
  int hyear, hmonth, hday;
  long absolute;

  absolute = absolute_from_gregorian( syear, smonth, sday );

  hebrew_from_absolute( absolute, &hyear, &hmonth, &hday );

  result->year = hyear;
  result->month = hmonth;
  result->day = hday;
  finish_up( absolute, hyear, hmonth, syear, smonth, result );
}
Beispiel #4
0
int main(int argc, char *argv[])
{
	int ret_val = -1;
	int tries = 0;
	unsigned char settings[2];

	parse_command_line(argc, argv);

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = open_modem();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error opening modem, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	printf("Step 1 Find the modem\n");

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = find_modem();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error finding modem, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Steps 2-4 Get the modem settings

	while (tries < 3) {
		printf("Step %d get the modem settings\n", tries + 2);
		tries++;
		ret_val = settings_modem(settings);
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error getting modem settings, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;


	if (settings[0] != 0x03 || settings[1] != 0x03) {
		if (debug)
			printf("Looks like modem needs resetting\n");
		reboot_modem();
		settings_modem(settings);
		settings_modem(settings);
	}

	ret_val = -1;

	// Step 5 Update basis

	printf("Step 5 updating the basis\n");

	while (ret_val != 0 && tries < 2) {
		tries++;
		ret_val = update_basis();
	}

	tries = 0;

	ret_val = -1;


	// Step 6 Update Modem

	printf("Step 6 updating the modem\n");

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = update_modem();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error updating modem, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 7 Get modem settings

	printf("Step 7 getting the modem settings\n");

	while (tries < 1) {
		tries++;
		ret_val = settings_modem(settings);
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error getting modem settings, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 8 Get basis settings

	printf("Step 8 getting the basis settings\n");

	while (ret_val != 0 && tries < 2) {
		tries++;
		ret_val = settings_basis(settings);
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error getting basis settings, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 9 and 10 Get modem settings

	while (tries < 2) {
		printf("Step %d, getting the modem settings\n", tries + 9);
		tries++;
		ret_val = settings_modem(settings);
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error getting modem settings, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 11 Set basis filter

	printf("Step 11 setting the basis filter\n");

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = set_filter_basis();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error setting basis filter, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 12 Set modem filter

	printf("Step 12 setting the modem filter\n");

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = set_filter_modem();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error setting modem filter, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 13 Reboot basis

	printf("Step 13 rebooting basis \n");

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = reboot_basis();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error rebooting basis, please run the program again\n");
		return finish_up(-1);
	}

	ret_val = -1;

	// Step 14 Reboot modem

	printf("Step 14, rebooting the modem \n");

	while (ret_val != 0 && tries < 1) {
		tries++;
		ret_val = reboot_modem();
	}

	tries = 0;

	if (ret_val && !ignore_errors) {
		printf
		    ("Error rebooting modem, please run the program again\n");
		return finish_up(-1);
	}

	return finish_up(0);
}