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); }
/* * 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; }
/* * Class: com_hd_internal_Scan * Method: sj_config * Signature: (JIDDIDDD)I */ JNIEXPORT jint JNICALL Java_com_hd_internal_Scan_sj_1config (JNIEnv *env, jclass clazz, jlong priv, jint p1, jdouble p2, jdouble p3, jint p4, jdouble p5, jdouble p6, jdouble p7) { int ret; struct scan_job_t* scan = (struct scan_job_t*) priv; e_assert(scan!=NULL, 0); ret = sj_config(scan, p1, p2, p3, p4, p5, p6, p7); e_assert(ret>0, 0); return 1; }
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; }