Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop data transmission in urg3d_open. Add urg3d_high_blocking_stop_data API. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/urg3d_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extern "C" {
*/
extern int urg3d_high_stop_data(urg3d_t * const urg, urg3d_measurement_type_t meas);

/*!
\brief request to stop data

\param[in,out] urg : urg3d session
\param[in] meas : urg3d_measurement_type_t sturct, i.e. meas = URG3D_DISTANCE_INTENSITY

\retval 1 succeeded
\retval 0 nothing happens
*/
extern int urg3d_high_blocking_stop_data(urg3d_t* const urg, urg3d_measurement_type_t meas);


/*!
\brief get "range and intensity" or "range only" user format from revceived data buffer

Expand Down
4 changes: 2 additions & 2 deletions samples/high_1_field_data_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ int main(int argc, char *argv[])
/*
* stop the acquisition flow started earlier using the start acquisition mode.
*/
if((ret = urg3d_high_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_stop_data %d\n", ret);
if((ret = urg3d_high_blocking_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_blocking_stop_data %d\n", ret);
ret = urg3d_close(&urg);
#if defined(URG3D_MSC)
getchar();
Expand Down
4 changes: 2 additions & 2 deletions samples/high_1_frame_4_field_data_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ int main(int argc, char *argv[])
/*
* stop the acquisition flow started earlier using the start acquisition mode.
*/
if((ret = urg3d_high_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_stop_data %d\n", ret);
if((ret = urg3d_high_blocking_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_blocking_stop_data %d\n", ret);
ret = urg3d_close(&urg);
#if defined(URG3D_MSC)
getchar();
Expand Down
4 changes: 2 additions & 2 deletions samples/high_1_frame_4_vfield_2_hfield_data_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ int main(int argc, char *argv[])
/*
* stop the acquisition flow started earlier using the start acquisition mode.
*/
if((ret = urg3d_high_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_stop_data %d\n", ret);
if((ret = urg3d_high_blocking_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_blocking_stop_data %d\n", ret);
ret = urg3d_close(&urg);
#if defined(URG3D_MSC)
getchar();
Expand Down
4 changes: 2 additions & 2 deletions samples/high_1_line_data_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ int main(int argc, char *argv[])
/*
* stop the acquisition flow started earlier using the start acquisition mode.
*/
if((ret = urg3d_high_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_stop_data %d\n", ret);
if((ret = urg3d_high_blocking_stop_data(&urg, URG3D_DISTANCE_INTENSITY)) < 0) {
printf("error urg3d_high_blocking_stop_data %d\n", ret);
ret = urg3d_close(&urg);
#if defined(URG3D_MSC)
getchar();
Expand Down
4 changes: 2 additions & 2 deletions samples/high_get_auxiliary.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ int main(int argc, char *argv[])
}

// stop data stream
if((ret = urg3d_high_stop_data(&urg, URG3D_AUXILIARY)) < 0) {
printf("error urg3d_high_stop_data %d\n", ret);
if((ret = urg3d_high_blocking_stop_data(&urg, URG3D_AUXILIARY)) < 0) {
printf("error urg3d_high_blocking_stop_data %d\n", ret);
ret = urg3d_close(&urg);
#if defined(URG3D_MSC)
getchar();
Expand Down
9 changes: 8 additions & 1 deletion samples/low_get_ax.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int main(int argc, char *argv[])
}
}
} else {
#ifdef URG3D_WINDOWS_OS
#ifdef URG3D_WINDOWS_OS
Sleep(10);
#else
usleep(10000);
Expand Down Expand Up @@ -132,6 +132,13 @@ int main(int argc, char *argv[])
printf("send ok -> DAT:ax=0\n");
}

// wait stop
#ifdef URG3D_WINDOWS_OS
Sleep(1000);
#else
usleep(1000000);
#endif

/*
* close the connection to the sensor
*/
Expand Down
7 changes: 7 additions & 0 deletions samples/low_get_multi_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ int main(int argc, char *argv[])
printf("send ok -> DAT:ax=0\n");
}

// wait stop
#ifdef URG3D_WINDOWS_OS
Sleep(1000);
#else
usleep(1000000);
#endif

/*
* close the connection to the sensor
*/
Expand Down
7 changes: 7 additions & 0 deletions samples/low_get_ri.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ int main(int argc, char *argv[])
printf("send ok -> DAT:ri=0\n");
}

// wait stop
#ifdef URG3D_WINDOWS_OS
Sleep(1000);
#else
usleep(1000000);
#endif

/*
* close the connection to the sensor
*/
Expand Down
7 changes: 7 additions & 0 deletions samples/low_get_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ int main(int argc, char *argv[])
printf("send ok -> DAT:ro=0\n");
}

// wait stop
#ifdef URG3D_WINDOWS_OS
Sleep(1000);
#else
usleep(1000000);
#endif

/*
* close the connection to the sensor
*/
Expand Down
7 changes: 7 additions & 0 deletions samples/low_get_ro_with_error_reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ int main(int argc, char *argv[])
printf("send success -> DAT:ro=0\n");
}

// wait stop
#ifdef URG3D_WINDOWS_OS
Sleep(1000);
#else
usleep(1000000);
#endif

// disconnect sensor
if((ret = urg3d_close(&urg)) < 0) {
printf("error urg3d_close %d\n", ret);
Expand Down
34 changes: 34 additions & 0 deletions src/urg3d_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ int urg3d_open(urg3d_t* const urg
return urg->last_errno;
}

// stop the _ro/_ri data acquisition.
if ((ret = urg3d_high_stop_data(urg, URG3D_DISTANCE_INTENSITY)) < 0) {
urg3d_connection_close(&urg->connection);
urg->last_errno = URG3D_INVALID_RESPONSE;
return urg->last_errno;
}

// stop the _ax data acquisition.
if ((ret = urg3d_high_stop_data(urg, URG3D_AUXILIARY)) < 0) {
urg3d_connection_close(&urg->connection);
urg->last_errno = URG3D_INVALID_RESPONSE;
return urg->last_errno;
}

urg->is_active = URG3D_TRUE;
return 0;
}
Expand Down Expand Up @@ -790,6 +804,26 @@ int urg3d_high_stop_data(urg3d_t* const urg
return urg3d_low_request_command(urg, command_list[meas]);
}

int urg3d_high_blocking_stop_data(urg3d_t* const urg
, urg3d_measurement_type_t meas)
{
urg3d_vssp_header_t header;
char data[URG3D_MAX_RX_LENGTH] = { 0 };
const char command_list[4][10] = { "", "DAT:ro=0\n", "DAT:ri=0\n", "DAT:ax=0\n" };
int ret = 0;

if (meas == URG3D_NO_REQUEST) {
return 0;
}

ret = urg3d_high_blocking_common(urg, &header, data, command_list[meas], "DAT", command_list[meas]);
if (ret < 0) {
return ret;
}

return 1;
}

int urg3d_high_get_measurement_data(urg3d_t * const urg
, urg3d_measurement_data_t *data)
{
Expand Down