コード例 #1
0
ファイル: installer.c プロジェクト: mcuee/libusb-win32
// Query parent app for device ID
char* req_id(enum installer_code id_code)
{
	int size;
	char* id_text[3] = {"device_id", "hardware_id", "user_sid"};
	static char device_id[MAX_PATH_LENGTH];
	static char hardware_id[MAX_PATH_LENGTH];
	static char user_sid[MAX_PATH_LENGTH];
	char* id = NULL;

	switch(id_code) {
	case IC_GET_DEVICE_ID:
		id = device_id;
		break;
	case IC_GET_HARDWARE_ID:
		id = hardware_id;
		break;
	case IC_GET_USER_SID:
		id = user_sid;
		break;
	default:
		plog("req_id: unknown ID requested");
		return NULL;
	}

	memset(id, 0, MAX_PATH_LENGTH);
	size = request_data(id_code, (void*)id, MAX_PATH_LENGTH);
	if (size > 0) {
		plog("got %s: '%s'", id_text[id_code-IC_GET_DEVICE_ID], id);
		return (id[0] != 0)?id:NULL;
	}

	plog("failed to read %s", id_text[id_code-IC_GET_DEVICE_ID]);
	return NULL;
}
コード例 #2
0
ファイル: simple-request.cpp プロジェクト: kiik/kweb
void loop() {
  HTTP::process();

  if(millis() > request_time) {
    request_data();
    request_time = millis() + request_period;
  }
}
コード例 #3
0
bool Nunchuk::update() {
  delay(1);
  Wire.requestFrom(NUNCHUK_DEVICE_ID, NUNCHUK_BUFFER_SIZE);
  int byte_counter = 0;
  while (Wire.available() && byte_counter < NUNCHUK_BUFFER_SIZE)
    _buffer[byte_counter++] = decode_byte(Wire.read());
  request_data();
  return byte_counter == NUNCHUK_BUFFER_SIZE;
}
コード例 #4
0
ファイル: ds3ps2drv.c プロジェクト: xerpi/ds3ps2drv
static void config_set(int result, int count, void *arg)
{
    int slot = (int)arg;
    //Set operational
    ds3_set_operational(slot);
    //Set LED
    ds3ps2_set_led(slot, slot+1);
    ds3ps2_send_ledsrumble(slot);
    //Start reading!
    request_data(0, 0, (void *)slot);
}
コード例 #5
0
uint8_t NUNCHUCK::retreive_data(){
	
	Wire.requestFrom(NUNADDRESS, 6);
	
	uint8_t index = 0;
	
	while(Wire.available()){
		nunDataArr[index] = decode_data(Wire.read());
		index++;
	}
	
	
	
	request_data();
	
	if(nunDataArr[5] != NULL){
		return 1;
	} else {
		return 0;
	}
	
	
}
コード例 #6
0
ファイル: capture.c プロジェクト: Araneidae/fa-archiver
/* Captures requested data from archiver and saves to file. */
int main(int argc, char **argv)
{
    char *server = getenv("FA_ARCHIVE_SERVER");
    if (server != NULL)
        server_name = server;

    output_file = stdout;
    FILE *stream;
    bool ok =
        parse_args(argc, argv)  &&
        validate_args()  &&

        connect_server(&stream)  &&
        IF_(output_filename != NULL,
            TEST_NULL_(
                output_file = fopen(output_filename, "w"),
                "Unable to open output file \"%s\"", output_filename))  &&
        request_data(stream)  &&
        check_response(stream)  &&

        initialise_signal()  &&
        capture_and_save(stream);
    return ok ? 0 : 1;
}
コード例 #7
0
ファイル: dump_manager.c プロジェクト: jionfull/record4cir
static void dump_data(struct dump_manager *manager, int section) {
	char buffer[256];
	char buffer1[256];
	FILE * file = NULL;
	struct dump* pdump = NULL;
	struct block * pblock = NULL;
	int i;
	int ack = 0;
	struct record_manager * record_manager = get_record_manager();
	struct block_filter * filter = manager->manager.fliters;
	if (section < 0 || section > 2)
		return;
	sprintf(buffer, "%s/%s/", MOUNT_POINT, manager->ID);

	if (mk_dir(buffer) == 0) {
		struct tm *tNow;
		tNow=&(manager->time_export);
		sprintf(buffer1, "%s/%04d-%02d-%02d %02d,%02d,%02d/",buffer, tNow->tm_year+1900, tNow->tm_mon+1, tNow->tm_mday, tNow->tm_hour, tNow->tm_min, tNow->tm_sec);
		if (mk_dir(buffer1) == 0) {

			switch (section) {
						case 0:
							sprintf(buffer, "%s/Menu.bin", buffer1);
							break;
						case 1:
							sprintf(buffer, "%s/Data.bin", buffer1);
							break;
						case 2:
							sprintf(buffer, "%s/Wave.bin", buffer1);
							break;
						}
		} else {
			switch (section) {
			case 0:
				sprintf(buffer, "%s/%s/Menu.bin", MOUNT_POINT, manager->ID);
				break;
			case 1:
				sprintf(buffer, "%s/%s/Data.bin", MOUNT_POINT, manager->ID);
				break;
			case 2:
				sprintf(buffer, "%s/%s/Wave.bin", MOUNT_POINT, manager->ID);
				break;
			}
		}

	} else {
		switch (section) {
		case 0:
			sprintf(buffer, "%s/Menu.bin", MOUNT_POINT);
			break;
		case 1:
			sprintf(buffer, "%s/Data.bin", MOUNT_POINT);
			break;
		case 2:
			sprintf(buffer, "%s/Wave.bin", MOUNT_POINT);
			break;
		}
	}

	for (i = 0; i < 3; i++) { //尝试3次
		request_data(record_manager, section, (char*) manager,
				sizeof(struct dump_manager));
		pblock = get_block(filter, 1000, BLOCK_FULL);
		if (pblock != NULL) {
			pdump = (struct dump*) pblock->data;
			if (pdump->type == section * 3) {
				ack = 1;
				put_block(pblock, BLOCK_EMPTY);
				break;
			} else {
				printf("ack type%d!\n", (char) pdump->type);
			}
			put_block(pblock, BLOCK_EMPTY);
		} else {
			printf("ack err%d!\n", i);
		}

	}
	if (ack == 0) {
		printf("ack err!\n");
		return;
	}

	file = fopen(buffer, "w+");

	if (file == NULL)
		return;
	while (1) {
		pblock = get_block(filter, 1000, BLOCK_FULL);
		if (pblock != NULL) {
			pdump = (struct dump*) pblock->data;
			if (pdump->type == (section * 3 + 2)) { //finished
				put_block(pblock, BLOCK_EMPTY);
				break;
			} else if (pdump->type == (section * 3 + 1)) {

				fwrite(pdump->data, pdump->length, 1, file);
				fflush(file);
			}
			put_block(pblock, BLOCK_EMPTY);
		} else {
			//printf("dump is null\n");
		}
	}

	fclose(file);

}
コード例 #8
0
ファイル: ds3ps2drv.c プロジェクト: xerpi/ds3ps2drv
static void request_data_cb(int result, int count, void *arg)
{
    int slot = (int)arg;
    correct_data(&gamepad[slot]);
    request_data(0, 0, (void *)slot);
}