Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	int version;
	int fd;
	char buf[128];

	api_client_init("192.168.0.103");

	version = uffs_version();
	printf("Version: %08X\n", version);

	fd = uffs_open("/test.txt", UO_RDWR|UO_CREATE);
	if (fd < 0) {
		printf("Can't create /test.txt\n");
		return -1;
	}
	
	sprintf(buf, "Hello, this is test\n");
	if (uffs_write(fd, buf, strlen(buf)) < 0) {
		printf("call uffs_write failed\n");
	}
	else {
		if (uffs_seek(fd, 7, USEEK_SET) != 7) {
			printf("call uffs_seek failed\n");
		}
		else {
			if (uffs_read(fd, buf, 4) != 4) {
				printf("call uffs_read failed\n");
			}
			else {
				if (memcmp(buf, "this", 4) != 0) {
					printf("uffs_read content not matched\n");
				}
				else {
					printf("everything is ok.\n");
				}
			}
		}
	}

	if (uffs_close(fd) < 0) {
		printf("uffs_close failed.\n");
	}

	return 0;
}
int main(int argc, char *argv[])
{
	int interval = 1000;

	if (argc > 2) {
		interval = atoi(argv[2]);
	}

	printf("Host: %s, Interval: %d\n", argv[1], interval);

	if (api_client_init(argv[1]) == 0) {
		while(1) {
			uffs_flush_all("/");
			usleep(interval * 1000);
		}
	}
	else {
		printf("init failed.\n");
	}

	return 0;
}