mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Adjustments to the read timeouts
This commit is contained in:
parent
937e834698
commit
15f01a53a1
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,3 +23,4 @@ patched
|
||||
wiped
|
||||
msg_gen
|
||||
srv_gen
|
||||
*sublime-workspace
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
{
|
||||
"word_wrap": "on",
|
||||
"wrap_width": 80,
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
|
||||
@ -1,531 +0,0 @@
|
||||
{
|
||||
"auto_complete":
|
||||
{
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"tour",
|
||||
"toupper(int _c) int"
|
||||
],
|
||||
[
|
||||
"rotat",
|
||||
"SceneObject::rotateTo(GLfloat roll, GLfloat pitch, GLfloat yaw) void"
|
||||
],
|
||||
[
|
||||
"tou",
|
||||
"touring_index size_t"
|
||||
],
|
||||
[
|
||||
"person",
|
||||
"person_mbb Model::CollisionBox"
|
||||
],
|
||||
[
|
||||
"SE",
|
||||
"SE Model::CollisionBox"
|
||||
],
|
||||
[
|
||||
"m",
|
||||
"mbb Model::CollisionBox"
|
||||
],
|
||||
[
|
||||
"glVer",
|
||||
"glVertex2fv(const GLfloat *v) void"
|
||||
],
|
||||
[
|
||||
"di",
|
||||
"distance GLfloat"
|
||||
],
|
||||
[
|
||||
"the",
|
||||
"their_position GLfloat *"
|
||||
],
|
||||
[
|
||||
"their",
|
||||
"their_obj_it vector<Model::Object>::iterator"
|
||||
],
|
||||
[
|
||||
"my",
|
||||
"my_obj_it vector<Model::Object>::iterator"
|
||||
],
|
||||
[
|
||||
"my_mod",
|
||||
"my_model_it vector<Model>::iterator"
|
||||
],
|
||||
[
|
||||
"thei",
|
||||
"their_model_it vector<Model>::iterator"
|
||||
],
|
||||
[
|
||||
"iterator",
|
||||
"assign(_InputIterator __first, _InputIterator __last) void"
|
||||
],
|
||||
[
|
||||
"get",
|
||||
"getPosition() GLfloat *"
|
||||
],
|
||||
[
|
||||
"lh",
|
||||
"lhs_mbb Model::CollisionBox"
|
||||
],
|
||||
[
|
||||
"cal",
|
||||
"calculateMBB(Model::Object &obj) Model::CollisionBox"
|
||||
],
|
||||
[
|
||||
"Col",
|
||||
"CollisionBox "
|
||||
],
|
||||
[
|
||||
"spo",
|
||||
"spotlight LightingStyle"
|
||||
],
|
||||
[
|
||||
"main",
|
||||
"main_camera Camera"
|
||||
],
|
||||
[
|
||||
"pers",
|
||||
"person Person *"
|
||||
],
|
||||
[
|
||||
"glro",
|
||||
"glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) void"
|
||||
],
|
||||
[
|
||||
"glTran",
|
||||
"glTranslatef(GLfloat x, GLfloat y, GLfloat z) void"
|
||||
],
|
||||
[
|
||||
"she",
|
||||
"shelby_model string"
|
||||
],
|
||||
[
|
||||
"loa",
|
||||
"loaded_ bool"
|
||||
],
|
||||
[
|
||||
"ena",
|
||||
"enabled_ bool"
|
||||
],
|
||||
[
|
||||
"sp",
|
||||
"specular(GLfloat r, GLfloat g, GLfloat b, GLfloat a) void"
|
||||
],
|
||||
[
|
||||
"en",
|
||||
"direction(GLfloat x, GLfloat y, GLfloat z) void"
|
||||
],
|
||||
[
|
||||
"spot",
|
||||
"spot_light Light"
|
||||
],
|
||||
[
|
||||
"GL_NOR",
|
||||
"GL_NORMALIZE "
|
||||
],
|
||||
[
|
||||
"att",
|
||||
"attenuation_q_ GLfloat"
|
||||
],
|
||||
[
|
||||
"atte",
|
||||
"attenuation_c_ GLfloat"
|
||||
],
|
||||
[
|
||||
"glPop",
|
||||
"glPopMatrix() void"
|
||||
],
|
||||
[
|
||||
"appl",
|
||||
"apply_() void"
|
||||
],
|
||||
[
|
||||
"no_l",
|
||||
"no_lights_left const size_t"
|
||||
],
|
||||
[
|
||||
"ligh",
|
||||
"lights_left size_t"
|
||||
],
|
||||
[
|
||||
"do",
|
||||
"do_normals bool"
|
||||
],
|
||||
[
|
||||
"back_in",
|
||||
"back_inserter(_Container &__x) back_insert_iterator<_Container>"
|
||||
],
|
||||
[
|
||||
"istr",
|
||||
"istream_iterator<typename _Tp> "
|
||||
],
|
||||
[
|
||||
"is",
|
||||
"istringstream "
|
||||
],
|
||||
[
|
||||
"math",
|
||||
"matches size_t"
|
||||
],
|
||||
[
|
||||
"curr",
|
||||
"current_object Model::Object"
|
||||
],
|
||||
[
|
||||
"matc",
|
||||
"matches2 size_t"
|
||||
],
|
||||
[
|
||||
"QwtPlot",
|
||||
"QwtPlotZoomer"
|
||||
],
|
||||
[
|
||||
"__init",
|
||||
"__initZooming"
|
||||
],
|
||||
[
|
||||
"plot_coi",
|
||||
"plot_coil2"
|
||||
],
|
||||
[
|
||||
"plo",
|
||||
"plot_coil1"
|
||||
],
|
||||
[
|
||||
"plot_co",
|
||||
"plot_coil2"
|
||||
],
|
||||
[
|
||||
"QwtPl",
|
||||
"QwtPlotCurve"
|
||||
],
|
||||
[
|
||||
"trail",
|
||||
"trailer_plotcurve"
|
||||
],
|
||||
[
|
||||
"pl",
|
||||
"plot_coil1"
|
||||
],
|
||||
[
|
||||
"plot",
|
||||
"plot_coil1"
|
||||
],
|
||||
[
|
||||
"open",
|
||||
"open_button"
|
||||
],
|
||||
[
|
||||
"plotcoi",
|
||||
"plot_coil1"
|
||||
],
|
||||
[
|
||||
"EM",
|
||||
"EM61MK2Log"
|
||||
],
|
||||
[
|
||||
"pa",
|
||||
"path_file_name"
|
||||
],
|
||||
[
|
||||
"head",
|
||||
"headings"
|
||||
],
|
||||
[
|
||||
"eas",
|
||||
"eastings"
|
||||
],
|
||||
[
|
||||
"north",
|
||||
"northings"
|
||||
],
|
||||
[
|
||||
"las",
|
||||
"last_east"
|
||||
],
|
||||
[
|
||||
"odom",
|
||||
"odom"
|
||||
],
|
||||
[
|
||||
"logs",
|
||||
"logs_data"
|
||||
],
|
||||
[
|
||||
"plot_",
|
||||
"plot_em61mk2logs"
|
||||
],
|
||||
[
|
||||
"Em61",
|
||||
"EM61MK2Log"
|
||||
],
|
||||
[
|
||||
"sib",
|
||||
"sibling_file_name"
|
||||
],
|
||||
[
|
||||
"si",
|
||||
"sibling_file_name"
|
||||
],
|
||||
[
|
||||
"fil",
|
||||
"file_name"
|
||||
]
|
||||
]
|
||||
},
|
||||
"buffers":
|
||||
[
|
||||
],
|
||||
"build_system": "Packages/Makefile/Make.sublime-build",
|
||||
"command_palette":
|
||||
{
|
||||
"height": 47.0,
|
||||
"selected_items":
|
||||
[
|
||||
[
|
||||
"install",
|
||||
"Package Control: Install Package"
|
||||
],
|
||||
[
|
||||
"late",
|
||||
"LaTeXTools: View PDF"
|
||||
]
|
||||
],
|
||||
"width": 449.0
|
||||
},
|
||||
"console":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"distraction_free":
|
||||
{
|
||||
"menu_visible": true,
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": false,
|
||||
"side_bar_visible": false,
|
||||
"status_bar_visible": false
|
||||
},
|
||||
"file_history":
|
||||
[
|
||||
"/Users/william/devel/serial/src/serial.cc",
|
||||
"/Users/william/devel/serial/src/impl/unix.cc",
|
||||
"/Users/william/devel/serial/include/serial/serial.h",
|
||||
"/Users/william/devel/serial/CMakeLists.txt",
|
||||
"/Users/william/devel/serial/serial.sublime-project",
|
||||
"/Users/william/Library/Application Support/Sublime Text 2/Packages/SublimeClang/SublimeClang.sublime-settings",
|
||||
"/Users/william/Library/Application Support/Sublime Text 2/Packages/SublimeClang/Default.sublime-keymap",
|
||||
"/Users/william/Library/Application Support/Sublime Text 2/Packages/User/SublimeClang.sublime-settings",
|
||||
"/Users/william/devel/automow_ws/au_automow_common/automow_planning/tests/test_path_planner.py",
|
||||
"/Users/william/devel/automow_ws/au_automow_common/automow_planning/tests/test_coverage_planner.py",
|
||||
"/Users/william/devel/automow_ws/au_automow_common/automow_planning/tests/test_costmap.py",
|
||||
"/Users/william/devel/automow_ws/au_automow_common/automow_planning/tests/survey.csv",
|
||||
"/Users/william/devel/automow_ws/au_automow_common/automow_planning/tests/image_generator.py",
|
||||
"/Users/william/.ros/rosdep.yaml",
|
||||
"/Users/william/.bashrc",
|
||||
"/Users/william/devel/xbow400/include/xbow_400.h",
|
||||
"/Users/william/devel/xbow400/src/xbow_400.cpp",
|
||||
"/Users/william/devel/xbow400/README",
|
||||
"/Users/william/devel/xbow400/xbow400.sublime-project",
|
||||
"/Users/william/devel/comp6400/homework6/homework6.sublime-project",
|
||||
"/Users/william/devel/comp6400/homework6/src/main.cc",
|
||||
"/Users/william/devel/comp6400/homework6/models/student.obj",
|
||||
"/Users/william/devel/comp6400/homework6/models/ground.obj",
|
||||
"/Users/william/devel/comp6400/homework6/models/shelby.obj",
|
||||
"/Users/william/devel/comp6400/homework6/models/ground.mtl",
|
||||
"/Users/william/devel/comp6400/homework6/models/shelby.mtl",
|
||||
"/Users/william/devel/comp6400/homework6/CMakeLists.txt",
|
||||
"/Users/william/devel/comp6400/homework6/models/shelby.blend",
|
||||
"/Users/william/devel/comp6400/homework6/Makefile",
|
||||
"/usr/include/c++/4.2.1/tr1/cstdio",
|
||||
"/Users/william/devel/comp6400/homework6/src/michaels.cc",
|
||||
"/Users/william/devel/auxos_orig/scripts/plot_em.py",
|
||||
"/Users/william/devel/auxos_orig/scripts/logtool.py",
|
||||
"/Users/william/devel/auxos_orig/scripts/em61mk2.py",
|
||||
"/Users/william/devel/auxos_orig/scripts/lib/__init__.py",
|
||||
"/usr/local/Library/Formula/pyqt.rb",
|
||||
"/usr/local/Library/Formula/pyqwt.rb",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/redo_slam_offline/launch/play_and_remap_tf.launch",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/misc_scripts/launch/automow_stuff.launch",
|
||||
"/Users/william/devel/auxos_orig/scripts/coords2path.py",
|
||||
"/Users/william/Downloads/sup1_waypts_utm_path.txt",
|
||||
"/Users/william/Downloads/example.txt",
|
||||
"/Users/william/devel/auxos_orig/scripts/sup1_waypts_utm_path.txt",
|
||||
"/Users/william/devel/ion_plans_paper/citations.bib",
|
||||
"/Users/william/devel/ion_plans_paper/ion_plans.tex",
|
||||
"/Users/william/Desktop/em61mk2.py",
|
||||
"/Users/william/devel/ion_plans_paper/ion_plans.log",
|
||||
"/Users/william/devel/ion_plans_paper/ion_plans.pdf",
|
||||
"/Users/william/devel/3dteleop_ws/octomap/octomap/include/octomap/OcTree.h",
|
||||
"/Users/william/devel/3dteleop_ws/octomap/octomap/include/octomap/OccupancyOcTreeBase.h",
|
||||
"/Users/william/devel/3dteleop_ws/octomap/octomap/include/octomap/OccupancyOcTreeBase.hxx",
|
||||
"/Users/william/devel/3dteleop_ws/octomap/octomap/src/OcTree.cpp",
|
||||
"/Users/william/devel/3dteleop_ws/octomap/octomap/include/octomap/octomap_deprecated.h",
|
||||
"/Users/william/devel/3dteleop_ws/octomap/CMakeLists.txt",
|
||||
"/Users/william/devel/comp6400/homework3/src/main.cc",
|
||||
"/Users/william/Desktop/untitled.obj",
|
||||
"/Users/william/devel/cs373-tests/util.py",
|
||||
"/Users/william/devel/cs373-tests/2.6/code.py",
|
||||
"/Users/william/devel/cs373-tests/2.6/template.py",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/misc_scripts/manifest.xml",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/misc_scripts/nodes/odom2tf.py",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/misc_scripts/nodes/automow_laser_filter.py",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/misc_scripts/nodes/rename_tf_frame.py",
|
||||
"/Users/william/devel/3dteleop_ws/3d_teleop/misc_scripts/nodes/remap_tf.py",
|
||||
"/Users/william/Downloads/orocos_kinematics_dynamics-ffdeaad-install_name_tool.patch",
|
||||
"/Users/william/devel/automow_ws/au_automow_common/automow_bringup/launch/minimal.launch",
|
||||
"/Users/william/devel/vis_ws/visualization/rviz/manifest.xml",
|
||||
"/Library/Python/2.7/site-packages/pkg_resources.py",
|
||||
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py",
|
||||
"/Volumes/Storage/Data/Camp Sibert/Feb 15 - Feb 20/plot_em61mk2.py",
|
||||
"/Volumes/Storage/Data/Camp Sibert/Feb 15 - Feb 20/em61mk2.py",
|
||||
"/Volumes/Storage/Data/Camp Sibert 2-15to2-20/em61mk2.py",
|
||||
"/Volumes/Storage/Data/Camp Sibert 2-15to2-20/plot_em61mk2.py"
|
||||
],
|
||||
"find":
|
||||
{
|
||||
"height": 35.0
|
||||
},
|
||||
"find_in_files":
|
||||
{
|
||||
"height": 0.0,
|
||||
"where_history":
|
||||
[
|
||||
""
|
||||
]
|
||||
},
|
||||
"find_state":
|
||||
{
|
||||
"case_sensitive": false,
|
||||
"find_history":
|
||||
[
|
||||
"cts",
|
||||
" ",
|
||||
"o ",
|
||||
"Cube_Cube.001",
|
||||
"min[2]",
|
||||
"min[1]",
|
||||
"max[2]",
|
||||
"max[1]",
|
||||
"max[0]",
|
||||
"min[0]",
|
||||
"window_width",
|
||||
"800",
|
||||
"•",
|
||||
"Cube",
|
||||
"expected 1.",
|
||||
"counter",
|
||||
"go",
|
||||
"setZoomerMousePattern",
|
||||
"updateNode",
|
||||
"compute",
|
||||
"insertS"
|
||||
],
|
||||
"highlight": true,
|
||||
"in_selection": false,
|
||||
"preserve_case": false,
|
||||
"regex": false,
|
||||
"replace_history":
|
||||
[
|
||||
", ",
|
||||
"min.z",
|
||||
"min.y",
|
||||
"max.z",
|
||||
"max.y",
|
||||
"max.x",
|
||||
"min.x",
|
||||
"*"
|
||||
],
|
||||
"reverse": false,
|
||||
"show_context": true,
|
||||
"use_buffer2": true,
|
||||
"whole_word": false,
|
||||
"wrap": true
|
||||
},
|
||||
"groups":
|
||||
[
|
||||
{
|
||||
"sheets":
|
||||
[
|
||||
]
|
||||
},
|
||||
{
|
||||
"sheets":
|
||||
[
|
||||
]
|
||||
}
|
||||
],
|
||||
"incremental_find":
|
||||
{
|
||||
"height": 0.0
|
||||
},
|
||||
"input":
|
||||
{
|
||||
"height": 31.0
|
||||
},
|
||||
"layout":
|
||||
{
|
||||
"cells":
|
||||
[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1
|
||||
]
|
||||
],
|
||||
"cols":
|
||||
[
|
||||
0.0,
|
||||
0.766633361467,
|
||||
1.0
|
||||
],
|
||||
"rows":
|
||||
[
|
||||
0.0,
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"menu_visible": true,
|
||||
"output.clang":
|
||||
{
|
||||
"height": 100.0
|
||||
},
|
||||
"output.exec":
|
||||
{
|
||||
"height": 229.0
|
||||
},
|
||||
"replace":
|
||||
{
|
||||
"height": 64.0
|
||||
},
|
||||
"save_all_on_build": true,
|
||||
"select_file":
|
||||
{
|
||||
"height": 0.0,
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"select_project":
|
||||
{
|
||||
"height": 0.0,
|
||||
"selected_items":
|
||||
[
|
||||
],
|
||||
"width": 0.0
|
||||
},
|
||||
"show_minimap": false,
|
||||
"show_open_files": false,
|
||||
"show_tabs": true,
|
||||
"side_bar_visible": true,
|
||||
"side_bar_width": 283.0,
|
||||
"status_bar_visible": true
|
||||
}
|
||||
@ -386,29 +386,33 @@ Serial::SerialImpl::read (unsigned char *buf, size_t size)
|
||||
total_timeout.tv_sec = total_timeout_ms / 1000;
|
||||
total_timeout.tv_usec = static_cast<int>(total_timeout_ms % 1000);
|
||||
total_timeout.tv_usec *= 1000; // To convert to micro seconds
|
||||
// Setup the inter byte timeout
|
||||
struct timeval inter_byte_timeout;
|
||||
inter_byte_timeout.tv_sec = timeout_.inter_byte_timeout / 1000;
|
||||
inter_byte_timeout.tv_usec =
|
||||
static_cast<int> (timeout_.inter_byte_timeout % 1000);
|
||||
inter_byte_timeout.tv_usec *= 1000; // To convert to micro seconds
|
||||
while (bytes_read < size) {
|
||||
// Setup the inter_byte timeout timeval
|
||||
struct timeval timeout; // Inter-byte timeout
|
||||
timeout.tv_sec = timeout_.inter_byte_timeout / 1000;
|
||||
timeout.tv_usec = static_cast<int> (timeout_.inter_byte_timeout % 1000);
|
||||
timeout.tv_usec *= 1000; // To convert to micro seconds
|
||||
// Setup the select timeout timeval
|
||||
struct timeval timeout;
|
||||
// If the total_timeout is less than the inter_byte_timeout
|
||||
if (total_timeout.tv_sec < inter_byte_timeout.tv_sec
|
||||
|| (total_timeout.tv_sec == inter_byte_timeout.tv_sec
|
||||
&& total_timeout.tv_usec < inter_byte_timeout.tv_sec))
|
||||
{
|
||||
// Then set the select timeout to use the total time
|
||||
timeout = total_timeout;
|
||||
} else {
|
||||
// Else set the select timeout to use the inter byte time
|
||||
timeout = inter_byte_timeout;
|
||||
}
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (fd_, &readfds);
|
||||
// Begin timing select
|
||||
struct timespec start, end;
|
||||
get_time_now (start);
|
||||
int r;
|
||||
// If the total_timeout is less than the inter_byte_timeout
|
||||
if (total_timeout.tv_sec < timeout.tv_sec
|
||||
|| (total_timeout.tv_sec == timeout.tv_sec
|
||||
&& total_timeout.tv_usec < timeout.tv_sec))
|
||||
{
|
||||
// Use the total_timeout
|
||||
r = select (fd_ + 1, &readfds, NULL, NULL, &total_timeout);
|
||||
} else {
|
||||
// Else use the inter_byte_timeout
|
||||
r = select (fd_ + 1, &readfds, NULL, NULL, &timeout);
|
||||
}
|
||||
// Call select to block for serial data or a timeout
|
||||
int r = select (fd_ + 1, &readfds, NULL, NULL, &timeout);
|
||||
// Calculate difference and update the structure
|
||||
get_time_now (end);
|
||||
// Calculate the time select took
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user