コード例 #1
0
ファイル: MMC.cpp プロジェクト: AKrduino/arduino-stm32
uint8_t MMC::command_response (const uint8_t *cmd, uint8_t * rspdata, int rsplength)
{
	int count, retry=0;
	uint8_t rxchar;

	spi.select();	
	if (wait_response(READY_TOKEN, READY_TOKEN) != READY_TOKEN) 
	{
		spi.deselect();
		return 0xFF;
	}
	
	/******** Send command ************/
	spi.txrx(cmd,NULL,MMC_CMD_SIZE);
	spi.txrx_byte(0xFF);

	/******** Get response ************/
	rxchar = wait_response(0, 0x80); /* Wait for byte with MSB == 0 */
	if (rxchar != 0) 
	{
		spi.deselect();
		return rxchar;
	}

	rspdata[0]=rxchar;
	spi.txrx(NULL,rspdata+1,rsplength-1);

	return rxchar;
}
コード例 #2
0
ファイル: lm4flash.c プロジェクト: alkyl1978/lm4tools
static int checksum_and_send(libusb_device_handle *handle, size_t idx, int *xfer)
{
	size_t i;
	uint8_t sum = 0;
	int retval, transferred;
	int has_ack;

	if (idx + SNPRINTF_OFFSET + END_LEN > BUF_SIZE)
		return LIBUSB_ERROR_NO_MEM;

	for (i = 1; i < idx; i++)
		sum += buf.u8[i];

	idx += sprintf(buf.c + idx, END "%02x", sum);

	retval = send_command(handle, idx);
	if (retval)
		return retval;

	retval = wait_response(handle, &has_ack, &transferred);
	if (retval)
		return retval;

	if (!has_ack)
		return LIBUSB_ERROR_OTHER;

	if (xfer)
		*xfer = transferred;

	/* FIXME: validate transferred here? */

	return retval;
}
コード例 #3
0
ファイル: Gainer.cpp プロジェクト: arton/GainerX
HRESULT STDMETHODCALLTYPE CGainer::ReadVersion( 
            /* [retval][out] */ BSTR *pResult)
{
    if (!m_iothread) return Error(IDS_E_NOTOPENED);
    if (!pResult) return E_POINTER;
    notify_message(m_iothread_id, WM_COM_IO, "?*");
    return wait_response(pResult);
}
コード例 #4
0
ファイル: commands.cpp プロジェクト: inkooboo/robowars
    void auth::execute()
    {
        Json::Value data;
        data["id"] = 0;
        data["command"] = "auth";
        data["user"] = user_;
        data["password"] = password_;

        send(data);
        wait_response();
    }
コード例 #5
0
ファイル: 3d.c プロジェクト: SenicJe/MicrochipRaspi
int hmi3d_send_message(hmi_t *hmi, void *msg, int size, int timeout) {
    int retries;
    int last_error = HMI_NO_ERROR;
    int msg_id = ((unsigned char *)msg)[3];

    /* Retry 2 times before accepting a failure */
    for(retries = 3; retries > 0; --retries) {
        last_error = hmi3d_message_write(hmi, msg, size);
        if(last_error)
            continue;

        last_error = wait_response(hmi, msg_id, timeout);
        if(!last_error)
            break;
    }
    return last_error;
}
コード例 #6
0
ファイル: getter.cpp プロジェクト: chenchu0910/mooon
bool CGetter::start()
{
    do
    {
        if (!get_ip_list())
            break;

        if (!send_http_request())
            break;

        if (!wait_response())
            break;

        return true;
    } while(false);

    return false;
}
コード例 #7
0
void main() {
  Display_Init();
  MCU_Init();
  #ifdef INIT_BLE
  BLE_Init();
  delay_ms(2000);
  #else
  RN_WAKE = 1;
  wait_response("CMD");
  #endif
  DrawFrame();
  InitTimer2();
  while(1)
  {
    if(data_ready)
    {
      //If characteristic is configured as write
      //received messages come here
      Display_Message();
      reset_buff();
    }
    else
    {
       //Test: every 5sec increase baterry level (0 to 100%)
       //and send value via Bluetooth Low Energy
       if (tmr_flg)
       {
          batt_level++;
          if(batt_level > 100)
          {
            batt_level = 0;
          }
          Display_BatteryLevel();
          if(RN_CONN)
          { //send battery level value if BLE connected
            shorttohex(batt_level, batt_level_txt);
            ltrim(batt_level_txt);
            ble2_write_server_characteristic_value_via_UUID("2A19",batt_level_txt);
          }
          tmr_flg = 0;
       }
    }
  }
}
コード例 #8
0
ファイル: Gainer.cpp プロジェクト: arton/GainerX
HRESULT STDMETHODCALLTYPE CGainer::ReadAllAnalogInputs( 
            /* [optional][in] */ VARIANT ContinuousMode,
            /* [retval][out] */ SAFEARRAY **ppResult)
{
    if (!m_iothread) return Error(IDS_E_NOTOPENED);

    bool continuous = convert_default(ContinuousMode);
    notify_message(m_iothread_id, WM_COM_IO, (continuous) ? "i*" : "I*");
    if (continuous)
        return S_OK;
    BSTR bstr;
    HRESULT hr = wait_response(&bstr);
    if (hr == S_OK)
    {
        *ppResult = convert(bstr);
        SysFreeString(bstr);
    }
    return hr;
}
コード例 #9
0
void BLE_Init()
{
  unsigned int line_no;
   line_no = 10;
  TFT_Write_Text("Start initialization",10,line_no);
  RN_WAKE = 1;
  while (!wait_response("CMD"));                                                //Wait to response CMD
  line_no += 20;
  Delay_ms(100);
  ble2_reset_to_factory_default(1);                                             //Reset RN4020 to factory settings
  while (!wait_response("AOK"));                                                //Wait to response AOK
  TFT_Write_Text("Factory reset",10,line_no);
  line_no += 20;
  Delay_ms(100);
  TFT_Write_Text("Set module name: BLE2_Click",10,line_no);
  ble2_set_device_name("BLE2_Click");                                           //Set name BLE2_Click
  while (!wait_response("AOK"));                                                //Wait to response AOK
  line_no += 20;
  Delay_ms(100);
  TFT_Write_Text("Configure services",10,line_no);

  /*
  Example:
  Table: 2-6 in Datasheet
  Health Thermometer + Heart Rate + Battery Services
  UART_WRite_Line("SS,F0000000");
  */

  ble2_set_server_services(40000000);                                           //Battery
  while (!wait_response("AOK"));                                                //Wait to response AOK
  line_no += 20;
  Delay_ms(100);
  TFT_Write_Text("Configure features",10,line_no);
  ble2_set_supported_features(20000000);                                        //Auto Advertise (Table: 2-5 in Datasheet)
  while (!wait_response("AOK"));                                                //wait to response AOK
  line_no += 20;
  Delay_ms(100);
  TFT_Write_Text("Reboot module",10,line_no);
  ble2_device_reboot();                                                       //reboot
  while (!wait_response("Reboot"));                                             //wait to response Reboot


}
コード例 #10
0
ファイル: orixctl.c プロジェクト: astroza/orixbot
int main(int c, char **v)
{
	struct sockaddr_un to;
	int sock, i;
	char *address;
	char buffer[109];
	int length = 1;

	if(c < 2)
		help();

	for(i = 0; i < NUM; i++) {
		if(strcasecmp(cmds[i].name, v[1]) == 0) {
			if(cmds[i].flags) {
				if(c < 3)
					help();
				else {
					strncpy(buffer + 1, v[2], 108);
					length += strlen(buffer + 1);
				}
			}
			buffer[0] = cmds[i].opcode;
			break;
		}
	}

	if(i == NUM+1)
		help();
	
	if(length > 1) /* Hay un argumento */
		i = 3;
	else
		i = 2;

	if(c < i+1)
		address = UNIX_DOMAIN;
	else
		address = v[i];

	sock = socket(AF_UNIX, SOCK_STREAM, 0);
	if(sock == -1) {
		perror("socket");
		exit(-1);
	}

	to.sun_family = AF_UNIX;
	strncpy(to.sun_path, address, 108);
	to.sun_path[107] = 0;

	if(connect(sock, (struct sockaddr *)&to, sizeof(to)) == -1) {
		perror("connect");
		exit(-1);
	}

	if(send(sock, buffer, length, 0) == -1) {
		perror("send");
		exit(-1);
	}
	
	if(wait_response(sock, 3))
		printf("OK\n");
	else
		printf("ERROR\n");

	close(sock);
	return 0;
}
コード例 #11
0
ファイル: xresponse.c プロジェクト: mer-tools/xresponse
int main(int argc, char **argv)
{
	int cnt, x, y, i = 0, verbose = 0;
	Window win = 0;
	Bool keysymMappingInitialized = False;
	int rc = 0;
	int inputEvents[100];
	int inputEventsIndex = 0;
	int iEvent = 0;

	if (argc == 1)
		usage(argv[0]);

	const char* log_file = NULL;
	if (streq(argv[1],"-o") || streq(argv[1],"--logfile")) {
		i++;

		if (++i > argc)
			usage(argv[0]);

		log_file = argv[i];
	}
	report_init(log_file);

	if (!xhandler_init(getenv("DISPLAY")))
		exit(1);

	report_add_message(xhandler_get_server_time(), "Startup\n");

	/* initialize subsystems */
	xemu_init(xhandler.display);
	scheduler_init(xhandler.display);
	window_init(xhandler.display);
	application_init();

	/*
	 * Process the command line options.
	 * Skip emulation options (--click, --drag, --key, --type), but remember they index
	 * and process them later.
	 */
	while (++i < argc) {

		if (streq(argv[i],"-v") || streq(argv[i],"--verbose")) {
			verbose = 1;
			continue;
		}

		if (streq(argv[i], "-id") || streq(argv[i], "--id")) {
			char name[PATH_MAX];
			if (++i >= argc)
				usage(argv[0]);

			cnt = sscanf(argv[i], "0x%lx", &win);
			if (cnt < 1) {
				cnt = sscanf(argv[i], "%lu", &win);
			}
			if (cnt < 1) {
				fprintf(stderr, "*** invalid window id '%s'\n", argv[i]);
				usage(argv[0]);
			}
			sprintf(name, "0x%lx", win);
			if (!window_add(win, application_monitor(name))) {
				fprintf(stderr, "Could not setup damage monitoring for window 0x%lx!\n", win);
				exit(1);
			}
			if (verbose)
				report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring window 0x%lx\n", win);

			continue;
		}

		if (streq(argv[i], "-a") || streq(argv[i], "--application")) {
			if (++i >= argc)
				usage(argv[0]);

			response.application = application_monitor(argv[i]);
			if (response.application && verbose) {
				report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring application '%s'\n", argv[i]);
			}
			if (!strcmp(argv[i], "*")) {
				application_set_monitor_all(true);
			}
			continue;
		}

		if (streq("-c", argv[i]) || streq("--click", argv[i])) {
			if (!xemu.pointer.dev) {
				fprintf(stderr, "Failed to open pointer device, unable to simulate pointer events.\n");
				exit(-1);
			}
			if (inputEventsIndex == ASIZE(inputEvents)) {
				fprintf(stderr, "Too many input events specified\n");
				exit(-1);
			}
			if (!argv[i + 1] || !match_regex(argv[i + 1], "^[0-9]+x[0-9]+(,[0-9]+)?$")) {
				fprintf(stderr, "Failed to parse --c options: %s\n", argv[i + 1]);
				exit(-1);
			}
			inputEvents[inputEventsIndex++] = i;
			if (++i >= argc)
				usage(argv[0]);

			continue;
		}

		if (streq("-l", argv[i]) || streq("--level", argv[i])) {
			if (++i >= argc)
				usage(argv[0]);

			if (!strcmp(argv[i], "raw")) {
				window_set_damage_level(XDamageReportRawRectangles);
			} else if (!strcmp(argv[i], "delta")) {
				window_set_damage_level(XDamageReportDeltaRectangles);
			} else if (!strcmp(argv[i], "box")) {
				window_set_damage_level(XDamageReportDeltaRectangles);
			} else if (!strcmp(argv[i], "nonempty")) {
				window_set_damage_level(XDamageReportNonEmpty);
			} else {
				fprintf(stderr, "Unrecongnized damage level: %s\n", argv[i]);
				usage(argv[0]);
			}
			if (verbose)
				report_add_message(REPORT_LAST_TIMESTAMP, "Setting damage report level to %s\n", argv[i]);
			continue;
		}

		if (streq("-x", argv[i]) || streq("--exclude", argv[i])) {
			char* exclude[] = { "none", "less", "greater" };

			if (options.exclude_rules != EXCLUDE_NONE) {
				fprintf(stderr, "Duplicated --exclude parameter detected. Aborting\n");
				exit(-1);
			}

			if (++i >= argc)
				usage(argv[0]);
			char rules[32] = "";
			if ((cnt = sscanf(argv[i], "%ux%u,%s", &options.exclude_rect.width, &options.exclude_rect.height, rules)) >= 2) {
				options.exclude_size = 0;
			} else if ((cnt = sscanf(argv[i], "%u,%s", &options.exclude_size, rules)) >= 1) {
				options.exclude_rect.width = 0;
				options.exclude_rect.height = 0;
			} else {
				fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
				usage(argv[0]);
			}
			options.exclude_rules = *rules && !strcmp(rules, "greater") ? EXCLUDE_GREATER : EXCLUDE_LESS;
			if (verbose) {
				if (options.exclude_size) {
					report_add_message(REPORT_LAST_TIMESTAMP, "Excluding damage areas %s than %d pixels\n", exclude[options.exclude_rules],
							options.exclude_size);
				} else {
					report_add_message(REPORT_LAST_TIMESTAMP, "Excluding damage areas %s than (%dx%d)\n", exclude[options.exclude_rules],
							options.exclude_rect.width, options.exclude_rect.height);
				}
			}
			continue;
		}

		if (streq("-m", argv[i]) || streq("--monitor", argv[i])) {
			if (options.interested_damage_rect.width || options.interested_damage_rect.height || options.interested_damage_rect.x
					|| options.interested_damage_rect.y) {
				fprintf(stderr, "Duplicated --monitor parameter detected. Aborting\n");
				exit(-1);
			}
			if (++i >= argc)
				usage(argv[0]);

			if ((cnt = sscanf(argv[i], "%ux%u+%u+%u", &options.interested_damage_rect.width, &options.interested_damage_rect.height,
					&options.interested_damage_rect.x, &options.interested_damage_rect.y)) != 4) {
				fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
				usage(argv[0]);
			}
			if (verbose) {
				report_add_message(REPORT_LAST_TIMESTAMP, "Set monitor rect to %ix%i+%i+%i\n", options.interested_damage_rect.width,
						options.interested_damage_rect.height, options.interested_damage_rect.x, options.interested_damage_rect.y);
			}
			continue;
		}

		if (streq("-w", argv[i]) || streq("--wait", argv[i])) {
			if (++i >= argc)
				usage(argv[0]);

			if (options.damage_wait_secs >= 0) {
				fprintf(stderr, "Duplicate -w(--wait) option detected. Discarding the previous value\n");
			}
			if ((options.damage_wait_secs = atoi(argv[i])) < 0) {
				fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
				usage(argv[0]);
			}
			if (verbose)
				report_add_message(REPORT_LAST_TIMESTAMP, "Set event timeout to %isecs\n", options.damage_wait_secs);

			continue;
		}

		if (streq("-b", argv[i]) || streq("--break", argv[i])) {
			if (options.break_timeout || options.break_on_damage) {
				fprintf(stderr, "Duplicate -b(--break)option detected. Discarding the previous value\n");
				options.break_timeout = 0;
				options.break_on_damage = 0;
			}
			if (++i >= argc)
				usage(argv[0]);

			if (!strncmp(argv[i], "damage", 6)) {
				sscanf(argv[i] + 6, ",%d", &options.break_on_damage);
				if (!options.break_on_damage)
					options.break_on_damage = 1;
				if (verbose)
					report_add_message(REPORT_LAST_TIMESTAMP, "Break wait on the %d damage event\n", options.break_on_damage);
			} else {
				if ((options.break_timeout = atoi(argv[i])) < 0) {
					fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
					usage(argv[0]);
				}
				if (verbose)
					report_add_message(REPORT_LAST_TIMESTAMP, "Set break timout to %imsecs\n", options.break_timeout);
			}
			continue;
		}

		if (streq("-d", argv[i]) || streq("--drag", argv[i])) {
			if (!xemu.pointer.dev) {
				fprintf(stderr, "Failed to open pointer device, unable to simulate pointer events.\n");
				exit(-1);
			}
			if (inputEventsIndex == ASIZE(inputEvents)) {
				fprintf(stderr, "Too many input events specified\n");
				exit(-1);
			}
			if (!argv[i + 1] || (!match_regex(argv[i + 1], "^([0-9]+,)?(([0-9]+x[0-9]+,([0-9]+,)?)+[0-9]+x[0-9]+)$") &&
				 (!match_regex(argv[i + 1], "[0-9]+x[0-9]+-[0-9]+x[0-9]+") ||
				  !match_regex(argv[i + 1], "^(((([0-9]+,)?([0-9]+x[0-9]+)|([0-9]+x[0-9]+-[0-9]+x[0-9]+(\\*[0-9]+)?(\\+[1-9][0-9]*)?)),?)+)$") ) ) ) {
				fprintf(stderr, "Failed to parse --drag options: %s\n", argv[i + 1]);
				exit(-1);
			}
			inputEvents[inputEventsIndex++] = i;

			if (++i >= argc)
				usage(argv[0]);
			continue;
		}

		if (streq("-k", argv[i]) || streq("--key", argv[i])) {
			if (!xemu.keyboard.dev) {
				fprintf(stderr, "Failed to open keyboard device, unable to simulate keyboard events.\n");
				exit(-1);
			}
			if (inputEventsIndex == ASIZE(inputEvents)) {
				fprintf(stderr, "Too many input events specified\n");
				exit(-1);
			}
			inputEvents[inputEventsIndex++] = i;
			if (++i >= argc)
				usage(argv[0]);

			continue;
		}

		if (streq("-t", argv[i]) || streq("--type", argv[i])) {
			if (!xemu.keyboard.dev) {
				fprintf(stderr, "Failed to open keyboard device, unable to simulate keyboard events.\n");
				exit(-1);
			}
			if (inputEventsIndex == ASIZE(inputEvents)) {
				fprintf(stderr, "Too many input events specified\n");
				exit(-1);
			}
			inputEvents[inputEventsIndex++] = i;
			if (++i >= argc)
				usage(argv[0]);

			if (!keysymMappingInitialized) {
				xemu_load_keycodes();
				keysymMappingInitialized = True;
			}

			continue;
		}

		/* since moving from command sequence approach the inspect parameter is deprecated */
		if (streq("-i", argv[i]) || streq("--inspect", argv[i])) {
			if (verbose)
				report_add_message(REPORT_LAST_TIMESTAMP, "Just displaying damage events until timeout\n");
			continue;
		}

		/* */
		if (streq("-u", argv[i]) || streq("--user", argv[i]) ||
				(xrecord.motion = (streq("-U", argv[i]) || streq("--user-all", argv[i])) ) ) {
			xinput_init(xhandler.display);
			if (verbose)
				report_add_message(REPORT_LAST_TIMESTAMP, "Reporting user input events\n");

			continue;
		}

		if (streq(argv[i], "-r") || streq(argv[i], "--response")) {
			if (++i >= argc)
				usage(argv[0]);
			char option[500];
			cnt = sscanf(argv[i], "%u,%s", &response.timeout, option);
			if (cnt < 1) {
				fprintf(stderr, "*** invalid response timeout value '%s'\n", argv[i]);
				usage(argv[0]);
			}
			if (cnt < 2) {
				report_set_silent(true);
			} else {
				if (strcmp(option, "verbose")) {
					fprintf(stderr, "*** invalid response option '%s'\n", argv[i]);
					usage(argv[0]);
				}
			}
			application_monitor_screen();
			xinput_init(xhandler.display);
			if (verbose)
				report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring application response time\n");

			continue;
		}

		fprintf(stderr, "*** Dont understand  %s\n", argv[i]);
		usage(argv[0]);
	}

	/* start monitoring the root window if no targets are specified */
	if ((window_empty() && application_empty()) || response.timeout) {
		application_monitor(ROOT_WINDOW_RESOURCE);
	}

	window_monitor_all();
	application_start_monitor();

	/* eat first damage event when options.break_on_damage set */
	if (options.break_on_damage)
		xhandler_eat_damage();

	/* monitor the whole screen of no area is specified */
	if (!options.interested_damage_rect.width && !options.interested_damage_rect.height && !options.interested_damage_rect.x
			&& !options.interested_damage_rect.y) {
		options.interested_damage_rect.x = 0;
		options.interested_damage_rect.y = 0;
		options.interested_damage_rect.width = DisplayWidth(xhandler.display, DefaultScreen(xhandler.display));
		options.interested_damage_rect.height = DisplayHeight(xhandler.display, DefaultScreen(xhandler.display));
	}

	/* emulate user input */

	for (iEvent = 0; iEvent < inputEventsIndex; iEvent++) {
		i = inputEvents[iEvent];

		if (!strcmp("-c", argv[i]) || !strcmp("--click", argv[i])) {
			unsigned long delay = 0;
			Time start = 0;
			cnt = sscanf(argv[++i], "%ux%u,%lu", &x, &y, &delay);
			if (cnt == 2) {
				start = xhandler_get_server_time();
				report_add_message(start, "Using no delay between press/release\n");
				delay = 0;
			} else if (cnt != 3) {
				fprintf(stderr, "cnt: %d\n", cnt);
				fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
				usage(argv[0]);
			}
			/* Send the event */
			start = xemu_button_event(x, y, delay);
			report_add_message(start, "Clicked %ix%i\n", x, y);

			continue;
		}

		if (!strcmp("-d", argv[i]) || !strcmp("--drag", argv[i])) {
			Time drag_time;
			char *s = NULL, *p = NULL;
			int button_state = XR_BUTTON_STATE_PRESS;

			s = p = argv[++i];
			int delay = DEFAULT_DRAG_DELAY;
			int x1, y1, x2, y2;
			while (p) {
				p = strchr(s, ',');
				if (p) {
					*p++ = '\0';
				}
				int count = DEFAULT_DRAG_COUNT;
				cnt = sscanf(s, "%ix%i-%ix%i*%i+%i", &x1, &y1, &x2, &y2, &delay, &count);
				if (cnt >= 4) {
					drag_time = xemu_drag_event(x1, y1, button_state, delay);
					button_state = XR_BUTTON_STATE_NONE;
					report_add_message(drag_time, "Dragged to %ix%i\n", x1, y1);

					int xdev = (x2 - x1) / (count + 1);
					int ydev = (y2 - y1) / (count + 1);
					for (i = 1; i <= count; i++) {
						x = x1 + xdev * i;
						y = y1 + ydev * i;
						drag_time = xemu_drag_event(x, y, button_state, delay);
						report_add_message(drag_time, "Dragged to %ix%i\n", x, y);
					}
					if (!p) button_state = XR_BUTTON_STATE_RELEASE;
					drag_time = xemu_drag_event(x2, y2, button_state, delay);
					report_add_message(drag_time, "Dragged to %ix%i\n", x2, y2);
				}
				else if (cnt == 2) {
					/* Send the event */
					if (!p) {
						if (button_state == XR_BUTTON_STATE_PRESS) {
							fprintf(stderr, "*** Need at least 2 drag points!\n");
							usage(argv[0]);
						}
						button_state = XR_BUTTON_STATE_RELEASE;
					}
					drag_time = xemu_drag_event(x1, y1, button_state, delay);
					report_add_message(drag_time, "Dragged to %ix%i\n", x1, y1);

					/* Make sure button state set to none after first point */
					button_state = XR_BUTTON_STATE_NONE;

					/* reset the delay to default value */
					delay = DEFAULT_DRAG_DELAY;
				} else if (cnt == 1) {
					delay = x1;
				} else {
					fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
					usage(argv[0]);
				}
				s = p;
			}
			continue;
		}

		if (!strcmp("-k", argv[i]) || !strcmp("--key", argv[i])) {
			char *key = NULL;
			char separator;
			unsigned long delay = 0;
			Time start = 0;

			cnt = sscanf(argv[++i], "%a[^,]%c%lu", &key, &separator, &delay);
			if (cnt == 1) {
				report_add_message(REPORT_LAST_TIMESTAMP, "Using default delay between press/release\n", delay);
				delay = DEFAULT_KEY_DELAY;
			} else if (cnt != 3 || separator != ',') {
				fprintf(stderr, "cnt: %d\n", cnt);
				fprintf(stderr, "*** failed to parse '%s'\n", argv[i]);
				if (key != NULL)
					free(key);
				usage(argv[0]);
			}
			start = xemu_send_key(key, delay);
			report_add_message(start, "Simulating keypress/-release pair (keycode '%s')\n", key);
			free(key);

			continue;
		}

		if (!strcmp("-t", argv[i]) || !strcmp("--type", argv[i])) {
			Time start = xemu_send_string(argv[++i]);
			report_add_message(start, "Simulated keys for '%s'\n", argv[i]);

			continue;
		}

	}

	/* setting the default wait period */
	if (options.damage_wait_secs < 0) {
		options.damage_wait_secs = 5;
	}

	signal(SIGINT, abort_wait);
	/* wait for damage events */
	rc = wait_response();

	scheduler_fini();

	report_flush_queue();
	report_fini();
	xinput_fini();
	xemu_fini();

	window_fini();
	application_fini();

	xhandler_fini();


	return rc;
}