Пример #1
0
int main()
{
	signal(SIGINT, sig_handler);
	int ret;
	DMSG((STDOUT,"LASER scan TEST start.\r\n"));
	ret = sj_create(&job);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST config.\r\n"));

	//ret = sj_config(job, 50, 180, 360, 5, 0.5, -45, 0);
	//ret = sj_config(job, 50, 0, 360, 5, 0.125, 0, 90);
	ret = sj_config(job, 50, 0, 360, 5, 0.25, -45, 90);
	//ret = sj_config(job, 50, 0, 90, 5, 0.5, -45, -20);
//	ret = sj_config(job, 50, 160, 200, 5, 0.5, -45, 90);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST start.\r\n"));
	ret = sj_start(job);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST start.\r\n"));
	ret = sj_wait(job);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST PASSED.\r\n"));
	sj_destroy(job);
}
Пример #2
0
/*
 * Class:     com_hd_scan_SickLD
 * Method:    main
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_com_hd_scan_SickLD_main
(JNIEnv *env, jclass clazz)
{
	int ret;
	scan_job job;
	DMSG((STDOUT,"LASER scan TEST start.\r\n"));
	ret = sj_create(&job);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST config.\r\n"));

	//ret = sj_config(job, 50, 180, 360, 5, 0.5, -45, 0);
	//ret = sj_config(job, 50, 0, 360, 5, 0.5, 0, 90);//???频繁出现取数据错误?sick 3030
	ret = sj_config(job, 50, 0, 360, 5, 0.25, -45, 90);
	//ret = sj_config(job, 50, 0, 90, 5, 0.5, -45, -20);
	//ret = sj_config(job, 50, 160, 200, 5, 0.5, -45, 90);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST start.\r\n"));
	ret = sj_start(job);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST start.\r\n"));
	ret = sj_wait(job);
	e_assert(ret>0, ret);

	DMSG((STDOUT,"LASER scan TEST PASSED.\r\n"));
	sj_destroy(job);
	return ret;
}
Пример #3
0
/*
 * Class:     com_hd_internal_Scan
 * Method:    sj_create
 * Signature: (J)I
 */
JNIEXPORT jlong JNICALL Java_com_hd_internal_Scan_sj_1create__J
(JNIEnv *env, jclass clazz) {
	int ret;
	struct scan_job_t* ptr;
	ret = sj_create(&ptr);
	e_assert(ret>0, 0);
	return (jlong) ptr;
}
Пример #4
0
/*
 * Class:     com_hd_internal_Scan
 * Method:    sj_create
 * Signature: (JLjava/lang/String;I)J
 */
JNIEXPORT jlong JNICALL Java_com_hd_internal_ScanWork_sj_1create
(JNIEnv *env, jclass clazz, jstring jsdev, jint baud, jstring jsip, jint port) {
	int ret;
	char *ip,*dev;
	struct scan_job_t* ptr;
	ip = (*env)->GetStringUTFChars(env, jsip, 0);
	dev = (*env)->GetStringUTFChars(env, jsdev, 0);
	ret = sj_create(&ptr, dev,baud,ip, port);
	(*env)->ReleaseStringUTFChars(env, jsip, ip);
	(*env)->ReleaseStringUTFChars(env, jsdev, dev);
	e_assert(ret>0, 0);
	return (jlong) ptr;
}
Пример #5
0
int on_command(const char *cmd, char *ret_buf, int *ctx,
		int log_printf(char *buf, int *ctx, int code, char *fmt, ...)) {
	int ret = 1;
	//command select

	signal(SIGINT, sig_handler);

	if (!strncmp(cmd, "get", 3)) {
		const char *scmd = get_sub_command(cmd);
		if (!strcmp(scmd, "author")) {
			log_printf(ret_buf, ctx, ret, "uplusplus");
		} else if (!strcmp(scmd, "version")) {
			log_printf(ret_buf, ctx, ret, "1.0.0");
		} else {
			log_printf(ret_buf, ctx, 0, "unknown command: <b>%s</b>", cmd);
			ret = 0;
			goto end;
		}
	} else if (!strncmp(cmd, "connect", sizeof("connect"))) {
		if (job != NULL) {
			log_printf(ret_buf, ctx, 0, "Laser already connect..");
			return 0;
		}
		log_printf(ret_buf, ctx, ret, "Laser try create..");
		ret = sj_create(&job, NULL, NULL, NULL, NULL);
		if (e_failed(ret)) {
			log_printf(ret_buf, ctx, ret, "Laser scan create failed.");
		} else {
			log_printf(ret_buf, ctx, ret, "Laser create successfull.");
		}
	} else if (!strncmp(cmd, "disconnect", sizeof("disconnect"))) {
		if (job == NULL) {
			log_printf(ret_buf, ctx, 0, "Laser already disconnect..");
			return 0;
		}
		log_printf(ret_buf, ctx, ret, "Laser try disconnect..");
		ret = sj_destroy(job);
		if (e_failed(ret)) {
			log_printf(ret_buf, ctx, ret, "Laser scan disconnect failed.");
		} else {
			log_printf(ret_buf, ctx, ret, "Laser disconnect successfull.");
		}
		job = NULL;
	} else if (!strncmp(cmd, "config", sizeof("config"))) {
		log_printf(ret_buf, ctx, ret, "Laser scan try config..");
		sj_set_data_dir(job, "/sdcard/ls300/data/point_cloud",
				"/sdcard/ls300/data/image");
		ret = sj_config(job, 100, 0, 360, 5, 0.25, -45, 90);
		if (e_failed(ret)) {
			log_printf(ret_buf, ctx, ret,
					"Laser scan config failed.device busy.");
		} else {
			log_printf(ret_buf, ctx, ret, "Laser scan config successfull.");
		}
	} else if (!strncmp(cmd, "pointscan", sizeof("pointscan"))) {
		log_printf(ret_buf, ctx, ret, "Laser scan try start..");
		ret = sj_scan_point(job);
		if (e_failed(ret)) {
			log_printf(ret_buf, ctx, ret,
					"Laser scan start scan point cloud failed.device busy.");
		}
	} else if (!strncmp(cmd, "photoscan", sizeof("photoscan"))) {
		log_printf(ret_buf, ctx, ret, "Laser photo scan try start..");
		ret = sj_scan_photo(job);
		if (e_failed(ret)) {
			log_printf(ret_buf, ctx, ret,
					"Laser scan start scan photo failed.device busy.");
		}
	} else if (!strncmp(cmd, "cancel", sizeof("cancel"))) {
		log_printf(ret_buf, ctx, ret, "Laser scan try stop..");
		ret = sj_cancel(job);
		if (e_failed(ret)) {
			log_printf(ret_buf, ctx, ret, "Laser scan stop failed.");
		}
	} else {
		log_printf(ret_buf, ctx, 0, "unknown command: <b>%s</b>", cmd);
		ret = 0;
		goto end;
	}

	end: return ret;
}