From: <th...@us...> - 2008-12-28 02:55:23
|
Revision: 7215 http://playerstage.svn.sourceforge.net/playerstage/?rev=7215&view=rev Author: thjc Date: 2008-12-28 01:37:39 +0000 (Sun, 28 Dec 2008) Log Message: ----------- Merge from 2-1 of 7088: fix for memory leak in python bindings for blackboard Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087,7204 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204 /code/player/trunk:6985 Modified: code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i 2008-12-28 01:32:24 UTC (rev 7214) +++ code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i 2008-12-28 01:37:39 UTC (rev 7215) @@ -445,7 +445,7 @@ // Returns a new reference to a dictionary object. PyObject *__convert_blackboard_entry__(player_blackboard_entry_t *entry) { - PyObject *entry_dict, *data; + PyObject *entry_dict, *data, *temp_pystring; char* str; int i; double d; @@ -460,54 +460,79 @@ assert(entry->group); assert(entry->group_count > 0); - ok = PyDict_SetItemString(entry_dict, "key", PyString_FromString(entry->key)); // Steals reference + +temp_pystring = PyString_FromString(entry->key); + ok = PyDict_SetItemString(entry_dict, "key", temp_pystring); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'key'"); Py_XDECREF(entry_dict); + Py_XDECREF(temp_pystring); return NULL; } +Py_XDECREF(temp_pystring); - ok = PyDict_SetItemString(entry_dict, "group", PyString_FromString(entry->group)); // Steals reference + +temp_pystring = PyString_FromString(entry->group); + ok = PyDict_SetItemString(entry_dict, "group", temp_pystring); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'group'"); Py_XDECREF(entry_dict); + Py_XDECREF(temp_pystring); return NULL; } - - ok = PyDict_SetItemString(entry_dict, "type", PyLong_FromLong(entry->type)); // Steals reference +Py_XDECREF(temp_pystring); + + +temp_pystring = PyLong_FromLong(entry->type); + ok = PyDict_SetItemString(entry_dict, "type", temp_pystring); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'type'"); Py_XDECREF(entry_dict); + Py_XDECREF(temp_pystring); return NULL; } +Py_XDECREF(temp_pystring); - ok = PyDict_SetItemString(entry_dict, "subtype", PyLong_FromLong(entry->subtype)); // Steals reference + +temp_pystring = PyLong_FromLong(entry->subtype); + ok = PyDict_SetItemString(entry_dict, "subtype", temp_pystring); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'subtype'"); Py_XDECREF(entry_dict); + Py_XDECREF(temp_pystring); return NULL; } +Py_XDECREF(temp_pystring); - ok = PyDict_SetItemString(entry_dict, "timestamp_sec", PyLong_FromLong(entry->timestamp_sec)); // Steals reference + +temp_pystring = PyLong_FromLong(entry->timestamp_sec); + ok = PyDict_SetItemString(entry_dict, "timestamp_sec", temp_pystring); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'timestamp_sec'"); Py_XDECREF(entry_dict); + Py_XDECREF(temp_pystring); return NULL; } +Py_XDECREF(temp_pystring); - ok = PyDict_SetItemString(entry_dict, "timestamp_usec", PyLong_FromLong(entry->timestamp_usec)); // Steals reference + +temp_pystring = PyLong_FromLong(entry->timestamp_usec); + ok = PyDict_SetItemString(entry_dict, "timestamp_usec", temp_pystring); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'timestamp_usec'"); Py_XDECREF(entry_dict); + Py_XDECREF(temp_pystring); return NULL; } +Py_XDECREF(temp_pystring); + switch(entry->subtype) { case PLAYERC_BLACKBOARD_DATA_SUBTYPE_NONE: @@ -524,6 +549,7 @@ } memcpy(str, entry->data, entry->data_count); data = PyString_FromString(str); + free(str); break; case PLAYERC_BLACKBOARD_DATA_SUBTYPE_INT: assert(entry->type == PLAYERC_BLACKBOARD_DATA_TYPE_SIMPLE); @@ -542,14 +568,16 @@ Py_INCREF(data); break; } - + ok = PyDict_SetItemString(entry_dict, "data", data); // Steals reference if (ok != 0) { PyErr_SetString(PyExc_RuntimeError, "Could not set dictionary value for 'data'"); Py_XDECREF(entry_dict); + Py_XDECREF(data); return NULL; } + Py_XDECREF(data); return entry_dict; } @@ -926,19 +954,17 @@ PyErr_SetString(PyExc_RuntimeError, "Failed to get entry"); return NULL; } + entry_dict = playerc_blackboard___convert_blackboard_entry__(self, entry); // New reference groups_dict = PyTuple_GetItem((PyObject*)self->py_private, DICT_GROUPS_INDEX); // Borrowed reference assert(groups_dict); assert(entry_dict); - Py_INCREF(entry_dict); + //Py_INCREF(entry_dict); playerc_blackboard___set_nested_dictionary_entry__(self, groups_dict, key, group, entry_dict); // Steals reference to entry_dict + + player_blackboard_entry_t_free(entry); - free(entry->key); - free(entry->group); - free(entry->data); - free(entry); - return entry_dict; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-03 02:05:49
|
Revision: 7228 http://playerstage.svn.sourceforge.net/playerstage/?rev=7228&view=rev Author: thjc Date: 2009-01-03 02:05:42 +0000 (Sat, 03 Jan 2009) Log Message: ----------- merge from 2-1 of 7226: fix off by one error in playerv image flipping routine Modified Paths: -------------- code/player/trunk/utils/playerv/pv_dev_camera.c Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226 /code/player/trunk:6985 Modified: code/player/trunk/utils/playerv/pv_dev_camera.c =================================================================== --- code/player/trunk/utils/playerv/pv_dev_camera.c 2009-01-03 02:05:17 UTC (rev 7227) +++ code/player/trunk/utils/playerv/pv_dev_camera.c 2009-01-03 02:05:42 UTC (rev 7228) @@ -1,4 +1,4 @@ -/* +/* * PlayerViewer * Copyright (C) Andrew Howard 2002 * @@ -46,12 +46,12 @@ char section[64]; char label[64]; camera_t *camera; - + camera = malloc(sizeof(camera_t)); camera->datatime = 0; camera->drivername = strdup(drivername); camera->proxy = playerc_camera_create(client, index); - + // Construct the menu snprintf(label, sizeof(label), "camera:%d (%s)", index, camera->drivername); camera->menu = rtk_menu_create_sub(mainwnd->device_menu, label); @@ -64,10 +64,10 @@ // Set the initial menu state rtk_menuitem_check(camera->subscribe_item, subscribe); rtk_menuitem_check(camera->stats_item, 0); - + // Default scale for drawing the image (m/pixel) camera->scale = 0.01; - + // Construct figures camera->image_init = 0; camera->allocated_size = 0; @@ -126,8 +126,8 @@ camera->img_buffer = realloc(camera->img_buffer, camera->proxy->image_count); camera->allocated_size = camera->proxy->image_count; } - - flip_image(camera->img_buffer, camera->proxy->image, camera->proxy->width, + + flip_image(camera->img_buffer, camera->proxy->image, camera->proxy->width, camera->proxy->height, camera->proxy->bpp, camera->proxy->image_count); camera_draw(camera); } @@ -188,7 +188,7 @@ camera->proxy->bpp); rtk_fig_text(camera->image_fig, PX(10), PY(camera->proxy->height + 10), 0, text); } - + } void flip_image(unsigned char *dst, unsigned char *src, int width, int height, int bpp, int usize) @@ -204,7 +204,7 @@ } row_width = width * bpp/8; - for(r = height; r >= 0; r--) { + for(r = height-1; r >= 0; r--) { memcpy(dst, src + r*row_width, row_width); dst = dst + row_width; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-04 01:01:34
|
Revision: 7231 http://playerstage.svn.sourceforge.net/playerstage/?rev=7231&view=rev Author: thjc Date: 2009-01-04 01:01:31 +0000 (Sun, 04 Jan 2009) Log Message: ----------- merge from 2-1 of 6230: allow eedhcontroller to work with nr joints != 6 Modified Paths: -------------- code/player/trunk/server/drivers/limb/eeDHcontroller.cc Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230 /code/player/trunk:6985 Modified: code/player/trunk/server/drivers/limb/eeDHcontroller.cc =================================================================== --- code/player/trunk/server/drivers/limb/eeDHcontroller.cc 2009-01-04 00:59:31 UTC (rev 7230) +++ code/player/trunk/server/drivers/limb/eeDHcontroller.cc 2009-01-04 01:01:31 UTC (rev 7231) @@ -243,7 +243,7 @@ nr_joints = cf->ReadInt (section, "nr_joints", 0); // Create initial DH parameters model - DHMatrixModel = Matrix (6, 23); + DHMatrixModel = Matrix (nr_joints, 23); DHMatrixModel = 0; actarray_state = new int[nr_joints]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-01-05 05:00:55
|
Revision: 7245 http://playerstage.svn.sourceforge.net/playerstage/?rev=7245&view=rev Author: gbiggs Date: 2009-01-05 05:00:40 +0000 (Mon, 05 Jan 2009) Log Message: ----------- Added library checks to eedhcontroller driver. Modified Paths: -------------- code/player/trunk/cmake/internal/DriverUtils.cmake code/player/trunk/server/drivers/limb/CMakeLists.txt code/player/trunk/server/drivers/limb/eeDHcontroller.cc Modified: code/player/trunk/cmake/internal/DriverUtils.cmake =================================================================== --- code/player/trunk/cmake/internal/DriverUtils.cmake 2009-01-05 03:55:24 UTC (rev 7244) +++ code/player/trunk/cmake/internal/DriverUtils.cmake 2009-01-05 05:00:40 UTC (rev 7245) @@ -304,7 +304,7 @@ ############################################################################### # PLAYERDRIVER_REQUIRE_LIB (_name _cumulativeVar _library _function _path) -# Check if a required package is available. +# Check if a required library is available. # # _name: Driver name. # _cumulativeVar: The option used in the calling CMakeLists.txt to check if @@ -315,6 +315,11 @@ INCLUDE (CheckLibraryExists) MACRO (PLAYERDRIVER_REQUIRE_LIB _name _cumulativeVar _library _function _path) SET (foundLibrary) + IF (PLAYER_EXTRA_LIB_DIRS AND NOT _path) + SET (_path "${PLAYER_EXTRA_LIB_DIRS}") + ELSEIF (NOT PLAYER_EXTRA_LIB_DIRS AND NOT _path) + SET (_path ".") + ENDIF (PLAYER_EXTRA_LIB_DIRS AND NOT _path) CHECK_LIBRARY_EXISTS ("${_library}" "${_function}" "${_path}" foundLibrary) # If not found, disable this driver # Dereference cumulativeVar only once because IF will dereference the variable name stored inside itself Modified: code/player/trunk/server/drivers/limb/CMakeLists.txt =================================================================== --- code/player/trunk/server/drivers/limb/CMakeLists.txt 2009-01-05 03:55:24 UTC (rev 7244) +++ code/player/trunk/server/drivers/limb/CMakeLists.txt 2009-01-05 05:00:40 UTC (rev 7245) @@ -1,2 +1,4 @@ PLAYERDRIVER_OPTION (eedhcontroller build_eedhcontroller OFF "Disabled - probably doesn't build") +PLAYERDRIVER_REQUIRE_LIB (eedhcontroller build_eedhcontroller roboop main "") +PLAYERDRIVER_REQUIRE_LIB (eedhcontroller build_eedhcontroller newmat main "") PLAYERDRIVER_ADD_DRIVER (eedhcontroller build_eedhcontroller SOURCES eeDHcontroller.cc) Modified: code/player/trunk/server/drivers/limb/eeDHcontroller.cc =================================================================== --- code/player/trunk/server/drivers/limb/eeDHcontroller.cc 2009-01-05 03:55:24 UTC (rev 7244) +++ code/player/trunk/server/drivers/limb/eeDHcontroller.cc 2009-01-05 05:00:40 UTC (rev 7245) @@ -217,7 +217,7 @@ void eedhcontroller_Register (DriverTable* table) { - table->AddDriver ("eeDHcontroller", EEDHController_Init); + table->AddDriver ("eedhcontroller", eedhcontroller_Init); } //////////////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-06 19:37:03
|
Revision: 7249 http://playerstage.svn.sourceforge.net/playerstage/?rev=7249&view=rev Author: thjc Date: 2009-01-06 19:37:00 +0000 (Tue, 06 Jan 2009) Log Message: ----------- Merge of 7248 from 2-1: Applied version of patch 2145007: fix up incorrect return type from playerc_client_read when sock < 0. Also removes small delay from read loop when not data is waiting (using a poll instead). Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/client.c Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248 /code/player/trunk:6985 Modified: code/player/trunk/client_libs/libplayerc/client.c =================================================================== --- code/player/trunk/client_libs/libplayerc/client.c 2009-01-06 19:31:27 UTC (rev 7248) +++ code/player/trunk/client_libs/libplayerc/client.c 2009-01-06 19:37:00 UTC (rev 7249) @@ -622,23 +622,24 @@ // Read and process a packet (blocking) void *playerc_client_read(playerc_client_t *client) { - void* ret_proxy; + void* ret_proxy = NULL; int ret; - // 10ms delay - struct timespec sleeptime = {0,10000000}; - for(;;) + // In case we're in PULL mode, first request a round of data. + if(playerc_client_requestdata(client) < 0) + return NULL; + // now wait until we get a sync, or some data if in push mode + do { - // In case we're in PULL mode, first request a round of data. - if(playerc_client_requestdata(client) < 0) - return NULL; ret = playerc_client_read_nonblock_withproxy(client, &ret_proxy); - if((ret > 0) || (client->sock < 0)) + if (ret < 0 || client->sock < 0) + break; + if(ret > 0) return ret_proxy; - if (ret < 0) - return NULL; - nanosleep(&sleeptime,NULL); - } + // if no data is available, then do a peek with infinite timeout... + // we cant do this first as we may already have data waiting on the internal queue + } while (playerc_client_internal_peek(client, -1) >= 0); + return NULL; } @@ -1311,8 +1312,7 @@ { int i, j; playerc_device_t *device; - void * ret; - ret = NULL; + void *ret = NULL; // Look for a device proxy to handle this data for (i = 0; i < client->device_count; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-07 18:41:38
|
Revision: 7253 http://playerstage.svn.sourceforge.net/playerstage/?rev=7253&view=rev Author: thjc Date: 2009-01-07 18:41:35 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Merge from 2-1 of 7250 Applied patch 2491569: adding some includes for neater compilation (v2.1.1) Modified Paths: -------------- code/player/trunk/client_libs/libplayerc++/actarrayproxy.cc code/player/trunk/client_libs/libplayerc++/opaqueproxy.cc code/player/trunk/client_libs/libplayerc++/speechproxy.cc code/player/trunk/client_libs/libplayerc++/test/test.cc code/player/trunk/server/drivers/laser/lms400_cola.cc Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250 /code/player/trunk:6985 Modified: code/player/trunk/client_libs/libplayerc++/actarrayproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/actarrayproxy.cc 2009-01-07 18:40:46 UTC (rev 7252) +++ code/player/trunk/client_libs/libplayerc++/actarrayproxy.cc 2009-01-07 18:41:35 UTC (rev 7253) @@ -44,6 +44,7 @@ #include "config.h" +#include <cstring> #include <cassert> #include <sstream> #include <iomanip> Modified: code/player/trunk/client_libs/libplayerc++/opaqueproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/opaqueproxy.cc 2009-01-07 18:40:46 UTC (rev 7252) +++ code/player/trunk/client_libs/libplayerc++/opaqueproxy.cc 2009-01-07 18:41:35 UTC (rev 7253) @@ -43,6 +43,7 @@ #include "config.h" +#include <cstring> #include <cassert> #include <sstream> #include <iomanip> Modified: code/player/trunk/client_libs/libplayerc++/speechproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/speechproxy.cc 2009-01-07 18:40:46 UTC (rev 7252) +++ code/player/trunk/client_libs/libplayerc++/speechproxy.cc 2009-01-07 18:41:35 UTC (rev 7253) @@ -40,6 +40,7 @@ /* * $Id$ */ +#include <cstring> #include <cstring> #include "playerc++.h" Modified: code/player/trunk/client_libs/libplayerc++/test/test.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test.cc 2009-01-07 18:40:46 UTC (rev 7252) +++ code/player/trunk/client_libs/libplayerc++/test/test.cc 2009-01-07 18:41:35 UTC (rev 7253) @@ -5,6 +5,7 @@ # CVS: $Id$ **************************************************************************/ +#include <cstring> #include <unistd.h> #include <cstring> Modified: code/player/trunk/server/drivers/laser/lms400_cola.cc =================================================================== --- code/player/trunk/server/drivers/laser/lms400_cola.cc 2009-01-07 18:40:46 UTC (rev 7252) +++ code/player/trunk/server/drivers/laser/lms400_cola.cc 2009-01-07 18:41:35 UTC (rev 7253) @@ -10,6 +10,7 @@ #include <stddef.h> #include <sys/socket.h> #include <netdb.h> +#include <unistd.h> #include <libplayercore/playercore.h> #include "lms400_cola.h" @@ -417,7 +418,12 @@ } while (current < length); // read checksum: - read (sockfd, &cs_read, 1); + int ret = read (sockfd, &cs_read, 1); + if (ret < 1) + { + PLAYER_ERROR1("LMS400 didnt get any data in read %d",ret); + return player_data; + } for (int i = 0; i < length; i++) cs_calc ^= buffer[i]; @@ -555,7 +561,12 @@ // Read checksum: char cs_read = 0; - read (sockfd, &cs_read, 1); + int ret = read (sockfd, &cs_read, 1); + if (ret < 1) + { + PLAYER_ERROR1("LMS400 didnt get any data in read %d",ret); + return -1; + } // printf ("%d %d 0x%x\n", bufferlength, sizeof(MeasurementHeader_t), buffer[0]); if (buffer[0] == 's') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-07 18:45:31
|
Revision: 7254 http://playerstage.svn.sourceforge.net/playerstage/?rev=7254&view=rev Author: thjc Date: 2009-01-07 18:45:27 +0000 (Wed, 07 Jan 2009) Log Message: ----------- Merge from 2-1 of 7251-7252: Applied patch 2164569: p2os driver - OSX serial flags Modified Paths: -------------- code/player/trunk/server/drivers/mixed/p2os/p2os.cc Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252 /code/player/trunk:6985 Modified: code/player/trunk/server/drivers/mixed/p2os/p2os.cc =================================================================== --- code/player/trunk/server/drivers/mixed/p2os/p2os.cc 2009-01-07 18:41:35 UTC (rev 7253) +++ code/player/trunk/server/drivers/mixed/p2os/p2os.cc 2009-01-07 18:45:27 UTC (rev 7254) @@ -844,7 +844,7 @@ this->psos_fd = -1; return(1); } - +#endif if((flags = fcntl(this->psos_fd, F_GETFL)) < 0) { perror("P2OS::Setup():fcntl()"); @@ -852,14 +852,18 @@ this->psos_fd = -1; return(1); } -#endif // radio modem initialization code, courtesy of Kim Jinsuck // <jin...@cs...> if(this->radio_modemp) { puts("Initializing radio modem..."); - write(this->psos_fd, "WMS2\r", 5); + int ret = write(this->psos_fd, "WMS2\r", 5); + if (ret < 5) + { + PLAYER_ERROR1("P2OS: Write failed to complete (%d)",ret); + return 1; + } usleep(50000); char modem_buf[50]; @@ -878,7 +882,12 @@ while(strstr(modem_buf, "ected to addres") == NULL) { puts("Initializing radio modem..."); - write(this->psos_fd, "WMS2\r", 5); + int ret = write(this->psos_fd, "WMS2\r", 5); + if (ret < 5) + { + PLAYER_ERROR1("P2OS: Failed to write full packet to modem (%d)", ret); + return 1; + } usleep(50000); char modem_buf[50]; @@ -1643,9 +1652,9 @@ } if(packet.packet[0] == 0xFA && packet.packet[1] == 0xFB && - (packet.packet[3] == 0x30 || packet.packet[3] == 0x31) || - (packet.packet[3] == 0x32 || packet.packet[3] == 0x33) || - (packet.packet[3] == 0x34)) + (packet.packet[3] == 0x30 || packet.packet[3] == 0x31 || + packet.packet[3] == 0x32 || packet.packet[3] == 0x33 || + packet.packet[3] == 0x34)) { /* It is a server packet, so process it */ @@ -1705,10 +1714,10 @@ } } else if(packet.packet[0] == 0xFA && packet.packet[1] == 0xFB && - (packet.packet[3] == 0x50 || packet.packet[3] == 0x80) || -// (packet.packet[3] == 0xB0 || packet.packet[3] == 0xC0) || - (packet.packet[3] == 0xC0) || - (packet.packet[3] == 0xD0 || packet.packet[3] == 0xE0)) + (packet.packet[3] == 0x50 || packet.packet[3] == 0x80 || +// packet.packet[3] == 0xB0 || packet.packet[3] == 0xC0 || + packet.packet[3] == 0xC0 || + packet.packet[3] == 0xD0 || packet.packet[3] == 0xE0)) { /* It is a vision packet from the old Cognachrome system*/ @@ -2379,12 +2388,15 @@ imager_config->contrast); if (imager_config->autogain >= 0) + { if (imager_config->autogain == 0) np += sprintf((char*)&cam_command[np], " 19 32"); else np += sprintf((char*)&cam_command[np], " 19 33"); + } if (imager_config->colormode >= 0) + { if (imager_config->colormode == 3) np += sprintf((char*)&cam_command[np], " 18 36"); else if (imager_config->colormode == 2) @@ -2393,6 +2405,7 @@ np += sprintf((char*)&cam_command[np], " 18 44"); else np += sprintf((char*)&cam_command[np], " 18 40"); + } if (np > 6) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-08 18:38:23
|
Revision: 7257 http://playerstage.svn.sourceforge.net/playerstage/?rev=7257&view=rev Author: thjc Date: 2009-01-08 18:38:04 +0000 (Thu, 08 Jan 2009) Log Message: ----------- Merge of 7256 from 201: Applied patch 2161837 - PlayerV sleep to avoid 100% CPU Modified Paths: -------------- code/player/trunk/utils/playerv/playerv.c Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256 /code/player/trunk:6985 Modified: code/player/trunk/utils/playerv/playerv.c =================================================================== --- code/player/trunk/utils/playerv/playerv.c 2009-01-08 18:19:00 UTC (rev 7256) +++ code/player/trunk/utils/playerv/playerv.c 2009-01-08 18:38:04 UTC (rev 7257) @@ -124,6 +124,8 @@ #include <time.h> #include "playerv.h" +#define GUI_UPDATE_RATE 20.0 + /* 20 Hz update rate is good for user interaction */ // Set flag to 1 to force program to quit static int quit = 0; @@ -164,7 +166,7 @@ device_t devices[PLAYER_MAX_DEVICES]; device_t *device; struct timeval tv, tc = {0, 0}; - struct timespec st = {0,0}; + struct timespec st = {0, (1.0/GUI_UPDATE_RATE) * 1e9}; printf("PlayerViewer %s\n", PLAYER_VERSION); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-09 21:14:33
|
Revision: 7259 http://playerstage.svn.sourceforge.net/playerstage/?rev=7259&view=rev Author: thjc Date: 2009-01-09 21:14:24 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Applied patch 2101864: New driver for the sick LD MRS (Ibeo LUX) Modified to work with threaded driver Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/dev_laser.c code/player/trunk/libplayercore/interfaces/006_laser.def code/player/trunk/server/drivers/laser/CMakeLists.txt code/player/trunk/server/drivers/shell/readlog.cc code/player/trunk/server/drivers/shell/writelog.cc Added Paths: ----------- code/player/trunk/server/drivers/laser/sickLDMRS.cc Modified: code/player/trunk/client_libs/libplayerc/dev_laser.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_laser.c 2009-01-09 21:03:45 UTC (rev 7258) +++ code/player/trunk/client_libs/libplayerc/dev_laser.c 2009-01-09 21:14:24 UTC (rev 7259) @@ -193,6 +193,40 @@ device->robot_pose[1] = scan_data->pose.py; device->robot_pose[2] = scan_data->pose.pa; } + else if((header->type == PLAYER_MSGTYPE_DATA) && + (header->subtype == PLAYER_LASER_DATA_SCANANGLE)) + { + player_laser_data_scanangle_t* scan_data = (player_laser_data_scanangle_t*)data; + + device->max_range = scan_data->max_range; + device->min_left = device->max_range; + device->min_right = device->max_range; + + device->scan_count = scan_data->ranges_count; + playerc_laser_reallocate_scans(device); + + for (i = 0; i < scan_data->ranges_count; i++) + { + r = scan_data->ranges[i]; + assert(r >= 0); + b = scan_data->angles[i]; + device->ranges[i] = r; + device->scan[i][0] = r; + device->scan[i][1] = b; + device->point[i].px = r * cos(b); + device->point[i].py = r * sin(b); + + if((i <= scan_data->ranges_count/2) && (r < device->min_right)) + device->min_right = r; + else if((i > scan_data->ranges_count/2) && (r < device->min_left)) + device->min_left = r; + } + for (i = 0; i < scan_data->intensity_count; i++) + device->intensity[i] = scan_data->intensity[i]; + + device->scan_id = scan_data->id; + } + else PLAYERC_WARN2("skipping laser message with unknown type/subtype: %s/%d\n", msgtype_to_str(header->type), header->subtype); Modified: code/player/trunk/libplayercore/interfaces/006_laser.def =================================================================== --- code/player/trunk/libplayercore/interfaces/006_laser.def 2009-01-09 21:03:45 UTC (rev 7258) +++ code/player/trunk/libplayercore/interfaces/006_laser.def 2009-01-09 21:14:24 UTC (rev 7259) @@ -21,6 +21,8 @@ message { DATA, SCAN, 1, player_laser_data_t }; /** Data subtype: pose-stamped scan */ message { DATA, SCANPOSE, 2, player_laser_data_scanpose_t }; +/** Data subtype: angle-stamped scan */ +message { DATA, SCANANGLE, 3, player_laser_data_scanangle_t }; /** Request/reply subtype: get geometry */ message { REQ, GET_GEOM, 1, player_laser_geom_t }; @@ -79,6 +81,30 @@ player_pose2d_t pose; } player_laser_data_scanpose_t; +/** @brief Data: scan (@ref PLAYER_LASER_DATA_SCANANGLE) + +The basic laser angle stamped data packet. */ +typedef struct player_laser_data_scanangle +{ + /** Maximum range [m]. */ + float max_range; + /** Number of range readings. */ + uint32_t ranges_count; + /** Range readings [m]. */ + float *ranges; + /** Number of agle readings. */ + uint32_t angles_count; + /** Angle readings [m]. */ + float *angles; + /** Number of intensity readings */ + uint32_t intensity_count; + /** Intensity readings. */ + uint8_t *intensity; + /** A unique, increasing, ID for the scan */ + uint32_t id; +} player_laser_data_scanangle_t; + + /** @brief Request/reply: Get geometry. The laser geometry (position and size) can be queried by sending a Modified: code/player/trunk/server/drivers/laser/CMakeLists.txt =================================================================== --- code/player/trunk/server/drivers/laser/CMakeLists.txt 2009-01-09 21:03:45 UTC (rev 7258) +++ code/player/trunk/server/drivers/laser/CMakeLists.txt 2009-01-09 21:14:24 UTC (rev 7259) @@ -43,3 +43,7 @@ PLAYERDRIVER_OPTION (rs4leuze build_rs4leuze ON) PLAYERDRIVER_ADD_DRIVER (rs4leuze build_rs4leuze SOURCES RS4LeuzeLaserDriver.cc RS4Leuze_laser.cc) + +PLAYERDRIVER_OPTION (sickLDMRS build_sickLDMRS ON) +PLAYERDRIVER_ADD_DRIVER (sickLDMRS build_sickLDMRS SOURCES sickLDMRS.cc) + Added: code/player/trunk/server/drivers/laser/sickLDMRS.cc =================================================================== --- code/player/trunk/server/drivers/laser/sickLDMRS.cc (rev 0) +++ code/player/trunk/server/drivers/laser/sickLDMRS.cc 2009-01-09 21:14:24 UTC (rev 7259) @@ -0,0 +1,539 @@ +/** @ingroup drivers Drivers */ +/** @{ */ +/** @defgroup driver_sickLDMRS sickLDMRS + * @brief SICK LD MRS / Multi plae and multi return laser scanner + +This driver is for communicting with the Ibeo LUX laser scanner over ethernet using the tcpstream driver + +@par Provides + +- laser + +@par Requires + + - opaque + +@par Supported commands + +- none + +@par Supported configuration requests + + - none + +@par Configuration file options + + - buffer_size (int) + - default: 100000 + - The size of the buffer in the lux driver + - layer (int) + - -1(default) = all layers + - 0,1,2,3 = only publish layer x of the data (3 = highest) + - echo (int) + - -1(default) = all echos + - 0,1,2,3 = only publish laser returns which are echo x + - intensity (0,1,2,3) + - 1(default) - publishes the echo width (in cm) as the intensity variable (cut at 255cm should never be exceeded?) + - 2 - publishes the echo number as the intensity value (0,1,2,3) + - 3 - publishes the scan layer as the intensity value (0,1,2,3) + - 0 - No intensity data + +@par Example: + +@verbatim +driver +( + name "sickLDMRS" + provides ["laser:0"] + requires ["opaque:0"] + buffer_size 20480 + layer 3 +) + +driver +( + name "tcpstream" + provides ["opaque:0"] + port 12002 + ip "10.99.0.1" + buffer_size 10000 +) +@endverbatim + +@author Chris Chambers + + +*/ +/** @} */ + +#define DEG2RAD(x) (((double)(x))*0.01745329251994) +//#define RAD2DEG(x) (((double)(x))*57.29577951308232) + +#include <unistd.h> +#include <string.h> +#include <iostream> +#include <arpa/inet.h> +//#include <stdint.h> +//#include <sys/time.h> +//#include <time.h> +//#include <assert.h> +//#include <math.h> + +#include <libplayercore/playercore.h> + +#define LUX_DEFAULT_RX_BUFFER_SIZE 100000U +#define LUX_DEFAULT_LAYER -1 +#define LUX_DEFAULT_ECHO -1 +#define LUX_DEFAULT_INTENSITY 1 + +#define HEADER_LEN 24U +#define SCAN_HEADER_LEN 46U +#define SCAN_DATA_LEN 24U + +#define MESSAGE_LEN 38U + +using namespace std; + +//extern PlayerTime *GlobalTime; + +/////////////////////////////////////////////////////////////////////////////// +// The class for the driver +class sickLDMRS : public ThreadedDriver +{ + public: + // Constructor; need that + sickLDMRS(ConfigFile* cf, int section); + ~sickLDMRS(); + + // Must implement the following methods. + virtual int MainSetup(); + virtual void MainQuit(); + + // This method will be invoked on each incoming message + virtual int ProcessMessage(QueuePointer & resp_queue, + player_msghdr* hdr, + void* data); + + private: + + //Makes a filter command + void makeStartStopCommand(uint8_t* buffer, bool start = true); + + bool ProcessLaserData(); + + // Main function for device thread. + virtual void Main(); + + // Opaque Driver info + Device *opaque; + player_devaddr_t opaque_id; + + player_laser_data_scanangle_t data_packet; + + struct timeval debug_time; + + int layer, echo, intensity; + + // rx buffer + uint8_t * rx_buffer; + unsigned int rx_buffer_size; + unsigned int rx_count; + +}; + + + +//////////////////////////////////////////////////////////////////////////////// +// Now the driver + +// A factory creation function, declared outside of the class so that it +// can be invoked without any object context (alternatively, you can +// declare it static in the class). In this function, we create and return +// (as a generic Driver*) a pointer to a new instance of this driver. +Driver* +sickLDMRS_Init(ConfigFile* cf, int section) +{ + // Create and return a new instance of this driver + return ((Driver*)(new sickLDMRS(cf, section))); + +} + +// A driver registration function, again declared outside of the class so +// that it can be invoked without object context. In this function, we add +// the driver into the given driver table, indicating which interface the +// driver can support and how to create a driver instance. +void sickLDMRS_Register(DriverTable* table) +{ + table->AddDriver("sickLDMRS", sickLDMRS_Init); +} + +//////////////////////////////////////////////////////////////////////////////// +// Constructor. Retrieve options from the configuration file and do any +// pre-Setup() setup. +sickLDMRS::sickLDMRS(ConfigFile* cf, int section) + : ThreadedDriver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_LASER_CODE) +{ + this->opaque = NULL; + // Must have an opaque device + if (cf->ReadDeviceAddr(&this->opaque_id, section, "requires", + PLAYER_OPAQUE_CODE, -1, NULL) != 0) + { + puts ("No Opaque driver specified"); + this->SetError(-1); + return; + } + + // Read options from the configuration file + + rx_count = 0; + rx_buffer_size = cf->ReadInt(section, "buffer_size", LUX_DEFAULT_RX_BUFFER_SIZE); + rx_buffer = new uint8_t[rx_buffer_size]; + assert(rx_buffer); + + layer = cf->ReadInt(section, "layer", LUX_DEFAULT_LAYER); + echo = cf->ReadInt(section, "echo", LUX_DEFAULT_ECHO); + intensity = cf->ReadInt(section, "intensity", LUX_DEFAULT_INTENSITY); + + //this->RegisterProperty ("mirror", &this->mirror, cf, section); + + return; +} + +sickLDMRS::~sickLDMRS() +{ + delete [] rx_buffer; +} + +//////////////////////////////////////////////////////////////////////////////// +// Set up the device. Return 0 if things go well, and -1 otherwise. +int sickLDMRS::MainSetup() +{ + puts("Setting up sickLDMRS driver"); + + if(Device::MatchDeviceAddress(this->opaque_id, this->device_addr)) + { + PLAYER_ERROR("attempt to subscribe to self"); + return(-1); + } + + if(!(this->opaque = deviceTable->GetDevice(this->opaque_id))) + { + PLAYER_ERROR("unable to locate suitable opaque device"); + return(-1); + } + + if(this->opaque->Subscribe(this->InQueue) != 0) + { + PLAYER_ERROR("unable to subscribe to opaque device"); + return(-1); + } + + uint8_t* buffer = new uint8_t[MESSAGE_LEN]; + assert(buffer); + makeStartStopCommand(buffer, true); + player_opaque_data_t mData; + mData.data_count = MESSAGE_LEN; + mData.data = buffer; + + opaque->PutMsg(this->InQueue, PLAYER_MSGTYPE_CMD, PLAYER_OPAQUE_CMD_DATA, reinterpret_cast<void*>(&mData),0,NULL); + + delete [] buffer; + buffer = NULL; + + puts("sickLDMRS driver ready"); + + return(0); +} + + +//////////////////////////////////////////////////////////////////////////////// +// Shutdown the device +void sickLDMRS::MainQuit() +{ + uint8_t* buffer = new uint8_t[MESSAGE_LEN]; + assert(buffer); + makeStartStopCommand(buffer, false); + player_opaque_data_t mData; + mData.data_count = MESSAGE_LEN; + mData.data = buffer; + + opaque->PutMsg(this->InQueue, PLAYER_MSGTYPE_CMD, PLAYER_OPAQUE_CMD_DATA, reinterpret_cast<void*>(&mData),0,NULL); + + delete [] buffer; + + puts("sickLDMRS driver shutting down"); + + opaque->Unsubscribe(InQueue); + + puts("sickLDMRS driver has been shutdown"); +} + + + +// Process an incoming message +int sickLDMRS::ProcessMessage(QueuePointer & resp_queue, + player_msghdr* hdr, + void* data) +{ + assert(hdr); + //assert(data); + + if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_DATA, PLAYER_OPAQUE_DATA_STATE, opaque_id)) + { + //GlobalTime->GetTime(&(this->debug_time)); + //PLAYER_MSG2(1,"LUX driver received data packet at %d:%d", this->debug_time.tv_sec, this->debug_time.tv_usec); + //puts("Received tcp data"); + player_opaque_data_t * recv = reinterpret_cast<player_opaque_data_t * > (data); + unsigned int messageOffset = rx_count; + rx_count += recv->data_count; + if (rx_count > rx_buffer_size) + { + PLAYER_WARN("sickLDMRS driver Buffer Full"); + rx_count = 0; + } + else + { + memcpy(&rx_buffer[messageOffset], recv->data, recv->data_count); + } + return 0; + } + return -1; +} + +//////////////////////////////////////////////////////////////////////////////// +// Main function for device thread +void sickLDMRS::Main() +{ + + // The main loop; interact with the device here + for(;;) + { + // Process incoming messages + ProcessMessages(); + + // Ask for the current position and publish it + ProcessLaserData(); + + if (!this->Wait(1)) + { + PLAYER_WARN("No TCP data received within 1s, possible loss of connection"); + } + } + return; +} + +// Currently this alternates between reading the pedal position and reading the steering position +bool sickLDMRS::ProcessLaserData() +{ + //TODO: Implement a timeout here so that if it gets no data back in a time frame it either errors or sends a reset and stuff + while(rx_count > HEADER_LEN) + { + //puts("Got enough data"); + // find our continuous data header + unsigned int ii; + bool found = false; + for (ii = 0; ii < rx_count - HEADER_LEN; ++ii) + { + if (memcmp(&rx_buffer[ii],"\xaf\xfe\xc0\xc2",4) == 0) + { + //PLAYER_MSG0(3,"Header string found"); + memmove(rx_buffer, &rx_buffer[ii], rx_count-ii); + rx_count -= ii; + found = true; + break; + } + } + if (!found) + { + memmove(rx_buffer, &rx_buffer[ii], rx_count-ii); + rx_count -= ii; + return 0; + } + + // get relevant bits of the header + // size includes all data in the data block + // through to the end of the packet including the checksum + uint32_t size = htonl(*reinterpret_cast<uint32_t*> (&rx_buffer[8])); // Should this be htons???? + if (size > rx_buffer_size - HEADER_LEN) + { + PLAYER_WARN("sickLDMRS: Requested Size of data is larger than the buffer size"); + memmove(rx_buffer, &rx_buffer[1], --rx_count); + return 0; + } + + // check if we have enough data yet + if (size > rx_count - HEADER_LEN) + { + return 0; + } + //PLAYER_MSG0(5, "GOT ENOUGH DATATATATATATATATATATATATATATATATATATATATAT"); + + uint8_t * data = &rx_buffer[HEADER_LEN]; + if (memcmp(&rx_buffer[14], "\x22\x01", 2) == 0) + { + //PLAYER_MSG0(1, "Got scan data packet"); + if (size < SCAN_HEADER_LEN) + { + PLAYER_WARN1("sickLDMRS- bad data count (%d)\n", size); + memmove(rx_buffer, &rx_buffer[1], --rx_count); + continue; + } + if (size == SCAN_HEADER_LEN) + { + PLAYER_MSG0(1, "LUX - no scans returned"); + continue; + } + //PLAYER_MSG0(1, "Not bad count"); + //PLAYER_MSG2(1, "Size hex %x %x", rx_buffer[34+HEADER_LEN], rx_buffer[35+HEADER_LEN]); + + uint16_t scan_count = htons(*reinterpret_cast<uint16_t*> (&data[34])); + //uint16_t scan_count = htons(*reinterpret_cast<uint16_t*> (&rx_buffer[34+HEADER_LEN])); + //PLAYER_MSG1(4,"Scan count %d", scan_count); + if (size != (SCAN_HEADER_LEN + SCAN_DATA_LEN*scan_count)) + { + PLAYER_WARN2("sickLDMRS - data size mismatch, size = %d, number of scans = %d\n", size, scan_count); + memmove(rx_buffer, &rx_buffer[1], --rx_count); + continue; + } + + if (intensity) + data_packet.intensity = new uint8_t [scan_count]; + data_packet.ranges = new float [scan_count]; + data_packet.angles = new float [scan_count]; + data_packet.max_range = 300; + // This is needed as the true count will be less than the scan count if you are only interesed in a single layer + // or a single echo thingy + int true_count = 0; + data_packet.id = htons(*reinterpret_cast<uint16_t *>(&data[6])); + for (int ii = 0; ii < scan_count; ++ii) + { + if (!(layer == -1 || layer == data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+2])) + continue; + if (!(echo == -1 || echo == data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+3])) + continue; + uint16_t Distance_CM = htons(*reinterpret_cast<uint16_t *> (&data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+6])); + assert(SCAN_HEADER_LEN + SCAN_DATA_LEN*ii+6+HEADER_LEN <= rx_count); + double distance_m = static_cast<double>(Distance_CM)/100.0; + data_packet.ranges[true_count] = distance_m; + int16_t angle_i = htons(*reinterpret_cast<uint16_t *> (&data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+4])); + if (angle_i > 180*32) + { + angle_i -= 360*32; + } + double angle_d = DEG2RAD(angle_i)/32.0; + data_packet.angles[true_count] = angle_d; + if (intensity == 1) + { + // echo width in cm + uint16_t tmp = htons(*reinterpret_cast<uint16_t *> (&data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+8])); + if (tmp > 255) + tmp = 255; + data_packet.intensity[true_count] = tmp; + } + else if (intensity == 2) + data_packet.intensity[true_count] = data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+3]; + else if (intensity == 3) + data_packet.intensity[true_count] = data[SCAN_HEADER_LEN+SCAN_DATA_LEN*ii+2]; + true_count++; + + } + assert(true_count <= scan_count); + data_packet.ranges_count = true_count; + data_packet.angles_count = true_count; + if (intensity) + data_packet.intensity_count = true_count; + else + data_packet.intensity_count = 0; + // About to publish stuff + //GlobalTime->GetTime(&(this->debug_time)); + //PLAYER_MSG2(1,"LUX driver publishing data at time %d:%d", this->debug_time.tv_sec, this->debug_time.tv_usec); + //PLAYER_MSG0(1, "Publishing data"); + //PLAYER_MSG2(1, "Scan number = %x %x", data[6], data[7]); + //PLAYER_MSG2(1, "Rx_count %d size %d", rx_count, size); + this->Publish (this->device_addr, PLAYER_MSGTYPE_DATA, + PLAYER_LASER_DATA_SCANANGLE, (void*)&data_packet); + delete [] data_packet.ranges; + delete [] data_packet.angles; + delete [] data_packet.intensity; + + + } + else if (memcmp(&rx_buffer[14], "\x20\x20", 2) == 0) + { + if (size != 2) + { + PLAYER_ERROR("Ibeo LUX: Only set mode ack returns are currently supported"); + } + // Got a command message reply + if (data[1] & 0x80) + PLAYER_ERROR("Ibeo LUX: The laser returned a failed flag for the command message sent"); + + } + else + PLAYER_WARN("Ibeo LUX got a unrecognised responce type"); + memmove(rx_buffer, &rx_buffer[size+HEADER_LEN], rx_count - (size+HEADER_LEN)); + rx_count -= (size + HEADER_LEN); + continue; + } + return 1; +} + +void sickLDMRS::makeStartStopCommand(uint8_t* buffer, bool start /*= true*/ ) +{ + + buffer[0] = 0xAF; // magic word + buffer[1] = 0xFE; + buffer[2] = 0xC0; + buffer[3] = 0xC2; + buffer[4] = 0x00; // Size of previous message, here just left to nullL + buffer[5] = 0x00; + buffer[6] = 0x00; + buffer[7] = 0x00; + buffer[8] = 0x00; // Size of data block + buffer[9] = 0x00; + buffer[10] = 0x00; + buffer[11] = 0x0e; + buffer[12] = 0x00; // Reserved + source Id + buffer[13] = 0x00; + buffer[14] = 0x20; // Data Type - 2010 = command + buffer[15] = 0x10; + buffer[16] = 0x00; // 4* ntpp time (s) + 4* fractions of a second + buffer[17] = 0x00; + buffer[18] = 0x00; + buffer[19] = 0x00; + buffer[20] = 0x00; + buffer[21] = 0x00; + buffer[22] = 0x00; + buffer[23] = 0x00; + // Data Block - all little endian + buffer[24] = 0x02; // Command Type - 0002 = set mode + buffer[25] = 0x00; + buffer[26] = 0x00; // Version + buffer[27] = 0x00; + // Start of set mode stuff - all little endian + buffer[28] = 0xc0; // start angle /32 + buffer[29] = 0x26; + buffer[30] = 0x40; // end angle /32 + buffer[31] = 0x06; + buffer[32] = 0x80; // frequency /256, must be 12.5 Hz + buffer[33] = 0x0c; + if (start) + { + buffer[34] = 0x03; + buffer[35] = 0x03; + } + else + { + buffer[34] = 0x00; + buffer[35] = 0x00; + } + buffer[36] = 0x00; // reserved + buffer[37] = 0x00; + + +} + + + + + Modified: code/player/trunk/server/drivers/shell/readlog.cc =================================================================== --- code/player/trunk/server/drivers/shell/readlog.cc 2009-01-09 21:03:45 UTC (rev 7258) +++ code/player/trunk/server/drivers/shell/readlog.cc 2009-01-09 21:14:24 UTC (rev 7259) @@ -1559,6 +1559,55 @@ return ret; } + case PLAYER_LASER_DATA_SCANANGLE: + { + player_laser_data_scanangle_t data; + + if (token_count < 13) + { + PLAYER_ERROR2("incomplete line at %s:%d", + this->filename, linenum); + return -1; + } + + data.id = atoi(tokens[7]); + data.max_range = atof(tokens[8]); + data.ranges_count = atoi(tokens[9]); + data.intensity_count = data.ranges_count; + data.angles_count = data.ranges_count; + + data.ranges = new float[ data.ranges_count ]; + data.intensity = new uint8_t[ data.ranges_count ]; + data.angles = new float[ data.ranges_count ]; + + count = 0; + for (i = 10; i < token_count; i += 3) + { + data.ranges[count] = atof(tokens[i + 0]); + data.angles[count] = atof(tokens[i + 1]); + data.intensity[count] = atoi(tokens[i + 2]); + count += 1; + } + + if (count != (int)data.ranges_count) + { + PLAYER_ERROR2("range count mismatch at %s:%d", + this->filename, linenum); + ret = -1; + } + else + { + this->Publish(id, type, subtype, + (void*)&data, sizeof(data), &time); + } + delete [] data.ranges; + delete [] data.intensity; + delete [] data.angles; + + return ret; + } + + default: PLAYER_ERROR1("unknown laser data subtype %d\n", subtype); return(-1); Modified: code/player/trunk/server/drivers/shell/writelog.cc =================================================================== --- code/player/trunk/server/drivers/shell/writelog.cc 2009-01-09 21:03:45 UTC (rev 7258) +++ code/player/trunk/server/drivers/shell/writelog.cc 2009-01-09 21:14:24 UTC (rev 7259) @@ -983,6 +983,7 @@ player_laser_data_t* scan; player_laser_data_scanpose_t* scanpose; player_laser_geom_t* geom; + player_laser_data_scanangle_t* scanangle; // Check the type switch(hdr->type) @@ -1032,6 +1033,22 @@ } return(0); + case PLAYER_LASER_DATA_SCANANGLE: + scanangle = (player_laser_data_scanangle_t*)data; + fprintf(this->file, "%04d %+07.4f %04d ", + scanangle->id, scanangle->max_range, scanangle->ranges_count); + + for (i = 0; i < scanangle->ranges_count; i++) + { + fprintf(this->file, "%.3f ", scanangle->ranges[i]); + fprintf(this->file, "%.3f ", scanangle->angles[i]); + if(i < scanangle->intensity_count) + fprintf(this->file, "%2d ", scanangle->intensity[i]); + else + fprintf(this->file, "%2d ", 0); + } + return(0); + default: return(-1); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-11 00:44:37
|
Revision: 7264 http://playerstage.svn.sourceforge.net/playerstage/?rev=7264&view=rev Author: thjc Date: 2009-01-11 00:44:30 +0000 (Sun, 11 Jan 2009) Log Message: ----------- Merge of 7262-7263 from 2-1: Fixed a bunch of sprintf's which should really be snprintf (including at least one that was definately over flowing a buffer) Fixed many compiler warnings. Modified Paths: -------------- code/player/trunk/client_libs/libplayerc++/rfidproxy.cc code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc code/player/trunk/libplayercore/addr_util.c code/player/trunk/libplayercore/configfile.cc code/player/trunk/libplayercore/plugins.cc code/player/trunk/libplayertcp/socket_util.c code/player/trunk/rtk2/rtk_canvas.c code/player/trunk/server/drivers/camera/1394/camera1394.cc code/player/trunk/server/drivers/camera/compress/cameracompress.cc code/player/trunk/server/drivers/camera/compress/camerauncompress.cc code/player/trunk/server/drivers/camera/v4l/v4lcapture.c code/player/trunk/server/drivers/camera/v4l/v4lframe.c code/player/trunk/server/drivers/imu/MTComm.cpp code/player/trunk/server/drivers/joystick/linuxjoy.cc code/player/trunk/server/drivers/laser/RS4Leuze_laser.cc code/player/trunk/server/drivers/laser/lms400_cola.cc code/player/trunk/server/drivers/limb/eeDHcontroller.cc code/player/trunk/server/drivers/mixed/cmucam2/camera.c code/player/trunk/server/drivers/mixed/cmucam2/cmucam2.cc code/player/trunk/server/drivers/mixed/erratic/erratic.cc code/player/trunk/server/drivers/mixed/khepera/khepera.cc code/player/trunk/server/drivers/mixed/mricp/src/map.cpp code/player/trunk/server/drivers/mixed/mricp/src/mricp_driver.cpp code/player/trunk/server/drivers/mixed/p2os/p2os.cc code/player/trunk/server/drivers/mixed/p2os/sip.cc code/player/trunk/server/drivers/mixed/reb/reb.cc code/player/trunk/server/drivers/mixed/rflex/rflex-io.cc code/player/trunk/server/drivers/mixed/rflex/rflex_commands.cc code/player/trunk/server/drivers/mixed/rmp/canio.h code/player/trunk/server/drivers/mixed/wbr/914/wbr914.cc code/player/trunk/server/drivers/ptz/canonvcc4.cc code/player/trunk/server/drivers/rfid/rfi341_protocol.cc code/player/trunk/server/drivers/wifi/linuxwifi.cc code/player/trunk/server/drivers/wsn/accel_calib.cc code/player/trunk/server/drivers/wsn/mica2.cc code/player/trunk/server/drivers/wsn/rcore_xbridge.cc code/player/trunk/utils/logsplitter/logsplitter.c code/player/trunk/utils/playerjoy/playerjoy.cc code/player/trunk/utils/playernav/gui.c code/player/trunk/utils/playerv/pv_dev_dio.c code/player/trunk/utils/playerv/pv_dev_power.c code/player/trunk/utils/playervcr/playervcr.c Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263 /code/player/trunk:6985 Modified: code/player/trunk/client_libs/libplayerc++/rfidproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/rfidproxy.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/client_libs/libplayerc++/rfidproxy.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -2,8 +2,8 @@ * Player - One Hell of a Robot Server * Copyright (C) 2000-2003 * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard - * * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -39,7 +39,7 @@ /* * Author: Radu Bogdan Rusu - * client-side RFID device + * client-side RFID device */ #include "playerc++.h" @@ -96,10 +96,10 @@ playerc_rfidtag_t tag; tag = c.GetRFIDTag(i); char RFIDtag[24]; - sprintf (RFIDtag, "$%2x$%2x$%2x$%2x$%2x$%2x$%2x$%2x", + snprintf (RFIDtag, 24, "$%2x$%2x$%2x$%2x$%2x$%2x$%2x$%2x", tag.guid[0], tag.guid[1], tag.guid[2], tag.guid[3], tag.guid[4], tag.guid[5], tag.guid[6], tag.guid[7]); - + os << " tag " << i << ":" << std::endl; os << " type: " << tag.type << std::endl; os << " guid: " << RFIDtag << std::endl; Modified: code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc =================================================================== --- code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/examples/plugins/exampleinterface/eginterf_driver.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -94,7 +94,7 @@ resp.stuff_count = reinterpret_cast<player_eginterf_cmd*> (data)->doStuff; resp.stuff = new double[reinterpret_cast<player_eginterf_cmd*> (data)->doStuff]; printf ("EgInterfDriver: Sending data:\n"); - for (char ii = 0; ii < reinterpret_cast<player_eginterf_cmd*> (data)->doStuff; ii++) + for (int ii = 0; ii < reinterpret_cast<player_eginterf_cmd*> (data)->doStuff; ii++) { double temp = (((double) random ()) / RAND_MAX) * 10.0f; resp.stuff[ii] = temp; Modified: code/player/trunk/libplayercore/addr_util.c =================================================================== --- code/player/trunk/libplayercore/addr_util.c 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/libplayercore/addr_util.c 2009-01-11 00:44:30 UTC (rev 7264) @@ -60,7 +60,7 @@ assert(len >= (size_t)16); - sprintf(dest, "%u.%u.%u.%u", + snprintf(dest, 16,"%u.%u.%u.%u", swappedaddr>>24 & mask, swappedaddr>>16 & mask, swappedaddr>>8 & mask, Modified: code/player/trunk/libplayercore/configfile.cc =================================================================== --- code/player/trunk/libplayercore/configfile.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/libplayercore/configfile.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -1,9 +1,9 @@ /* * Player - One Hell of a Robot Server - * Copyright (C) 2000 + * Copyright (C) 2000 * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard - * * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -97,7 +97,7 @@ /////////////////////////////////////////////////////////////////////////// // Default constructor -ConfigFile::ConfigFile(uint32_t _default_host, uint32_t _default_robot) +ConfigFile::ConfigFile(uint32_t _default_host, uint32_t _default_robot) { this->default_host = _default_host; this->default_robot = _default_robot; @@ -189,7 +189,7 @@ } ClearTokens(); - + // Read tokens from the file if (!LoadTokens(file, 0)) { @@ -217,7 +217,7 @@ fclose(file); return false; } - + // Work out what the length units are const char *unit = ReadString(0, "unit_length", "m"); if (strcmp(unit, "m") == 0) @@ -233,9 +233,9 @@ this->unit_angle = M_PI / 180; else if (strcmp(unit, "radians") == 0) this->unit_angle = 1; - + //DumpTokens(); - fclose(file); + fclose(file); return true; } @@ -243,7 +243,7 @@ /// Add a (name,value) pair directly into the database, without /// reading from a file. The (name,value) goes into the "global" section. void ConfigFile::InsertFieldValue(int index, - const char* name, + const char* name, const char* value) { // Work out what the length units are @@ -282,7 +282,7 @@ { // Debugging //DumpFields(); - + // If no filename is supplied, use default if (!filename) filename = this->filename; @@ -350,7 +350,7 @@ int ch; int line; char token[256]; - + line = 1; while (true) @@ -358,7 +358,7 @@ ch = fgetc(file); if (ch == EOF) break; - + if ((char) ch == '#') { ungetc(ch, file); @@ -416,7 +416,7 @@ else if ( 0x0d == ch ) { ch = fgetc(file); - if ( 0x0a != ch ) + if ( 0x0a != ch ) ungetc(ch, file); line++; AddToken(TokenEOL, "\n", include); @@ -424,7 +424,7 @@ else if ( 0x0a == ch ) { ch = fgetc(file); - if ( 0x0d != ch ) + if ( 0x0d != ch ) ungetc(ch, file); line++; AddToken(TokenEOL, "\n", include); @@ -450,7 +450,7 @@ len = 0; memset(token, 0, sizeof(token)); - + while (true) { ch = fgetc(file); @@ -480,10 +480,10 @@ char token[1024]; int len; int ch; - + len = 0; memset(token, 0, sizeof(token)); - + while (true) { ch = fgetc(file); @@ -506,8 +506,8 @@ if (!LoadTokenInclude(file, line, include)) return false; } - else if(strcmp(token, "true") == 0 || strcmp(token, "false") == 0 || - strcmp(token, "yes") == 0 || strcmp(token, "no") == 0) + else if(strcmp(token, "true") == 0 || strcmp(token, "false") == 0 || + strcmp(token, "yes") == 0 || strcmp(token, "no") == 0) { ungetc(ch, file); AddToken(TokenBool, token, include); @@ -532,7 +532,7 @@ int ch; const char *filename; char *fullpath; - + ch = fgetc(file); if (ch == EOF) @@ -551,7 +551,7 @@ return false; ch = fgetc(file); - + if (ch == EOF) { TOKEN_ERR("incomplete include statement", *line); @@ -585,7 +585,7 @@ fullpath = (char*) malloc(PATH_MAX); memset(fullpath, 0, PATH_MAX); strcat( fullpath, dirname(tmp)); - strcat( fullpath, "/" ); + strcat( fullpath, "/" ); strcat( fullpath, filename ); assert(strlen(fullpath) + 1 < PATH_MAX); free(tmp); @@ -597,10 +597,16 @@ // There's no bounds-checking, but what the heck. char *tmp = strdup(this->filename); fullpath = (char*) malloc(PATH_MAX); - getcwd(fullpath, PATH_MAX); - strcat( fullpath, "/" ); + char* ret = getcwd(fullpath, PATH_MAX); + if (ret == NULL) + { + PLAYER_ERROR("Failed to get working directory"); + assert(false); + // TODO: handle this error properly + } + strcat( fullpath, "/" ); strcat( fullpath, dirname(tmp)); - strcat( fullpath, "/" ); + strcat( fullpath, "/" ); strcat( fullpath, filename ); assert(strlen(fullpath) + 1 < PATH_MAX); free(tmp); @@ -639,10 +645,10 @@ char token[1024]; int len; int ch; - + len = 0; memset(token, 0, sizeof(token)); - + while (true) { ch = fgetc(file); @@ -675,12 +681,12 @@ int ch; int len; char token[1024]; - + len = 0; memset(token, 0, sizeof(token)); ch = fgetc(file); - + while (true) { ch = fgetc(file); @@ -712,10 +718,10 @@ int ch; int len; char token[1024]; - + len = 0; memset(token, 0, sizeof(token)); - + while (true) { ch = fgetc(file); @@ -747,7 +753,7 @@ { int i; Token *token; - + for (i = 0; i < this->token_count; i++) { token = this->tokens + i; @@ -755,7 +761,7 @@ if (token->include > 0) continue; if (token->type == TokenString) - fprintf(file, "\"%s\"", token->value); + fprintf(file, "\"%s\"", token->value); else fprintf(file, "%s", token->value); } @@ -792,11 +798,11 @@ this->tokens = (Token*) realloc(this->tokens, this->token_size * sizeof(this->tokens[0])); } - this->tokens[this->token_count].include = include; + this->tokens[this->token_count].include = include; this->tokens[this->token_count].type = type; this->tokens[this->token_count].value = strdup(value); this->token_count++; - + return true; } @@ -809,7 +815,7 @@ free(this->tokens[index].value); this->tokens[index].value = strdup(value); - + return true; } @@ -856,11 +862,11 @@ ClearSections(); ClearFields(); - + // Add in the "global" section. section = AddSection(-1, ""); line = 1; - + for (i = 0; i < this->token_count; i++) { token = this->tokens + i; @@ -1081,7 +1087,7 @@ return false; } } - + return false; } @@ -1097,7 +1103,7 @@ name = *index; macro = LookupMacro(GetTokenValue(name)); - + // If the section name is a macro... if (macro >= 0) { @@ -1186,7 +1192,7 @@ name = *index; value = -1; count = 0; - + for (i = *index + 1; i < this->token_count; i++) { token = this->tokens + i; @@ -1233,7 +1239,7 @@ Token *token; count = 0; - + for (i = *index + 1; i < this->token_count; i++) { token = this->tokens + i; @@ -1293,7 +1299,7 @@ this->macros[macro].starttoken = starttoken; this->macros[macro].endtoken = endtoken; this->macro_count++; - + return macro; } @@ -1305,7 +1311,7 @@ { int i; CMacro *macro; - + for (i = 0; i < this->macro_count; i++) { macro = this->macros + i; @@ -1365,7 +1371,7 @@ this->sections[section].parent = parent; this->sections[section].type = type; this->section_count++; - + return section; } @@ -1455,7 +1461,7 @@ { int i; Field *field; - + // See if this field already exists; if it does, we dont need to // add it again. for (i = 0; i < this->field_count; i++) @@ -1513,7 +1519,7 @@ /////////////////////////////////////////////////////////////////////////// -// Get a field +// Get a field int ConfigFile::GetField(int section, const char *name) { // Find first instance of field @@ -1552,18 +1558,18 @@ /////////////////////////////////////////////////////////////////////////// -// Get the value of an field +// Get the value of an field const char *ConfigFile::GetFieldValue(int field, int index, bool flag_used) { assert(field >= 0); Field *pfield = this->fields + field; - + if(index >= pfield->value_count) return NULL; if (flag_used) pfield->useds[index] = true; - + return GetTokenValue(pfield->values[index]); } @@ -1577,7 +1583,7 @@ { Field *field = this->fields + i; Section *section = this->sections + field->section; - + printf("## [%d]", field->section); printf("[%s]", section->type); printf("[%s]", field->name); @@ -1607,7 +1613,7 @@ int field = GetField(section, name); if (field < 0) return; - SetFieldValue(field, 0, value); + SetFieldValue(field, 0, value); } @@ -1717,7 +1723,7 @@ { int field; const char *color; - + field = GetField(section, name); if (field < 0) return value; @@ -1739,7 +1745,7 @@ return value; const char *filename = GetFieldValue(field, 0); - + if( filename[0] == '/' || filename[0] == '~' ) return filename; @@ -1752,12 +1758,12 @@ char *fullpath = (char*) malloc(MAX_FILENAME_SIZE); memset(fullpath, 0, MAX_FILENAME_SIZE); strcat( fullpath, dirname(tmp)); - strcat( fullpath, "/" ); + strcat( fullpath, "/" ); strcat( fullpath, filename ); assert(strlen(fullpath) + 1 < MAX_FILENAME_SIZE); SetFieldValue(field, 0, fullpath); - + free(fullpath); free(tmp); } @@ -1769,15 +1775,21 @@ // There's no bounds-checking, but what the heck. char *tmp = strdup(this->filename); char *fullpath = (char*) malloc(MAX_FILENAME_SIZE); - getcwd(fullpath, MAX_FILENAME_SIZE); - strcat( fullpath, "/" ); + char * ret = getcwd(fullpath, MAX_FILENAME_SIZE); + if (ret == NULL) + { + PLAYER_ERROR("Failed to get working directory"); + assert(false); + // TODO: handle this error properly + } + strcat( fullpath, "/" ); strcat( fullpath, dirname(tmp)); - strcat( fullpath, "/" ); + strcat( fullpath, "/" ); strcat( fullpath, filename ); assert(strlen(fullpath) + 1 < MAX_FILENAME_SIZE); SetFieldValue(field, 0, fullpath); - + free(fullpath); free(tmp); } @@ -1825,7 +1837,7 @@ if (field < 0) field = InsertField(section, name); */ - SetFieldValue(field, index, value); + SetFieldValue(field, index, value); } @@ -1975,8 +1987,8 @@ fclose(file); return 0xFFFFFF; } - - + + while (true) { char line[1024]; @@ -1984,7 +1996,7 @@ break; // it's a macro or comment line - ignore the line - if (line[0] == '!' || line[0] == '#' || line[0] == '%') + if (line[0] == '!' || line[0] == '#' || line[0] == '%') continue; // Trim the trailing space @@ -1995,7 +2007,7 @@ int r, g, b; int chars_matched = 0; sscanf( line, "%d %d %d %n", &r, &g, &b, &chars_matched ); - + // Read the name char* nname = line + chars_matched; @@ -2037,7 +2049,7 @@ // Find the number of values in the field count = GetFieldValueCount(prop); - + // Consider all the values, looking for a match for (i = 0; i < count; i++) { @@ -2124,7 +2136,7 @@ // is no match. if (key && k == NULL) continue; - + // If the key is expected and present in the file, it must match if (key && k && strcmp(key, k) != 0) continue; @@ -2137,14 +2149,14 @@ addr->interf = interf.interf; addr->index = ind; return 0; - + } return -1; } // Parse all driver blocks -bool +bool ConfigFile::ParseAllDrivers() { for(int i = 1; i < this->GetSectionCount(); i++) @@ -2160,10 +2172,10 @@ } // Parse a driver block, and update the deviceTable accordingly -bool +bool ConfigFile::ParseDriver(int section) { - const char *pluginname; + const char *pluginname; const char *drivername; DriverEntry *entry; Driver *driver; @@ -2173,7 +2185,7 @@ entry = NULL; driver = NULL; - + // Load any required plugins pluginname = this->ReadString(section, "plugin", NULL); if (pluginname != NULL) @@ -2197,7 +2209,7 @@ PLAYER_ERROR1("No driver name specified in section %d", section); return (false); } - + // Look for the driver entry = driverTable->GetDriverEntry(drivername); if (entry == NULL) @@ -2241,8 +2253,8 @@ PLAYER_ERROR1("Driver has no (usable) interfaces \"%s\"", drivername); return false; } - - // Should this device be "always on"? + + // Should this device be "always on"? if (driver) driver->alwayson = this->ReadInt(section, "alwayson", driver->alwayson); Modified: code/player/trunk/libplayercore/plugins.cc =================================================================== --- code/player/trunk/libplayercore/plugins.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/libplayercore/plugins.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -164,7 +164,13 @@ cfgdir = dirname(tmp); if(cfgdir[0] != '/' && cfgdir[0] != '~') { - getcwd(path->fullpath, PATH_MAX); + char * ret = getcwd(path->fullpath, PATH_MAX); + if (ret == NULL) + { + PLAYER_ERROR("Failed to get working directory"); + assert(false); + // TODO: handle this error properly + } strncat(path->fullpath,"/", PATH_MAX); } strncat(path->fullpath,cfgdir, PATH_MAX); Modified: code/player/trunk/libplayertcp/socket_util.c =================================================================== --- code/player/trunk/libplayertcp/socket_util.c 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/libplayertcp/socket_util.c 2009-01-11 00:44:30 UTC (rev 7264) @@ -47,7 +47,7 @@ #include <sys/types.h> /* for socket(2) */ #include <sys/socket.h> /* for socket(2) */ #include <fcntl.h> /* for fcntl(2) */ -#include <stdio.h> /* for sprintf(3) */ +#include <stdio.h> /* for snprintf(3) */ #include <string.h> /* for strncpy(3) */ #include <unistd.h> /* for getpid(2),close(2) */ #include <time.h> /* for ctime(3) */ Modified: code/player/trunk/rtk2/rtk_canvas.c =================================================================== --- code/player/trunk/rtk2/rtk_canvas.c 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/rtk2/rtk_canvas.c 2009-01-11 00:44:30 UTC (rev 7264) @@ -792,7 +792,11 @@ // Save PPM image fprintf(file, "P6\n%d %d\n255\n", sizex, sizey); - fwrite(image, sizex * sizey * 3, 1, file); + int ret = fwrite(image, sizex * sizey * 3, 1, file); + if (ret < 0) + { + fprintf(stderr,"Failed to write Image"); + } fclose(file); return 0; Modified: code/player/trunk/server/drivers/camera/1394/camera1394.cc =================================================================== --- code/player/trunk/server/drivers/camera/1394/camera1394.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/camera/1394/camera1394.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -588,6 +588,7 @@ // Parse camera settings - default is to leave them alone. str = cf->ReadString(section, "brightness", "NONE"); if (strcmp(str,"NONE")) + { if (!strcmp(str,"auto")) { this->setBrightness=true; @@ -599,8 +600,10 @@ this->autoBrightness=false; this->brightness = atoi(str); } + } str = cf->ReadString(section, "exposure", "NONE"); if (strcmp(str,"NONE")) + { if (!strcmp(str,"auto")) { this->setExposure=true; @@ -612,8 +615,10 @@ this->autoExposure=false; this->exposure = atoi(str); } + } str = cf->ReadString(section, "shutter", "NONE"); if (strcmp(str,"NONE")) + { if (!strcmp(str,"auto")) { this->setShutter=true; @@ -625,8 +630,10 @@ this->autoShutter=false; this->shutter = atoi(str); } + } str = cf->ReadString(section, "gain", "NONE"); if (strcmp(str,"NONE")) + { if (!strcmp(str,"auto")) { this->setGain=true; @@ -638,12 +645,15 @@ this->autoGain=false; this->gain = atoi(str); } + } str = cf->ReadString(section, "whitebalance", "NONE"); if (strcmp(str,"NONE")) + { if(sscanf(str,"%u %u",&this->blueBalance,&this->redBalance)==2) this->setWhiteBalance=true; else PLAYER_ERROR1("didn't understand white balance values [%s]", str); + } // Force into raw mode this->forceRaw = cf->ReadInt(section, "force_raw", 0); @@ -1369,22 +1379,27 @@ return -1; } + int ret = 0; switch (this->data->format) { case PLAYER_CAMERA_FORMAT_MONO8: fprintf(fp,"P5\n%u %u\n255\n", this->data->width, this->data->height); - fwrite((unsigned char*)this->data->image, 1, this->data->image_count, fp); + ret = fwrite((unsigned char*)this->data->image, 1, this->data->image_count, fp); break; case PLAYER_CAMERA_FORMAT_RGB888: fprintf(fp,"P6\n%u %u\n255\n", this->data->width, this->data->height); - fwrite((unsigned char*)this->data->image, 1, this->data->image_count, fp); + ret = fwrite((unsigned char*)this->data->image, 1, this->data->image_count, fp); break; default: break; } - fclose(fp); + if (ret < 0) + { + PLAYER_ERROR("Failed to save frame"); + } + return 0; } Modified: code/player/trunk/server/drivers/camera/compress/cameracompress.cc =================================================================== --- code/player/trunk/server/drivers/camera/compress/cameracompress.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/camera/compress/cameracompress.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -308,7 +308,9 @@ { snprintf(filename, sizeof(filename), "click-%04d.jpeg",this->frameno++); FILE *fp = fopen(filename, "w+"); - fwrite(this->data.image, 1, this->data.image_count, fp); + int ret = fwrite(this->data.image, 1, this->data.image_count, fp); + if (ret < 0) + PLAYER_ERROR("Failed to save frame"); fclose(fp); } Modified: code/player/trunk/server/drivers/camera/compress/camerauncompress.cc =================================================================== --- code/player/trunk/server/drivers/camera/compress/camerauncompress.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/camera/compress/camerauncompress.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -249,7 +249,9 @@ { snprintf(filename, sizeof(filename), "click-%04d.ppm",this->frameno++); FILE *fp = fopen(filename, "w+"); - fwrite (this->data.image, 1, this->data.image_count, fp); + int ret = fwrite (this->data.image, 1, this->data.image_count, fp); + if (ret < 0) + PLAYER_ERROR("Failed to save frame"); fclose(fp); } Modified: code/player/trunk/server/drivers/camera/v4l/v4lcapture.c =================================================================== --- code/player/trunk/server/drivers/camera/v4l/v4lcapture.c 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/camera/v4l/v4lcapture.c 2009-01-11 00:44:30 UTC (rev 7264) @@ -50,7 +50,7 @@ // Requires: 1. The Video4Linux subsystem to be properly initialised // 2. Either a valid device name (such as "/dev/bttv") or // NULL to use the default. -// +// // Promises: 1. To open the video device // 2. Initialise the video device to reasonable defaults // 3. To not leak any memory by freeing upon any error @@ -161,7 +161,7 @@ free( fg ); return NULL; } - + // set the default max_buffer fg->max_buffer = fg->mbuf.frames; @@ -189,7 +189,7 @@ void fg_close(FRAMEGRABBER* fg) { - munmap( fg->mb_map, fg->mbuf.size); + munmap( fg->mb_map, fg->mbuf.size); close( fg->fd ); // Make sure we free all memory (backwards!) @@ -415,7 +415,7 @@ { capture_frame = 0; } - + // Set up capture parameters fg->mmap.format = fg->picture.palette; fg->mmap.frame = capture_frame; @@ -477,10 +477,16 @@ fg->window.height, fg->picture.palette ); - read( fg->fd, + int ret = read( fg->fd, fr->data, frame_get_size( fr ) ); + if (ret < 0) + { + fprintf(stderr,"Failed to read from frame grabber"); + return NULL; + } + return fr; } Modified: code/player/trunk/server/drivers/camera/v4l/v4lframe.c =================================================================== --- code/player/trunk/server/drivers/camera/v4l/v4lframe.c 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/camera/v4l/v4lframe.c 2009-01-11 00:44:30 UTC (rev 7264) @@ -83,7 +83,7 @@ // 3 bytes per pixel size = pixels * 3; break; - + case VIDEO_PALETTE_RGB32: // 4 bytes (1 int) per pixel size = pixels * 4; @@ -225,10 +225,12 @@ fprintf( fp, "255\n" ); // Dump raw image data - fwrite( fr->data, + int ret = fwrite( fr->data, 1, // YUV422 has 1 byte per pixel fr->width * fr->height, fp ); + if (ret < 0) + fprintf(stderr,"Failed to write image"); break; case VIDEO_PALETTE_YUV420P: Modified: code/player/trunk/server/drivers/imu/MTComm.cpp =================================================================== --- code/player/trunk/server/drivers/imu/MTComm.cpp 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/imu/MTComm.cpp 2009-01-11 00:44:30 UTC (rev 7264) @@ -74,7 +74,7 @@ // - Deleted obsolete functions // - Changed function getLastErrorCode into getLastDeviceError // - Changed OpenPort function for compatiblity with Bluetooth ports -// - Added workaround for lockup of USB driver (close function) +// - Added workaround for lockup of USB driver (close function) // - Added workaround for clock() problem with read function of USB driver // // v1.0.2 @@ -92,7 +92,7 @@ // ---------------------------------------------------------------------------- // This file is an Xsens Code Examples. // -// Copyright (C) Xsens Technologies B.V., 2005. +// Copyright (C) Xsens Technologies B.V., 2005. // // This source code is intended only as a example of the implementation // of the Xsens MT Communication protocol. @@ -150,7 +150,7 @@ // // Calculates the processor time used by the calling process. // For linux use gettimeofday instead of clock() function -// When using read from FTDI serial port in a loop the +// When using read from FTDI serial port in a loop the // clock() function very often keeps returning 0. // // Output @@ -195,11 +195,11 @@ if (m_fileOpen || m_portOpen) { return (m_retVal = MTRV_ANINPUTALREADYOPEN); } -#ifdef WIN32 +#ifdef WIN32 char pchFileName[10]; - - sprintf(pchFileName,"\\\\.\\COM%d",portNumber); // Create file name + snprintf(pchFileName,10,"\\\\.\\COM%d",portNumber); // Create file name + m_handle = CreateFile(pchFileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (m_handle == INVALID_HANDLE_VALUE) { return (m_retVal = MTRV_INPUTCANNOTBEOPENED); @@ -217,14 +217,14 @@ dcb.Parity = NOPARITY; // Setup the Parity dcb.ByteSize = 8; // Setup the data bits dcb.StopBits = TWOSTOPBITS; // Setup the stop bits - dcb.fDsrSensitivity = FALSE; // Setup the flow control + dcb.fDsrSensitivity = FALSE; // Setup the flow control dcb.fOutxCtsFlow = FALSE; // NoFlowControl: dcb.fOutxDsrFlow = FALSE; dcb.fOutX = FALSE; dcb.fInX = FALSE; if (!SetCommState(m_handle, (LPDCB)&dcb)) {// Set new state // Bluetooth ports cannot always be opened with 2 stopbits - // Now try to open port with 1 stopbit. + // Now try to open port with 1 stopbit. dcb.StopBits = ONESTOPBIT; if (!SetCommState(m_handle, (LPDCB)&dcb)) { CloseHandle(m_handle); @@ -242,12 +242,12 @@ // immediate return if data is available, wait 1ms otherwise CommTimeouts.ReadTotalTimeoutConstant = 1; CommTimeouts.ReadIntervalTimeout = MAXDWORD; - CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD; + CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD; // immediate return whether data is available or not // CommTimeouts.ReadTotalTimeoutConstant = 0; // CommTimeouts.ReadIntervalTimeout = MAXDWORD; -// CommTimeouts.ReadTotalTimeoutMultiplier = 0; +// CommTimeouts.ReadTotalTimeoutMultiplier = 0; SetCommTimeouts(m_handle, &CommTimeouts); // Set CommTimeouts structure @@ -259,13 +259,13 @@ PurgeComm(m_handle, PURGE_TXCLEAR | PURGE_RXCLEAR); return (m_retVal = MTRV_OK); -#else +#else char chPort[15]; struct termios options; /* Open port */ - sprintf(chPort,"/dev/ttyS%d",(portNumber - 1)); - + snprintf(chPort,15,"/dev/ttyS%d",(portNumber - 1)); + m_handle = open(chPort, O_RDWR | O_NOCTTY); // O_RDWR: Read+Write @@ -283,11 +283,11 @@ /* Start configuring of port for non-canonical transfer mode */ // Get current options for the port tcgetattr(m_handle, &options); - - // Set baudrate. + + // Set baudrate. cfsetispeed(&options, baudrate); cfsetospeed(&options, baudrate); - + // Enable the receiver and set local mode options.c_cflag |= (CLOCAL | CREAD); // Set character size to data bits and set no parity Mask the characte size bits @@ -307,11 +307,11 @@ // Set the new options for the port tcsetattr(m_handle,TCSANOW, &options); - + tcflush(m_handle, TCIOFLUSH); return (m_retVal = MTRV_OK); -#endif +#endif } //////////////////////////////////////////////////////////////////// @@ -335,7 +335,7 @@ if (m_fileOpen || m_portOpen) { return (m_retVal = MTRV_ANINPUTALREADYOPEN); } -#ifdef WIN32 +#ifdef WIN32 m_handle = CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (m_handle == INVALID_HANDLE_VALUE) { return (m_retVal = MTRV_INPUTCANNOTBEOPENED); @@ -353,14 +353,14 @@ dcb.Parity = NOPARITY; // Setup the Parity dcb.ByteSize = 8; // Setup the data bits dcb.StopBits = TWOSTOPBITS; // Setup the stop bits - dcb.fDsrSensitivity = FALSE; // Setup the flow control + dcb.fDsrSensitivity = FALSE; // Setup the flow control dcb.fOutxCtsFlow = FALSE; // NoFlowControl: dcb.fOutxDsrFlow = FALSE; dcb.fOutX = FALSE; dcb.fInX = FALSE; if (!SetCommState(m_handle, (LPDCB)&dcb)) {// Set new state // Bluetooth ports cannot always be opened with 2 stopbits - // Now try to open port with 1 stopbit. + // Now try to open port with 1 stopbit. dcb.StopBits = ONESTOPBIT; if (!SetCommState(m_handle, (LPDCB)&dcb)) { CloseHandle(m_handle); @@ -378,12 +378,12 @@ // immediate return if data is available, wait 1ms otherwise CommTimeouts.ReadTotalTimeoutConstant = 1; CommTimeouts.ReadIntervalTimeout = MAXDWORD; - CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD; + CommTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD; // immediate return whether data is available or not // CommTimeouts.ReadTotalTimeoutConstant = 0; // CommTimeouts.ReadIntervalTimeout = MAXDWORD; -// CommTimeouts.ReadTotalTimeoutMultiplier = 0; +// CommTimeouts.ReadTotalTimeoutMultiplier = 0; SetCommTimeouts(m_handle, &CommTimeouts); // Set CommTimeouts structure // Other initialization functions @@ -394,11 +394,11 @@ PurgeComm(m_handle, PURGE_TXCLEAR | PURGE_RXCLEAR); return (m_retVal = MTRV_OK); -#else +#else struct termios options; /* Open port */ - + m_handle = open(portName, O_RDWR | O_NOCTTY); // O_RDWR: Read+Write @@ -409,15 +409,15 @@ // Port not open return (m_retVal = MTRV_INPUTCANNOTBEOPENED); } - + // Once here, port is open m_portOpen = true; /* Start configuring of port for non-canonical transfer mode */ // Get current options for the port tcgetattr(m_handle, &options); - - // Set baudrate. + + // Set baudrate. cfsetispeed(&options, baudrate); cfsetospeed(&options, baudrate); @@ -440,11 +440,11 @@ // Set the new options for the port tcsetattr(m_handle,TCSANOW, &options); - + tcflush(m_handle, TCIOFLUSH); return (m_retVal = MTRV_OK); -#endif +#endif } //////////////////////////////////////////////////////////////////// @@ -469,7 +469,7 @@ if (m_portOpen || m_portOpen) { return (m_retVal = MTRV_ANINPUTALREADYOPEN); } -#ifdef WIN32 +#ifdef WIN32 DWORD disposition = OPEN_ALWAYS; if (createAlways == true) { disposition = CREATE_ALWAYS; @@ -573,7 +573,7 @@ } } while (j < nBytesToRead); - + return j; */ #endif @@ -591,7 +591,7 @@ // // Output // number of bytes actually written -// +// // The MTComm return value is != MTRV_OK if serial port is closed int CMTComm::writeData(const unsigned char* msgBuffer, const int nBytesToWrite) { @@ -599,7 +599,7 @@ m_retVal = MTRV_NOINPUTINITIALIZED; return 0; } - + m_retVal = MTRV_OK; #ifdef WIN32 DWORD nBytesWritten; @@ -613,7 +613,7 @@ //////////////////////////////////////////////////////////////////// // flush // -// Remove any 'old' data in COM port buffer and flushes internal +// Remove any 'old' data in COM port buffer and flushes internal // temporary buffer // void CMTComm::flush() @@ -673,7 +673,7 @@ // origin is specified in moveMethod // moveMethod : FILEPOS_BEGIN, FILEPOS_CURRENT or FILEPOS_END // Output -// +// // returns MTRV_OK if file pointer is successfully set // short CMTComm::setFilePos(long relPos, unsigned long moveMethod) @@ -702,7 +702,7 @@ // Input // Output // fileSize : Number of bytes of the current file -// +// // returns MTRV_OK if successful // short CMTComm::getFileSize(unsigned long &fileSize) @@ -758,7 +758,7 @@ //////////////////////////////////////////////////////////////////// // readMessage // -// Reads the next message from serial port buffer or file. +// Reads the next message from serial port buffer or file. // To be read within current time out period // // Input @@ -767,7 +767,7 @@ // data : array pointer to data bytes (no header) // dataLen : number of data bytes read // bid : BID or address of message read (optional) -// +// // returns MTRV_OK if a message has been read else <>MTRV_OK // // Remarks @@ -899,7 +899,7 @@ nBytesToRead = 0; } } - + // Check if serial port buffer must be read if (nBytesToRead > 0) { nBytesRead = readData(msgBuffer+nOffset, nBytesToRead); @@ -910,7 +910,7 @@ nBytesToRead -= nBytesRead; nBytesRead = 0; } - + if(nBytesToRead == 0){ switch(state){ case 0: // Check preamble @@ -931,7 +931,7 @@ else { state = 2; nBytesToRead = 2; // Read extended length - } + } break; case 2: state = 3; @@ -990,7 +990,7 @@ } } } while((clkEnd >= clockms()) || m_timeOut == 0 || nBytesRead != 0); - + // Check if pending message has a valid message if(state > 0){ int i; @@ -1013,7 +1013,7 @@ } break; } - + return (m_retVal = MTRV_TIMEOUT); } @@ -1040,16 +1040,16 @@ // = MTRV_TIMEOUT if timeout occurred // = MTRV_NOINPUTINITIALIZED // -short CMTComm::writeMessage(const unsigned char mid, const unsigned long dataValue, +short CMTComm::writeMessage(const unsigned char mid, const unsigned long dataValue, const unsigned char dataValueLen, const unsigned char bid) { unsigned char buffer[MAXMSGLEN]; short msgLen; - + if (!(m_fileOpen || m_portOpen)) { return (m_retVal = MTRV_NOINPUTINITIALIZED); } - + buffer[IND_PREAMBLE] = PREAMBLE; buffer[IND_BID] = bid; buffer[IND_MID] = mid; @@ -1058,13 +1058,13 @@ calcChecksum(buffer,LEN_MSGHEADER + dataValueLen); // Send message - writeData(buffer, LEN_MSGHEADERCS + dataValueLen); + writeData(buffer, LEN_MSGHEADERCS + dataValueLen); // Return if file opened if (m_fileOpen) { return (m_retVal = MTRV_OK); } - + // Keep reading until an Ack or Error message is received (or timeout) clock_t clkStart, clkOld; bool msgRead = false; @@ -1117,7 +1117,7 @@ // = MTRV_TIMEOUT if timeout occurred // = MTRV_NOINPUTINITIALIZED // -short CMTComm::writeMessage(const unsigned char mid, const unsigned char data[], +short CMTComm::writeMessage(const unsigned char mid, const unsigned char data[], const unsigned short &dataLen, const unsigned char bid) { unsigned char buffer[MAXMSGLEN]; @@ -1190,7 +1190,7 @@ // waitForMessage // // Read messages from serial port or file using the current timeout period -// until the received message is equal to a specific message identifier +// until the received message is equal to a specific message identifier // By default the timeout period by file input is set to infinity (= until // end of file is reached) // @@ -1298,7 +1298,7 @@ // Acknowledge received value = 0; swapEndian(&buffer[IND_DATA0],(unsigned char *)&value, buffer[IND_LEN]); - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -1330,7 +1330,7 @@ // // value contains the integer value of the data field of the ack message // -short CMTComm::reqSetting(const unsigned char mid, const unsigned char param, unsigned long &value, +short CMTComm::reqSetting(const unsigned char mid, const unsigned char param, unsigned long &value, const unsigned char bid) { unsigned char buffer[MAXMSGLEN]; @@ -1369,7 +1369,7 @@ else{ swapEndian(&buffer[IND_DATA0]+1,(unsigned char *)&value, buffer[IND_LEN]-1); } - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -1426,7 +1426,7 @@ // Acknowledge received value = 0; swapEndian(&buffer[IND_DATA0],(unsigned char *)&value, buffer[IND_LEN]); - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -1496,7 +1496,7 @@ else{ swapEndian(&buffer[IND_DATA0]+1,(unsigned char *)&value, buffer[IND_LEN]-1); } - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -1518,7 +1518,7 @@ // Input // mid : Message ID of message to send // bid : Bus ID of message to send (def 0xFF) -// +// // Output // = MTRV_OK if an Ack message is received // = MTRV_RECVERRORMSG if an error message is received @@ -1527,7 +1527,7 @@ // data[] contains the data of the acknowledge message // dataLen contains the number bytes returned // -short CMTComm::reqSetting(const unsigned char mid, +short CMTComm::reqSetting(const unsigned char mid, unsigned char data[], short &dataLen, const unsigned char bid) { unsigned char buffer[MAXMSGLEN]; @@ -1562,7 +1562,7 @@ dataLen = buffer[IND_LENEXTH]*256 + buffer[IND_LENEXTL]; memcpy(data, &buffer[IND_DATAEXT0], dataLen); } - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -1586,7 +1586,7 @@ // bid : Bus ID of message to send (def 0xFF) // dataIn : Data to be included in request // dataInLen : Number of bytes in dataIn -// +// // Output // = MTRV_OK if an Ack message is received // = MTRV_RECVERRORMSG if an error message is received @@ -1642,7 +1642,7 @@ dataOutLen = buffer[IND_LENEXTH]*256 + buffer[IND_LENEXTL]; memcpy(dataOut, &buffer[IND_DATAEXT0], dataOutLen); } - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -1666,7 +1666,7 @@ // mid : Message ID of message to send // param : For messages that need a parameter (optional) // bid : Bus ID of message to send (def 0xFF) -// +// // Output // = MTRV_OK if an Ack message is received // = MTRV_RECVERRORMSG if an error message is received @@ -1675,7 +1675,7 @@ // data[] contains the data of the acknowledge message (including param!!) // dataLen contains the number bytes returned // -short CMTComm::reqSetting(const unsigned char mid, const unsigned char param, +short CMTComm::reqSetting(const unsigned char mid, const unsigned char param, unsigned char data[], short &dataLen, const unsigned char bid) { unsigned char buffer[MAXMSGLEN]; @@ -1716,7 +1716,7 @@ dataLen = buffer[IND_LENEXTH]*256 + buffer[IND_LENEXTL]; memcpy(data, &buffer[IND_DATAEXT0], dataLen); } - return (m_retVal = MTRV_OK); + return (m_retVal = MTRV_OK); } else if (buffer[IND_MID] == MID_ERROR){ m_deviceError = buffer[IND_DATA0]; @@ -2034,46 +2034,46 @@ // // Requests the current output mode/setting of input (file or serialport) // the Outputmode, Outputsettings, DataLength & number of devices -// are stored in member variables of the MTComm class. These values +// are stored in member variables of the MTComm class. These values // are needed for the GetValue functions. // The function optionally returns the number of devices // // File: expects the Configuration message at the start of the file -// which holds the OutputMode & OutputSettings. File position +// which holds the OutputMode & OutputSettings. File position // is after the first message // // Input // Output // numDevices : [optional] number of devices connected to port or // found in configuration file -// +// // returns MTRV_OK if the mode & settings are read // short CMTComm::getDeviceMode(unsigned short *numDevices) { unsigned char mid, data[MAXMSGLEN]; short datalen; - + if (numDevices != NULL) { *numDevices = 0; } - + // In case serial port is used (live device / XM or MT) if (m_portOpen) { if (reqSetting(MID_INITBUS,data,datalen) != MTRV_OK) { return m_retVal; } - + // Retrieve outputmode + outputsettings for (int i = 0; i < datalen / LEN_DEVICEID; i++) { if (reqSetting(MID_REQOUTPUTMODE,m_storedOutputMode[BID_MT+i],BID_MT+i) != MTRV_OK) { return m_retVal; } - + if (reqSetting(MID_REQOUTPUTSETTINGS,m_storedOutputSettings[BID_MT+i],BID_MT+i) != MTRV_OK) { return m_retVal; } - + if (reqSetting(MID_REQDATALENGTH,m_storedDataLength[BID_MT+i],BID_MT+i) != MTRV_OK) { return m_retVal; } @@ -2082,14 +2082,14 @@ if (numDevices != NULL) { *numDevices = datalen / LEN_DEVICEID; } - + unsigned char masterDID[4]; short DIDlen; if(reqSetting(MID_REQDID,masterDID,DIDlen) != MTRV_OK) { return m_retVal; } - + if (memcmp(masterDID,data,LEN_DEVICEID) != 0) { // Using an XbusMaster m_storedOutputMode[0] = OUTPUTMODE_XM; @@ -2112,13 +2112,13 @@ swapEndian(data+CONF_NUMDEVICES, (unsigned char *)&_numDevices,CONF_NUMDEVICESLEN); for(unsigned int i = 0; i < _numDevices; i++){ m_storedOutputMode[BID_MT+i] = 0; - swapEndian(data+CONF_OUTPUTMODE+i*CONF_BLOCKLEN, (unsigned char *)(m_storedOutputMode+BID_MT+i), + swapEndian(data+CONF_OUTPUTMODE+i*CONF_BLOCKLEN, (unsigned char *)(m_storedOutputMode+BID_MT+i), CONF_OUTPUTMODELEN); m_storedOutputSettings[BID_MT+i] = 0; - swapEndian(data+CONF_OUTPUTSETTINGS+i*CONF_BLOCKLEN, (unsigned char *)(m_storedOutputSettings+BID_MT+i), + swapEndian(data+CONF_OUTPUTSETTINGS+i*CONF_BLOCKLEN, (unsigned char *)(m_storedOutputSettings+BID_MT+i), CONF_OUTPUTSETTINGSLEN); m_storedDataLength[BID_MT+i] = 0; - swapEndian(data+CONF_DATALENGTH+i*CONF_BLOCKLEN, (unsigned char *)(m_storedDataLength+BID_MT+i), + swapEndian(data+CONF_DATALENGTH+i*CONF_BLOCKLEN, (unsigned char *)(m_storedDataLength+BID_MT+i), CONF_DATALENGTHLEN); } if (numDevices != NULL) { @@ -2146,16 +2146,16 @@ //////////////////////////////////////////////////////////////////// // setDeviceMode // -// Sets the current output mode/setting of input (not for file-based +// Sets the current output mode/setting of input (not for file-based // inputs) // // Input -// OutputMode : OutputMode to be set in device & stored in MTComm +// OutputMode : OutputMode to be set in device & stored in MTComm // class member variable -// OutputSettings : OutputSettings to be set in device & stored in +// OutputSettings : OutputSettings to be set in device & stored in // MTComm class member variable // Output -// +// // returns MTRV_OK if the mode & settings are read // short CMTComm::setDeviceMode(unsigned long OutputMode, unsigned long OutputSettings, const unsigned char bid) @@ -2186,7 +2186,7 @@ if (OutputMode != OUTPUTMODE_XM) { unsigned long value; if (reqSetting(MID_REQDATALENGTH, value, bid) == MTRV_OK) { - if (bid == BID_MASTER || bid == BID_MT && m_storedOutputMode[0] != OUTPUTMODE_XM) { + if (bid == BID_MASTER || (bid == BID_MT && m_storedOutputMode[0] != OUTPUTMODE_XM)) { m_storedDataLength[0] = m_storedDataLength[BID_MT] = value; } else{ @@ -2205,17 +2205,17 @@ // getMode // // Gets the output mode/setting used in MTComm class and the corresponding -// datalength. These variables are set by the functions GetDeviceMode, +// datalength. These variables are set by the functions GetDeviceMode, // SetDeviceMode or SetMode // // Input // Output // OutputMode : OutputMode stored in MTComm class member variable // OutputSettings : OutputSettings stored in MTComm class member variable -// +// // returns always MTRV_OK // -short CMTComm::getMode(unsigned long &OutputMode, unsigned long &OutputSettings, +short CMTComm::getMode(unsigned long &OutputMode, unsigned long &OutputSettings, unsigned short &dataLength, const unsigned char bid) { unsigned char nbid = (bid == BID_MASTER)?0:bid; @@ -2236,7 +2236,7 @@ // OutputMode : OutputMode to be stored in MTComm class member variable // OutputSettings : OutputSettings to be stored in MTComm class member variable // Output -// +// // returns always MTRV_OK // short CMTComm::setMode(unsigned long OutputMode, unsigned long OutputSettings, const unsigned char bid) @@ -2309,7 +2309,7 @@ // Retrieves a unsigned short value from the data input parameter // This function is valid for the following value specifiers: // VALUE_RAW_TEMP -// VALUE_SAMPLECNT +// VALUE_SAMPLECNT // // Use getDeviceMode or setMode to initialize the Outputmode // and Outputsettings member variables used to retrieve the correct @@ -2323,12 +2323,12 @@ // Output // value : reference to unsigned short in which the retrieved // value will be returned -// +// // Return value // MTRV_OK : value is successfully retrieved // != MTRV_OK : not successful // -short CMTComm::getValue(const unsigned long valueSpec, unsigned short &value, const unsigned char data[], +short CMTComm::getValue(const unsigned long valueSpec, unsigned short &value, const unsigned char data[], const unsigned char bid) { short offset = 0; @@ -2350,7 +2350,7 @@ offset += (short)m_storedDataLength[i++]; } } - + // Check if data is unsigned short & available in data m_retVal = MTRV_INVALIDVALUESPEC; if (valueSpec == VALUE_RAW_TEMP) { @@ -2376,7 +2376,7 @@ //////////////////////////////////////////////////////////////////// // getValue (array of unsigned short variant) // -// Retrieves an array of unsigned short values from the data input +// Retrieves an array of unsigned short values from the data input // parameter. This function is valid for the following value specifiers: // VALUE_RAW_ACC // VALUE_RAW_GYR @@ -2392,14 +2392,14 @@ // bid : bus identifier of the device of which the // value should be returned (default = BID_MT) // Output -// value[] : pointer to array of unsigned shorts in which the +// value[] : pointer to array of unsigned shorts in which the // retrieved values will be returned -// +// // Return value // MTRV_OK : value is successfully retrieved // != MTRV_OK : not successful // -short CMTComm::getValue(const unsigned long valueSpec, unsigned short value[], const unsigned char data[], +short CMTComm::getValue(const unsigned long valueSpec, unsigned short value[], const unsigned char data[], const unsigned char bid) { short offset = 0; @@ -2440,7 +2440,7 @@ //////////////////////////////////////////////////////////////////// // getValue (array of floats variant) // -// Retrieves an array of float values from the data input parameter. +// Retrieves an array of float values from the data input parameter. // This function is valid for the following value specifiers: // VALUE_TEMP // VALUE_CALIB_ACC @@ -2460,14 +2460,14 @@ // bid : bus identifier of the device of which the // value should be returned (default = BID_MT) // Output -// value[] : pointer to array of floats in which the +// value[] : pointer to array of floats in which the // retrieved values will be returned -// +// // Return value // MTRV_OK : value is successfully retrieved // != MTRV_OK : not successful // -short CMTComm::getValue(const unsigned long valueSpec, float value[], const unsigned char data[], +short CMTComm::getValue(const unsigned long valueSpec, float value[], const unsigned char data[], const unsigned char bid) { short offset = 0; @@ -2501,7 +2501,7 @@ } else if (valueSpec == VALUE_CALIB_ACC) { offset += ((m_storedOutputMode[nbid] & OUTPUTMODE_TEMP) != 0)?LEN_TEMPDATA:0; - if (m_storedOutputMode[nbid] & OUTPUTMODE_CALIB && + if (m_storedOutputMode[nbid] & OUTPUTMODE_CALIB && (m_storedOutputSettings[nbid] & OUTPUTSETTINGS_CALIBMODE_ACC_MASK) == 0) { nElements = LEN_CALIB_ACCDATA / LEN_FLOAT; m_retVal = MTRV_OK; @@ -2509,7 +2509,7 @@ } else if (valueSpec == VALUE_CALIB_GYR) { offset += ((m_storedOutputMode[nbid] & OUTPUTMODE_TEMP) != 0)?LEN_TEMPDATA:0; - if (m_storedOutputMode[nbid] & OUTPUTMODE_CALIB && + if (m_storedOutputMode[nbid] & OUTPUTMODE_CALIB && (m_storedOutputSettings[nbid] & OUTPUTSETTINGS_CALIBMODE_GYR_MASK) == 0) { offset += ((m_storedOutputSettings[nbid] & OUTPUTSETTINGS_CALIBMODE_ACC_MASK) == 0)?LEN_CALIB_ACCX*3:0; nElements = LEN_CALIB_GYRDATA / LEN_FLOAT; @@ -2518,7 +2518,7 @@ } else if (valueSpec == VALUE_CALIB_MAG) { offset += ((m_storedOutputMode[nbid] & OUTPUTMODE_TEMP) != 0)?LEN_TEMPDATA:0; - if (m_storedOutputMode[nbid] & OUTPUTMODE_CALIB && + if (m_storedOutputMode[nbid] & OUTPUTMODE_CALIB && (m_storedOutputSettings[nbid] & OUTPUTSETTINGS_CALIBMODE_MAG_MASK) == 0) { offset += ((m_storedOutputSettings[nbid] & OUTPUTSETTINGS_CALIBMODE_ACC_MASK) == 0)?LEN_CALIB_ACCX*3:0; offset += ((m_storedOutputSettings[nbid] & OUTPUTSETTINGS_CALIBMODE_GYR_MASK) == 0)?LEN_CALIB_GYRX*3:0; @@ -2565,10 +2565,10 @@ swapEndian(data+offset+i*LEN_FLOAT, (unsigned char *)value+i*LEN_FLOAT, LEN_FLOAT); } } - else { + else { int temp; for (int i = 0; i < nElements; i++) { - swapEndian(data+offset+i*LEN_FLOAT, (unsigned char*)&temp, 4); + swapEndian(data+offset+i*LEN_FLOAT, (unsigned char*)&temp, 4); value[i] = (float)temp/1048576; } } @@ -2579,7 +2579,7 @@ ////////////////////////////////////////////////////////////////////// // getLastDeviceError // -// Returns the last reported device error of the latest received Error +// Returns the last reported device error of the latest received Error // message // // Output @@ -2666,7 +2666,7 @@ unsigned char checkSum = 0; int i; - for(i = 1; i < msgBufferLength; i++) + for(i = 1; i < msgBufferLength; i++) checkSum += msgBuffer[i]; msgBuffer[msgBufferLength] = -checkSum; // Store chksum Modified: code/player/trunk/server/drivers/joystick/linuxjoy.cc =================================================================== --- code/player/trunk/server/drivers/joystick/linuxjoy.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/joystick/linuxjoy.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -577,7 +577,12 @@ else if(count > 0) { // get the next event from the joystick - read(this->fd, &event, sizeof(struct js_event)); + int ret = read(this->fd, &event, sizeof(struct js_event)); + if (ret < 0) + { + PLAYER_ERROR("Failed to read from the joystick"); + return; + } //printf( "value % d type %u number %u state %X \n", // event.value, event.type, event.number, this->joy_data.buttons ); Modified: code/player/trunk/server/drivers/laser/RS4Leuze_laser.cc =================================================================== --- code/player/trunk/server/drivers/laser/RS4Leuze_laser.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/laser/RS4Leuze_laser.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -1,6 +1,6 @@ /** laser.cpp V 2.0 -> RS4Leuze_laser.cpp - + Modified by Ernesto Homar Teniente Aviles Date 20 APril 2007 */ @@ -13,8 +13,8 @@ /** Default constructor. */ -//Claser::Claser(ClogMsg *lgMsg, bool *laser_ON, char dir_name[80]) //default constructor. -Claser::Claser(int scan_points) //default constructor. +//Claser::Claser(ClogMsg *lgMsg, bool *laser_ON, char dir_name[80]) //default constructor. +Claser::Claser(int scan_points) //default constructor. { points_to_scan = scan_points; @@ -23,7 +23,7 @@ /** Destructor */ -Claser::~Claser() +Claser::~Claser() { //close port closeSerial(); @@ -49,13 +49,13 @@ // Configure Serial Port: termios settings: 57600(default), No Parity, 8 data bits, 1 stop Bit (8N1) // values of masks in /usr/include/bits/termios.h tcgetattr(serialFD,&ttyset); - ttyset.c_cflag = ( Baud_rate | CLOCAL | CREAD | CS8 ); + ttyset.c_cflag = ( Baud_rate | CLOCAL | CREAD | CS8 ); ttyset.c_iflag = ( IGNBRK ); //Ignores break condition on input ttyset.c_oflag = 0x0; ttyset.c_lflag = 0x0; // Set configuration immediately. - if (tcsetattr(serialFD, TCSANOW, &ttyset)<0) + if (tcsetattr(serialFD, TCSANOW, &ttyset)<0) { PLAYER_ERROR("Claser, Error opening serial port"); *laser_ON=0; @@ -63,15 +63,15 @@ } else - + FD_ZERO(&rfds); // Initialize the read set to zero FD_SET(serialFD, &rfds); // Turn on the read set // set timer - tv.tv_sec = 1; - tv.tv_usec = 0; - + tv.tv_sec = 1; + tv.tv_usec = 0; + //Flush both pending input and untransmitted output. tcflush(serialFD, TCIOFLUSH); @@ -84,7 +84,7 @@ { unsigned char localByte; read (serialFD, &localByte, 1); - checksum = checksum ^ localByte; + checksum = checksum ^ localByte; return localByte; } @@ -94,15 +94,15 @@ void Claser::sync() { int num_zeroes = 0; - + // We must read three consecutive 0x00 for the end of the message while (num_zeroes < 3) - { + { read(serialFD, &byte, 1); - if(byte == 0x00) num_zeroes++; - else num_zeroes = 0; + if(byte == 0x00) num_zeroes++; + else num_zeroes = 0; } - // We are now, for a short time, at the beginning of the message. + // We are now, for a short time, at the beginning of the message. } /** @@ -111,8 +111,8 @@ int Claser::scanRead() { unsigned int ii; - - //******STEP 1: Reading message header + + //******STEP 1: Reading message header for (ii=0; ii<2; ii++) { byte = readByte(); @@ -125,12 +125,12 @@ } } readByte(); //Reads but doesn't analyze command byte - option1=readByte(); //Reads Option1; - if (option1 & 0x03 > 1) + option1=readByte(); //Reads Option1; + if ((option1 & 0x03) > 1) { - byte=readByte(); //Reads Option2 + byte=readByte(); //Reads Option2 } - if (option1 & 0x03 > 2) + if ((option1 & 0x03) > 2) {; byte=readByte(); //Reads Option3 } @@ -176,7 +176,7 @@ if (ii%2 == 0) { // 3.1: reading the first Byte of two from de scaned point - scanedPoint = (readByte() * 256); + scanedPoint = (readByte() * 256); } else { @@ -186,12 +186,12 @@ scanData.Reading[(ii-1)/2] = (double)(scanedPoint/1000.0); } } - + //******STEP 4: Reading Control Byte for checksum and ending message; read(serialFD, &controlByte, 1);//just read without checksum - + /*********************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*****/ - + return(0); } @@ -199,18 +199,18 @@ void Claser::runLaser() { //Claser *thisLaser = (Claser*)thisPnt; - //zeroTimeStamp=clock(); //Initializes time stamp + //zeroTimeStamp=clock(); //Initializes time stamp FD_ZERO(&rfds); // Initialize the read set to zero FD_SET(serialFD, &rfds); // Turn on the read set // set timer - tv.tv_sec = 1; - tv.tv_usec = 0; + tv.tv_sec = 1; + tv.tv_usec = 0; if(select(serialFD+1, &rfds, NULL, NULL, &tv)) { this->sync(); //Synchronizes this->checksum=0x00; //Reset Checksum this->scanRead(); //Read all scan Message - + } else { Modified: code/player/trunk/server/drivers/laser/lms400_cola.cc =================================================================== --- code/player/trunk/server/drivers/laser/lms400_cola.cc 2009-01-10 23:57:55 UTC (rev 7263) +++ code/player/trunk/server/drivers/laser/lms400_cola.cc 2009-01-11 00:44:30 UTC (rev 7264) @@ -17,6 +17,8 @@ #include <unistd.h> #include <string.h> +const int CMD_BUFFER_SIZE=255; + //////////////////////////////////////////////////////////////////////////////// // Constructor. lms400_cola::lms400_cola (const char* host, int port, int debug_mode) @@ -88,8 +90,8 @@ int lms400_cola::EnableRIS (int onoff) { - char cmd[40]; - sprintf (cmd, "sWN MDblex %i", onoff); + char cmd[CMD_BUFFER_SIZE]; + snprintf (cmd, CMD_BUFFER_SIZE, "sWN MDblex %i", onoff); SendCommand (cmd); if (ReadAnswer () != 0) @@ -113,8 +115,8 @@ int lms400_cola::SetMeanFilterParameters (int num_scans) { - char cmd[40]; - sprintf (cmd, "sWN FLmean 0 %i", num_scans); + char cmd[CMD_BUFFER_SIZE]; + snprintf (cmd, CMD_BUFFER_SIZE, "sWN FLmean 0 %i", num_scans); SendCommand (cmd); if (ReadAnswer () != 0) @@ -128,8 +130,8 @@ int lms400_cola::SetRangeFilterParameters (float *ranges) { - char cmd[40]; - sprintf (cmd, "sWN FLrang %+f %+f", ranges[0], ranges[1]); + char cmd[CMD_BUFFER_SIZE]; + snprintf (cmd, CMD_BUFFER_SIZE, "sWN FLrang... [truncated message content] |
From: <th...@us...> - 2009-01-11 18:48:04
|
Revision: 7266 http://playerstage.svn.sourceforge.net/playerstage/?rev=7266&view=rev Author: thjc Date: 2009-01-11 18:48:00 +0000 (Sun, 11 Jan 2009) Log Message: ----------- Applied patch 2303195: joystick interface expansion Also re enables the joystick proxies Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/client_libs/libplayerc/dev_joystick.c code/player/trunk/client_libs/libplayerc/playerc.h code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/playerc++.h code/player/trunk/libplayercore/interfaces/049_joystick.def code/player/trunk/server/drivers/joystick/linuxjoy.cc Added Paths: ----------- code/player/trunk/client_libs/libplayerc++/joystickproxy.cc Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-01-11 18:48:00 UTC (rev 7266) @@ -27,6 +27,7 @@ dev_health.c dev_imu.c dev_ir.c + dev_joystick.c dev_laser.c dev_limb.c dev_localize.c Modified: code/player/trunk/client_libs/libplayerc/dev_joystick.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_joystick.c 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/client_libs/libplayerc/dev_joystick.c 2009-01-11 18:48:00 UTC (rev 7266) @@ -1,4 +1,4 @@ -/* +/* * libplayerc : a Player client library * Copyright (C) Andrew Howard 2002-2003 * @@ -20,8 +20,8 @@ /* * Player - One Hell of a Robot Server * Copyright (C) Andrew Howard 2003 - * * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -37,19 +37,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /*************************************************************************** - * Desc: Joystick device proxy + * Desc: joystick proxy. * Author: Andrew Howard - * Date: 13 May 2002 + * Date: 26 May 2002 * CVS: $Id$ **************************************************************************/ +#if HAVE_CONFIG_H + #include "config.h" +#endif #include <math.h> #include <stdlib.h> #include <string.h> +#include <netinet/in.h> #include "playerc.h" #include "error.h" +// Local declarations +void playerc_joystick_putmsg(playerc_joystick_t *device, + player_msghdr_t *header, + player_joystick_data_t *data, + size_t len); // Create a new joystick proxy playerc_joystick_t *playerc_joystick_create(playerc_client_t *client, int index) @@ -59,9 +68,8 @@ device = malloc(sizeof(playerc_joystick_t)); memset(device, 0, sizeof(playerc_joystick_t)); playerc_device_init(&device->info, client, PLAYER_JOYSTICK_CODE, index, - (playerc_putdata_fn_t) playerc_joystick_putdata,NULL,NULL); + (playerc_putmsg_fn_t) playerc_joystick_putmsg); - return device; } @@ -71,8 +79,6 @@ { playerc_device_term(&device->info); free(device); - - return; } @@ -91,13 +97,26 @@ // Process incoming data -void playerc_joystick_putdata(playerc_joystick_t *device, player_msghdr_t *header, - player_joystick_data_t *data, size_t len) +void playerc_joystick_putmsg(playerc_joystick_t *device, player_msghdr_t *header, + player_joystick_data_t *data, size_t len) { - device->px = (double) (int16_t) ntohs(data->xpos) / (double) (int16_t) ntohs(data->xscale); - device->py = (double) (int16_t) ntohs(data->ypos) / (double) (int16_t) ntohs(data->yscale); - device->buttons = ntohs(data->buttons); - + int i; + if((header->type == PLAYER_MSGTYPE_DATA) && + (header->subtype == PLAYER_JOYSTICK_DATA_STATE)) + { + + device->buttons = data->buttons; + device->axes_count = data->axes_count; + for (i = 0; i < data->axes_count ; i++) + device->pos[i] = data->pos[i]; + + + } + else + PLAYERC_WARN2("skipping joystick message with unknown type/subtype: %s/%d\n", + msgtype_to_str(header->type), header->subtype); return; } + + Modified: code/player/trunk/client_libs/libplayerc/playerc.h =================================================================== --- code/player/trunk/client_libs/libplayerc/playerc.h 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/client_libs/libplayerc/playerc.h 2009-01-11 18:48:00 UTC (rev 7266) @@ -51,7 +51,7 @@ #ifndef PLAYERC_H #define PLAYERC_H -#include <netinet/in.h> // need this for struct sockaddr_in +#include <netinet/in.h> /* need this for struct sockaddr_in */ #include <stdio.h> #include <playerconfig.h> @@ -64,7 +64,7 @@ typedef void * GEOSGeom; #endif -// Get the message structures from Player +/* Get the message structures from Player*/ #include <libplayercore/playercommon.h> #include <libplayercore/player.h> #include <libplayercore/error.h> @@ -332,10 +332,10 @@ const char *playerc_error_str(void); /** Get the name for a given interface code. */ -//const char *playerc_lookup_name(int code); +/*const char *playerc_lookup_name(int code);*/ /** Get the interface code for a given name. */ -//int playerc_lookup_code(const char *name); +/*int playerc_lookup_code(const char *name);*/ /** Add new entries to the XDR function table. */ int playerc_add_xdr_ftable(playerxdr_function_t *flist, int replace); @@ -344,13 +344,13 @@ /***************************************************************************/ -// Forward declare types +/* Forward declare types*/ struct _playerc_client_t; struct _playerc_device_t; -// forward declaration to avoid including <sys/poll.h>, which may not be -// available when people are building clients against this lib +/* forward declaration to avoid including <sys/poll.h>, which may not be + available when people are building clients against this lib*/ struct pollfd; @@ -365,7 +365,7 @@ @{ */ -// Items in incoming data queue. +/* Items in incoming data queue.*/ typedef struct { player_msghdr_t header; @@ -373,36 +373,36 @@ } playerc_client_item_t; -// Multi-client data +/* Multi-client data*/ typedef struct { - // List of clients being managed + /* List of clients being managed*/ int client_count; struct _playerc_client_t *client[128]; - // Poll info + /* Poll info*/ struct pollfd* pollfd; - // Latest time received from any server + /* Latest time received from any server*/ double time; } playerc_mclient_t; -// Create a multi-client object +/* Create a multi-client object*/ playerc_mclient_t *playerc_mclient_create(void); -// Destroy a multi-client object +/* Destroy a multi-client object*/ void playerc_mclient_destroy(playerc_mclient_t *mclient); -// Add a client to the multi-client (private). +/* Add a client to the multi-client (private).*/ int playerc_mclient_addclient(playerc_mclient_t *mclient, struct _playerc_client_t *client); -// Test to see if there is pending data. -// Returns -1 on error, 0 or 1 otherwise. +/* Test to see if there is pending data. + Returns -1 on error, 0 or 1 otherwise.*/ int playerc_mclient_peek(playerc_mclient_t *mclient, int timeout); -// Read incoming data. The timeout is in ms. Set timeout to a -// negative value to wait indefinitely. +/* Read incoming data. The timeout is in ms. Set timeout to a + negative value to wait indefinitely.*/ int playerc_mclient_read(playerc_mclient_t *mclient, int timeout); /** @} */ @@ -739,11 +739,11 @@ */ void *playerc_client_read(playerc_client_t *client); -// Read and process a packet (nonblocking) -// returns 0 if no data recieved, 1 if data recieved and -1 on error +/* Read and process a packet (nonblocking) + returns 0 if no data recieved, 1 if data recieved and -1 on error*/ int playerc_client_read_nonblock(playerc_client_t *client); -// Read and process a packet (nonblocking), fills in pointer to proxy that got data -// returns 0 if no data recieved, 1 if data recieved and -1 on error +/* Read and process a packet (nonblocking), fills in pointer to proxy that got data + returns 0 if no data recieved, 1 if data recieved and -1 on error*/ int playerc_client_read_nonblock_withproxy(playerc_client_t *client, void ** proxy); /** @brief Set the timeout for client requests. @@ -908,10 +908,10 @@ /** Device info; must be at the start of all device structures. */ playerc_device_t info; - /// The number of valid analog inputs. + /* The number of valid analog inputs.*/ uint8_t voltages_count; - /// A bitfield of the current digital inputs. + /* A bitfield of the current digital inputs.*/ float *voltages; } playerc_aio_t; @@ -1035,7 +1035,7 @@ /** @brief Set the speed of a joint (-1 for all joints) for all subsequent movement commands. */ int playerc_actarray_speed_config(playerc_actarray_t *device, int joint, float speed); -// Set the accelration of a joint (-1 for all joints) for all subsequent movement commands +/* Set the accelration of a joint (-1 for all joints) for all subsequent movement commands*/ int playerc_actarray_accel_config(playerc_actarray_t *device, int joint, float accel); @@ -1440,10 +1440,10 @@ /** Device info; must be at the start of all device structures. */ playerc_device_t info; - /// The number of valid digital inputs. + /*/ The number of valid digital inputs.*/ uint8_t count; - /// A bitfield of the current digital inputs. + /*/ A bitfield of the current digital inputs.*/ uint32_t digin; } playerc_dio_t; @@ -1844,10 +1844,10 @@ /** Device info; must be at the start of all device structures. */ playerc_device_t info; - // data + /* data*/ player_ir_data_t data; - // config + /* config*/ player_ir_pose_t poses; } playerc_ir_t; @@ -1878,7 +1878,47 @@ /***************************************************************************/ +/***************************************************************************/ +/** @ingroup playerc_proxies + * @defgroup playerc_proxy_joystick joystick +The joystick proxy can be used to get images from a joystick. + +@{ +*/ + +/** @brief joystick proxy data. */ +typedef struct +{ + /** Device info; must be at the start of all device structures. */ + playerc_device_t info; + int32_t axes_count; + int32_t pos[8]; + uint32_t buttons; + int * axes_max; + int * axes_min; + double * scale_pos; + + +} playerc_joystick_t; + + +/** @brief Create a joystick proxy. */ +playerc_joystick_t *playerc_joystick_create(playerc_client_t *client, int index); + +/** @brief Destroy a joystick proxy. */ +void playerc_joystick_destroy(playerc_joystick_t *device); + +/** @brief Subscribe to the joystick device. */ +int playerc_joystick_subscribe(playerc_joystick_t *device, int access); + +/** @brief Un-subscribe from the joystick device. */ +int playerc_joystick_unsubscribe(playerc_joystick_t *device); + +/** @} */ +/**************************************************************************/ + + /***************************************************************************/ /** @ingroup playerc_proxies * @defgroup playerc_proxy_laser laser @@ -3299,8 +3339,8 @@ playerc_device_t info; char *rawText; - // Just estimating that no more than 20 words will be spoken between updates. - // Assuming that the longest word is <= 30 characters. + /* Just estimating that no more than 20 words will be spoken between updates. + Assuming that the longest word is <= 30 characters.*/ char **words; int wordCount; } playerc_speechrecognition_t; Modified: code/player/trunk/client_libs/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-01-11 18:48:00 UTC (rev 7266) @@ -173,6 +173,7 @@ healthproxy.cc imuproxy.cc irproxy.cc + joystickproxy.cc laserproxy.cc limbproxy.cc localizeproxy.cc Added: code/player/trunk/client_libs/libplayerc++/joystickproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/joystickproxy.cc (rev 0) +++ code/player/trunk/client_libs/libplayerc++/joystickproxy.cc 2009-01-11 18:48:00 UTC (rev 7266) @@ -0,0 +1,94 @@ + /* + * Player - One Hell of a Robot Server + * Copyright (C) 2000-2003 + * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + /******************************************************************** + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ********************************************************************/ + + /* + * $Id: linuxjoystickproxy.cc 4227 2007-10-24 22:32:04Z thjc $ + */ + + #include "playerc++.h" + + using namespace PlayerCc; + + LinuxjoystickProxy::LinuxjoystickProxy(PlayerClient *aPc, uint32_t aIndex) + : ClientProxy(aPc, aIndex), + mDevice(NULL) + { + Subscribe(aIndex); + // how can I get this into the clientproxy.cc? + // right now, we're dependent on knowing its device type + mInfo = &(mDevice->info); + } + + LinuxjoystickProxy::~LinuxjoystickProxy() + { + Unsubscribe(); + } + + void + LinuxjoystickProxy::Subscribe(uint32_t aIndex) + { + scoped_lock_t lock(mPc->mMutex); + mDevice = playerc_joystick_create(mClient, aIndex); + if (NULL==mDevice) + throw PlayerError("LinuxjoystickProxy::LinuxjoystickProxy()", "could not create"); + + if (0 != playerc_joystick_subscribe(mDevice, PLAYER_OPEN_MODE)) + throw PlayerError("LinuxjoystickProxy::LinuxjoystickProxy()", "could not subscribe"); + } + + void + LinuxjoystickProxy::Unsubscribe() + { + assert(NULL!=mDevice); + scoped_lock_t lock(mPc->mMutex); + playerc_joystick_unsubscribe(mDevice); + playerc_joystick_destroy(mDevice); + mDevice = NULL; + } + + std::ostream& + std::operator << (std::ostream &os, const PlayerCc::LinuxjoystickProxy &c) + { + os << "#Linuxjoystick (" << c.GetInterface() << ":" << c.GetIndex() << ")" << std::endl; + for (unsigned int i = 0; i < c.GetAxesCount(); ++i) + os << i << ": " << c[i] << std::endl; + return os; + } + + Modified: code/player/trunk/client_libs/libplayerc++/playerc++.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-01-11 18:48:00 UTC (rev 7266) @@ -1230,7 +1230,56 @@ }; +/** +The @p LinuxjoystickProxy class is used to control a @ref interface_joystick +device. The most recent joystick range measuremts can be read from the +range attribute, or using the the [] operator. +*/ +class LinuxjoystickProxy : public ClientProxy +{ + private: + void Subscribe(uint32_t aIndex); + void Unsubscribe(); + + // libplayerc data structure + playerc_joystick_t *mDevice; + + public: + /// constructor + LinuxjoystickProxy(PlayerClient *aPc, uint32_t aIndex=0); + /// destructor + ~LinuxjoystickProxy(); + + /// return the sensor count + uint32_t GetButtons() const { return GetVar(mDevice->buttons); }; + + /// return a particular scan value + double GetAxes(uint32_t aIndex) const + { if (GetVar(mDevice->axes_count) <= (int32_t)aIndex) return -1.0; return GetVar(mDevice->pos[aIndex]); }; + /// This operator provides an alternate way of access the scan data. + /// For example, LinuxjoystickProxy[0] == LinuxjoystickProxy.GetRange(0) + double operator [] (uint32_t aIndex) const { return GetAxes(aIndex); } + + /// Number of valid joystick poses + uint32_t GetAxesCount() const { return GetVar(mDevice->axes_count); }; + + /// Linuxjoystick poses (m,m,radians) +// player_pose3d_t GetPose(uint32_t aIndex) const +// { return GetVar(mDevice->poses[aIndex]); }; + + // Enable/disable the joysticks. + // Set @p state to 1 to enable, 0 to disable. + // Note that when joysticks are disabled the client will still receive joystick + // data, but the ranges will always be the last value read from the joysticks + // before they were disabled. + //void SetEnable(bool aEnable); + + /// Request the joystick geometry. +// void RequestGeom(); +}; + + /** The @p LocalizeProxy class is used to control a @ref interface_localize device, which can provide multiple pose @@ -2563,6 +2612,7 @@ std::ostream& operator << (std::ostream& os, const PlayerCc::IrProxy& c); std::ostream& operator << (std::ostream& os, const PlayerCc::LaserProxy& c); std::ostream& operator << (std::ostream& os, const PlayerCc::LimbProxy& c); + std::ostream& operator << (std::ostream& os, const PlayerCc::LinuxjoystickProxy& c); std::ostream& operator << (std::ostream& os, const PlayerCc::LocalizeProxy& c); std::ostream& operator << (std::ostream& os, const PlayerCc::LogProxy& c); std::ostream& operator << (std::ostream& os, const PlayerCc::MapProxy& c); Modified: code/player/trunk/libplayercore/interfaces/049_joystick.def =================================================================== --- code/player/trunk/libplayercore/interfaces/049_joystick.def 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/libplayercore/interfaces/049_joystick.def 2009-01-11 18:48:00 UTC (rev 7266) @@ -13,14 +13,17 @@ /** @brief Data: state (@ref PLAYER_JOYSTICK_DATA_STATE) The joystick data packet, which contains the current state of the -joystick */ -typedef struct player_joystick_data -{ + joystick */ + typedef struct player_joystick_data + { /** Current joystick position X, Y and Yaw (unscaled) */ - int32_t pos[3]; - /** Scaling factors for X, Y and Yaw */ - int32_t scale[3]; - /** Button states (bitmask) */ - uint32_t buttons; -} player_joystick_data_t; + int32_t pos[8]; + /** Scaling factors for X, Y and Yaw --- not using these yet*/ + int32_t scale[8]; + /** Button states (bitmask) */ + uint32_t buttons; + /** Nunber of axes */ + uint32_t axes_count; + } player_joystick_data_t; + Modified: code/player/trunk/server/drivers/joystick/linuxjoy.cc =================================================================== --- code/player/trunk/server/drivers/joystick/linuxjoy.cc 2009-01-11 18:43:03 UTC (rev 7265) +++ code/player/trunk/server/drivers/joystick/linuxjoy.cc 2009-01-11 18:48:00 UTC (rev 7266) @@ -229,6 +229,7 @@ #define XAXIS 1 #define YAXIS 2 #define YAWAXIS 0 +#define SLIDER 3 #define MAX_XSPEED 0.5 #define MAX_YSPEED 0.5 @@ -276,11 +277,12 @@ private: player_devaddr_t joystick_addr; private: const char *dev; private: int fd; - private: int16_t pos[3]; - private: uint16_t buttons; - private: int axes_max[3]; - private: int axes_min[3]; - private: double scale_pos[3]; + private: int axes_count; + private: int32_t pos[4]; + private: uint32_t buttons; + private: int axes_max[4]; + private: int axes_min[4]; + private: double scale_pos[4]; private: double timeout; private: struct timeval lastread; @@ -289,8 +291,8 @@ private: player_position2d_data_t pos_data; // These are used when we send commands to a position device - private: double max_speed[3]; - private: int axes[3]; + private: double max_speed[4]; + private: int axes[4]; private: int deadman_button; private: player_devaddr_t cmd_position_addr; private: Device * position; @@ -360,9 +362,14 @@ } this->dev = cf->ReadString(section, "port", "/dev/js0"); +// partially implementing axes_count + this->axes_count=4; this->axes[0] = cf->ReadTupleInt(section,"axes", 0, XAXIS); this->axes[1] = cf->ReadTupleInt(section,"axes", 1, YAXIS); this->axes[2] = cf->ReadTupleInt(section,"axes", 2, YAWAXIS); + this->axes[3] = cf->ReadTupleInt(section,"axes", 3, SLIDER); + + this->deadman_button = cf->ReadInt(section,"deadman", -1); this->axes_max[0] = cf->ReadTupleInt(section, "axes_maxima", 0, XAXIS_MAX); this->axes_max[1] = cf->ReadTupleInt(section, "axes_maxima", 1, YAXIS_MAX); @@ -445,7 +452,7 @@ } } - this->pos[0] = this->pos[1] = this->pos[2] = 0; + this->pos[0] = this->pos[1] = this->pos[2] = this->pos[3] = 0; return 0; } @@ -571,6 +578,7 @@ fd.events = POLLIN | POLLHUP; fd.revents = 0; + count = poll(&fd, 1, 10); if (count < 0) PLAYER_ERROR1("poll returned error [%s]", strerror(errno)); @@ -590,10 +598,12 @@ // Update buttons if ((event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) { + if (event.value) this->buttons |= (1 << event.number); else this->buttons &= ~(1 << event.number); + } // ignore the startup events @@ -625,6 +635,13 @@ this->pos[2] = 0; GlobalTime->GetTime(&this->lastread); } + else if(event.number == this->axes[3]) + { + this->pos[3] = event.value; + if(abs(this->pos[3]) < this->axes_min[3]) + this->pos[3] = 0; + GlobalTime->GetTime(&this->lastread); + } } break; } @@ -638,16 +655,22 @@ // Send new data out void LinuxJoystick::RefreshData() { + int i; if(this->joystick_addr.interf) { memset(&(this->joy_data),0,sizeof(player_joystick_data_t)); - this->joy_data.pos[0] = this->pos[0]; - this->joy_data.pos[1] = this->pos[1]; - this->joy_data.pos[2] = this->pos[2]; + + this->joy_data.buttons = this->buttons; + this->joy_data.axes_count = this->axes_count; + for (i = 0; i < joy_data.axes_count ; i++) + this->joy_data.pos[i] = this->pos[i]; + + this->joy_data.scale[0] = this->axes_max[0]; this->joy_data.scale[1] = this->axes_max[1]; this->joy_data.scale[2] = this->axes_max[2]; - this->joy_data.buttons = this->buttons; + this->joy_data.scale[3] = this->axes_max[3]; + this->Publish(this->joystick_addr, PLAYER_MSGTYPE_DATA, PLAYER_JOYSTICK_DATA_STATE, (void*)&this->joy_data, sizeof(this->joy_data), NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-16 22:46:05
|
Revision: 7278 http://playerstage.svn.sourceforge.net/playerstage/?rev=7278&view=rev Author: thjc Date: 2009-01-16 22:32:00 +0000 (Fri, 16 Jan 2009) Log Message: ----------- removed empty structures from player Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/client.c code/player/trunk/client_libs/libplayerc/dev_gripper.c code/player/trunk/client_libs/libplayerc/dev_limb.c code/player/trunk/client_libs/libplayerc/dev_position3d.c code/player/trunk/libplayercore/interfaces/001_player.def code/player/trunk/libplayercore/interfaces/003_gripper.def code/player/trunk/libplayercore/interfaces/004_position2d.def code/player/trunk/libplayercore/interfaces/030_position3d.def code/player/trunk/libplayercore/interfaces/045_log.def code/player/trunk/libplayercore/interfaces/054_limb.def code/player/trunk/libplayercore/interfaces/055_graphics2d.def code/player/trunk/libplayercore/interfaces/056_rfid.def code/player/trunk/libplayercore/interfaces/058_graphics3d.def code/player/trunk/libplayercore/player.h code/player/trunk/libplayercore/playerinterfacegen.py code/player/trunk/server/drivers/mixed/botrics/obot.cc Modified: code/player/trunk/client_libs/libplayerc/client.c =================================================================== --- code/player/trunk/client_libs/libplayerc/client.c 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/client_libs/libplayerc/client.c 2009-01-16 22:32:00 UTC (rev 7278) @@ -551,13 +551,12 @@ playerc_client_requestdata(playerc_client_t* client) { int ret; - player_null_t req; if(client->mode != PLAYER_DATAMODE_PULL || client->data_requested) return(0); ret = playerc_client_request(client, NULL, PLAYER_PLAYER_REQ_DATA, - &req, NULL); + NULL, NULL); if(ret == 0) { client->data_requested = 1; Modified: code/player/trunk/client_libs/libplayerc/dev_gripper.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_gripper.c 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/client_libs/libplayerc/dev_gripper.c 2009-01-16 22:32:00 UTC (rev 7278) @@ -108,46 +108,31 @@ // Command the gripper to open int playerc_gripper_open_cmd (playerc_gripper_t *device) { - player_null_t cmd; - - memset (&cmd, 0, sizeof (cmd)); - return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_OPEN, &cmd, NULL); + return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_OPEN, NULL, NULL); } // Command the gripper to close int playerc_gripper_close_cmd (playerc_gripper_t *device) { - player_null_t cmd; - - memset (&cmd, 0, sizeof (cmd)); - return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_CLOSE, &cmd, NULL); + return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_CLOSE, NULL, NULL); } // Command the gripper to stop int playerc_gripper_stop_cmd (playerc_gripper_t *device) { - player_null_t cmd; - - memset (&cmd, 0, sizeof (cmd)); - return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_STOP, &cmd, NULL); + return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_STOP, NULL, NULL); } // Command the gripper to store int playerc_gripper_store_cmd (playerc_gripper_t *device) { - player_null_t cmd; - - memset (&cmd, 0, sizeof (cmd)); - return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_STORE, &cmd, NULL); + return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_STORE, NULL, NULL); } // Command the gripper to retrieve int playerc_gripper_retrieve_cmd (playerc_gripper_t *device) { - player_null_t cmd; - - memset (&cmd, 0, sizeof (cmd)); - return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_RETRIEVE, &cmd, NULL); + return playerc_client_write (device->info.client, &device->info, PLAYER_GRIPPER_CMD_RETRIEVE, NULL, NULL); } // Get the geometry. The writes the result into the proxy Modified: code/player/trunk/client_libs/libplayerc/dev_limb.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_limb.c 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/client_libs/libplayerc/dev_limb.c 2009-01-16 22:32:00 UTC (rev 7278) @@ -125,25 +125,17 @@ // Command the end effector to move home int playerc_limb_home_cmd(playerc_limb_t *device) { - player_null_t cmd; - - memset(&cmd, 0, sizeof(cmd)); - return playerc_client_write(device->info.client, &device->info, PLAYER_LIMB_CMD_HOME, - &cmd, NULL); + NULL, NULL); } // Command the end effector to stop immediatly int playerc_limb_stop_cmd(playerc_limb_t *device) { - player_null_t cmd; - - memset(&cmd, 0, sizeof(cmd)); - return playerc_client_write(device->info.client, &device->info, PLAYER_LIMB_CMD_STOP, - &cmd, NULL); + NULL, NULL); } // Command the end effector to move to a specified pose Modified: code/player/trunk/client_libs/libplayerc/dev_position3d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_position3d.c 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/client_libs/libplayerc/dev_position3d.c 2009-01-16 22:32:00 UTC (rev 7278) @@ -193,7 +193,7 @@ //TODO: Actually store the geometry player_position3d_geom_t_free(config); - + return 0; } @@ -324,14 +324,8 @@ int playerc_position3d_reset_odom(playerc_position3d_t *device) { - player_position3d_reset_odom_config_t config; - - memset(&config, 0, sizeof(config)); - - - return playerc_client_request(device->info.client, &device->info, PLAYER_POSITION3D_REQ_RESET_ODOM, - &config,NULL); + NULL,NULL); } Modified: code/player/trunk/libplayercore/interfaces/001_player.def =================================================================== --- code/player/trunk/libplayercore/interfaces/001_player.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/001_player.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -21,14 +21,14 @@ client can request a single round of data by sending a zero-argument request with type code @p PLAYER_PLAYER_REQ_DATA. The response will be a zero-length acknowledgement. */ -message { REQ, DATA, 4, player_null_t }; +message { REQ, DATA, 4, NULL }; message { REQ, DATAMODE, 5, player_device_datamode_req_t }; message { REQ, AUTH, 7, player_device_auth_req_t }; message { REQ, NAMESERVICE, 8, player_device_nameservice_req_t }; message { REQ, ADD_REPLACE_RULE, 10, player_add_replace_rule_req_t }; -message { SYNCH, OK, 1, player_null_t }; +message { SYNCH, OK, 1, NULL }; message { SYNCH, OVERFLOW, 2, player_uint32_t }; Modified: code/player/trunk/libplayercore/interfaces/003_gripper.def =================================================================== --- code/player/trunk/libplayercore/interfaces/003_gripper.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/003_gripper.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -20,28 +20,28 @@ /** @brief Command: Open (@ref PLAYER_GRIPPER_CMD_OPEN) Tells the gripper to open. */ -message { CMD, OPEN, 1, player_null_t }; +message { CMD, OPEN, 1, NULL }; /** @brief Command: Close (@ref PLAYER_GRIPPER_CMD_CLOSE) Tells the gripper to close. */ -message { CMD, CLOSE, 2, player_null_t }; +message { CMD, CLOSE, 2, NULL }; /** @brief Command: Stop (@ref PLAYER_GRIPPER_CMD_STOP) Tells the gripper to stop. */ -message { CMD, STOP, 3, player_null_t }; +message { CMD, STOP, 3, NULL }; /** @brief Command: Store (@ref PLAYER_GRIPPER_CMD_STORE) Tells the gripper to store whatever it is holding. */ -message { CMD, STORE, 4, player_null_t }; +message { CMD, STORE, 4, NULL }; /** @brief Command: Retrieve (@ref PLAYER_GRIPPER_CMD_RETRIEVE) Tells the gripper to retrieve a stored object (so that it can be put back into the world). The opposite of store. */ -message { CMD, RETRIEVE, 5, player_null_t }; +message { CMD, RETRIEVE, 5, NULL }; /** Gripper state: open */ Modified: code/player/trunk/libplayercore/interfaces/004_position2d.def =================================================================== --- code/player/trunk/libplayercore/interfaces/004_position2d.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/004_position2d.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -191,7 +191,7 @@ To reset the robot's odometry to @f$(x, y, yaw) = (0,0,0)@f$, send a @ref PLAYER_POSITION2D_REQ_RESET_ODOM request. Null response. */ - message { REQ, RESET_ODOM, 6, player_null_t }; + message { REQ, RESET_ODOM, 6, NULL }; /** @brief Request/reply: Set velocity PID parameters. * Modified: code/player/trunk/libplayercore/interfaces/030_position3d.def =================================================================== --- code/player/trunk/libplayercore/interfaces/030_position3d.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/030_position3d.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -24,7 +24,7 @@ /** Request/reply subtype: position mode */ message { REQ, POSITION_MODE, 4, player_position3d_position_mode_req_t }; /** Request/reply subtype: reset odometry */ -message { REQ, RESET_ODOM, 5, player_position3d_set_odom_req_t }; +message { REQ, RESET_ODOM, 5, NULL }; /** Request/reply subtype: set odometry */ message { REQ, SET_ODOM, 6, player_position3d_set_odom_req_t }; /** Request/reply subtype: set speed PID params */ @@ -139,9 +139,6 @@ To reset the robot's odometry to @f$(x,y,\theta) = (0,0,0)@f$, send a @ref PLAYER_POSITION3D_RESET_ODOM request. Null response. */ -typedef struct player_position3d_reset_odom_config -{ -} player_position3d_reset_odom_config_t; /** @brief Request/reply: Set velocity PID parameters. * Modified: code/player/trunk/libplayercore/interfaces/045_log.def =================================================================== --- code/player/trunk/libplayercore/interfaces/045_log.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/045_log.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -14,7 +14,7 @@ /** Request/reply subtype: get state */ message { REQ, GET_STATE, 3, player_log_get_state_t }; /** Request/reply subtype: rewind */ -message { REQ, SET_READ_REWIND, 4, player_log_set_read_rewind_t }; +message { REQ, SET_READ_REWIND, 4, NULL }; /** Request/reply subtype: set filename to write */ message { REQ, SET_FILENAME, 5, player_log_set_filename_t }; @@ -50,10 +50,8 @@ To rewind log playback to beginning of logfile, send a @ref PLAYER_LOG_REQ_SET_READ_REWIND request. Does not affect playback state (i.e., whether it is started or stopped. Null response. */ -typedef struct player_log_set_read_rewind -{ -} player_log_set_read_rewind_t; + /** @brief Request/reply: Get state. To find out whether logging/playback is enabled or disabled, send a null Modified: code/player/trunk/libplayercore/interfaces/054_limb.def =================================================================== --- code/player/trunk/libplayercore/interfaces/054_limb.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/054_limb.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -23,11 +23,11 @@ /** @brief Command: home (@ref PLAYER_LIMB_HOME_CMD) Tells the end effector to return to its home position. */ -message { CMD, HOME, 1, player_null_t }; +message { CMD, HOME, 1, NULL }; /** @brief Command: stop (@ref PLAYER_LIMB_STOP_CMD) Tells the limb to stop moving immediatly. */ -message { CMD, STOP, 2, player_null_t }; +message { CMD, STOP, 2, NULL }; /** Command subtype: set pose */ message { CMD, SETPOSE, 3, player_limb_setpose_cmd_t }; /** Command subtype: set position */ Modified: code/player/trunk/libplayercore/interfaces/055_graphics2d.def =================================================================== --- code/player/trunk/libplayercore/interfaces/055_graphics2d.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/055_graphics2d.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -8,7 +8,7 @@ } /** Command subtype: clear the drawing area (send an empty message) */ -message { CMD, CLEAR, 1, player_null_t }; +message { CMD, CLEAR, 1, NULL }; /** Command subtype: draw points */ message { CMD, POINTS, 2, player_graphics2d_cmd_points_t }; /** Command subtype: draw a polyline */ Modified: code/player/trunk/libplayercore/interfaces/056_rfid.def =================================================================== --- code/player/trunk/libplayercore/interfaces/056_rfid.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/056_rfid.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -10,13 +10,13 @@ message { DATA, TAGS, 1, player_rfid_data_t }; /** Request/reply: put the reader in sleep mode (0) or wake it up (1). */ -message { REQ, POWER, 1, player_null_t }; +message { REQ, POWER, 1, NULL }; /** Request/reply: read data from the RFID tag - to be implemented. */ -message { REQ, READTAG, 2, player_null_t }; +message { REQ, READTAG, 2, NULL }; /** Request/reply: write data to the RFID tag - to be implemented. */ -message { REQ, WRITETAG, 3, player_null_t }; +message { REQ, WRITETAG, 3, NULL }; /** Request/reply: lock data blocks of a RFID tag - to be implemented. */ -message { REQ, LOCKTAG, 4, player_null_t }; +message { REQ, LOCKTAG, 4, NULL }; /** @brief Structure describing a single RFID tag. */ Modified: code/player/trunk/libplayercore/interfaces/058_graphics3d.def =================================================================== --- code/player/trunk/libplayercore/interfaces/058_graphics3d.def 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/interfaces/058_graphics3d.def 2009-01-16 22:32:00 UTC (rev 7278) @@ -12,7 +12,7 @@ } /** Command subtype: clear the drawing area (send an empty message) */ -message { CMD, CLEAR, 1, player_null_t }; +message { CMD, CLEAR, 1, NULL }; /** Command subtype: draw items */ message { CMD, DRAW, 2, player_graphics3d_cmd_draw_t }; /** Command subtype: translate coordinate system */ @@ -20,9 +20,9 @@ /** Command subtype: rotate coordinate system */ message { CMD, ROTATE, 4, player_graphics3d_cmd_rotate_t }; /** Command subtype: push current coordinate system onto stack */ -message { CMD, PUSH, 5, player_null_t }; +message { CMD, PUSH, 5, NULL }; /** Command subtype: pop coordinate system from stack to become current */ -message { CMD, POP, 6, player_null_t }; +message { CMD, POP, 6, NULL }; /** Drawmode: enumeration that defines the drawing mode */ Modified: code/player/trunk/libplayercore/player.h =================================================================== --- code/player/trunk/libplayercore/player.h 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/player.h 2009-01-16 22:32:00 UTC (rev 7278) @@ -176,11 +176,6 @@ * These structures often appear inside other structures. * @{ */ -/** @brief A null structure for parsing completeness */ -typedef struct player_null -{ -} player_null_t; - /** @brief A point in the plane */ typedef struct player_point_2d { Modified: code/player/trunk/libplayercore/playerinterfacegen.py =================================================================== --- code/player/trunk/libplayercore/playerinterfacegen.py 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/libplayercore/playerinterfacegen.py 2009-01-16 22:32:00 UTC (rev 7278) @@ -132,8 +132,9 @@ """ % {"interface_name": interface_name} print "\n /* %s messages */" % interface_name for m in interface_messages: - print " {", interface_def, ",", m.msg_type, ",", m.msg_subtype_string, "," - print " (player_pack_fn_t)%(dt_base)s_pack, (player_copy_fn_t)%(dt)s_copy, (player_cleanup_fn_t)%(dt)s_cleanup,(player_clone_fn_t)%(dt)s_clone,(player_free_fn_t)%(dt)s_free,(player_sizeof_fn_t)%(dt)s_sizeof}," % { "dt_base": m.datatype[:-2], "dt": m.datatype} + if m.datatype != "NULL": + print " {", interface_def, ",", m.msg_type, ",", m.msg_subtype_string, "," + print " (player_pack_fn_t)%(dt_base)s_pack, (player_copy_fn_t)%(dt)s_copy, (player_cleanup_fn_t)%(dt)s_cleanup,(player_clone_fn_t)%(dt)s_clone,(player_free_fn_t)%(dt)s_free,(player_sizeof_fn_t)%(dt)s_sizeof}," % { "dt_base": m.datatype[:-2], "dt": m.datatype} if plugin: print """ /* This NULL element signals the end of the list */ Modified: code/player/trunk/server/drivers/mixed/botrics/obot.cc =================================================================== --- code/player/trunk/server/drivers/mixed/botrics/obot.cc 2009-01-16 21:58:55 UTC (rev 7277) +++ code/player/trunk/server/drivers/mixed/botrics/obot.cc 2009-01-16 22:32:00 UTC (rev 7278) @@ -137,7 +137,7 @@ static void StopRobot(void* obotdev); -class Obot : public ThreadedDriver +class Obot : public ThreadedDriver { private: // this function will be run in a separate thread @@ -776,12 +776,6 @@ PLAYER_POSITION2D_REQ_RESET_ODOM, this->position_addr)) { - if(hdr->size != sizeof(player_null_t)) - { - PLAYER_WARN("Arg to odometry reset requests wrong size; ignoring"); - return(-1); - } - // Just overwrite our current odometric pose. this->px = 0.0; this->py = 0.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-16 22:55:28
|
Revision: 7277 http://playerstage.svn.sourceforge.net/playerstage/?rev=7277&view=rev Author: thjc Date: 2009-01-16 21:58:55 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Merge of 7276 from 2-1: Bugfix [2513331] no timestamp from "cameracompress" driver also applies to camera uncompress Modified Paths: -------------- code/player/trunk/server/drivers/camera/compress/cameracompress.cc code/player/trunk/server/drivers/camera/compress/camerauncompress.cc Property Changed: ---------------- code/player/trunk/ Property changes on: code/player/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263 /code/player/trunk:6985 + /code/player/branches/release-2-1-patches:6672-6673,6738,6834,6886,6905,6930,6936,6946,6951,6955,6975,6979-6981,6985,6987-6996,7087-7088,7204,7226,7230,7248,7250-7252,7256,7262-7263,7276 /code/player/trunk:6985 Modified: code/player/trunk/server/drivers/camera/compress/cameracompress.cc =================================================================== --- code/player/trunk/server/drivers/camera/compress/cameracompress.cc 2009-01-16 21:52:44 UTC (rev 7276) +++ code/player/trunk/server/drivers/camera/compress/cameracompress.cc 2009-01-16 21:58:55 UTC (rev 7277) @@ -201,6 +201,7 @@ { assert(data); player_camera_data_t * recv = reinterpret_cast<player_camera_data_t * > (data); + camera_time = hdr->timestamp; ProcessImage(*recv); return 0; } Modified: code/player/trunk/server/drivers/camera/compress/camerauncompress.cc =================================================================== --- code/player/trunk/server/drivers/camera/compress/camerauncompress.cc 2009-01-16 21:52:44 UTC (rev 7276) +++ code/player/trunk/server/drivers/camera/compress/camerauncompress.cc 2009-01-16 21:58:55 UTC (rev 7277) @@ -205,6 +205,7 @@ PLAYER_WARN("uncompressing raw camera images (not good)"); return -1; } + camera_time = hdr->timestamp; ProcessImage(*camera_data); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-24 02:26:03
|
Revision: 7295 http://playerstage.svn.sourceforge.net/playerstage/?rev=7295&view=rev Author: thjc Date: 2009-01-24 02:25:59 +0000 (Sat, 24 Jan 2009) Log Message: ----------- fixed unpack/pack regressions introduced by the elimination of empty structures in the interfaces. Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/client.c code/player/trunk/libplayertcp/playertcp.cc code/player/trunk/libplayertcp/playerudp.cc Modified: code/player/trunk/client_libs/libplayerc/client.c =================================================================== --- code/player/trunk/client_libs/libplayerc/client.c 2009-01-24 01:07:34 UTC (rev 7294) +++ code/player/trunk/client_libs/libplayerc/client.c 2009-01-24 02:25:59 UTC (rev 7295) @@ -1139,33 +1139,39 @@ client->read_xdrdata_len += nbytes; } + if (header->size) + { // Locate the appropriate unpacking function for the message body - if(!(packfunc = playerxdr_get_packfunc(header->addr.interf, header->type, + if(!(packfunc = playerxdr_get_packfunc(header->addr.interf, header->type, header->subtype))) - { - // TODO: Allow the user to register a callback to handle unsupported - // messages - PLAYERC_ERR4("skipping message from %s:%u with unsupported type %s:%u", + { + // TODO: Allow the user to register a callback to handle unsupported + // messages + PLAYERC_ERR4("skipping message from %s:%u with unsupported type %s:%u", interf_to_str(header->addr.interf), header->addr.index, msgtype_to_str(header->type), header->subtype); - // Slide over the body - memmove(client->read_xdrdata, + // Slide over the body + memmove(client->read_xdrdata, client->read_xdrdata + header->size, client->read_xdrdata_len - header->size); - client->read_xdrdata_len -= header->size; + client->read_xdrdata_len -= header->size; - return(-1); - } + return(-1); + } - // Unpack the body - if((decode_msglen = (*packfunc)(client->read_xdrdata, + // Unpack the body + if((decode_msglen = (*packfunc)(client->read_xdrdata, header->size, data, PLAYERXDR_DECODE)) < 0) - { - PLAYERC_ERR4("decoding failed on message from %s:%u with type %s:%u", + { + PLAYERC_ERR4("decoding failed on message from %s:%u with type %s:%u", interf_to_str(header->addr.interf), header->addr.index, msgtype_to_str(header->type), header->subtype); - return(-1); + return(-1); + } } - + else + { + decode_msglen = 0; + } // Slide over the body memmove(client->read_xdrdata, client->read_xdrdata + header->size, @@ -1273,8 +1279,15 @@ item = client->qitems + (client->qfirst + client->qlen) % client->qsize; item->header = *header; - item->data = malloc(header->size); - memcpy(item->data, data, header->size); + if (header->size && data) + { + item->data = malloc(header->size); + memcpy(item->data, data, header->size); + } + else + { + item->data = NULL; + } client->qlen +=1; Modified: code/player/trunk/libplayertcp/playertcp.cc =================================================================== --- code/player/trunk/libplayertcp/playertcp.cc 2009-01-24 01:07:34 UTC (rev 7294) +++ code/player/trunk/libplayertcp/playertcp.cc 2009-01-24 02:25:59 UTC (rev 7295) @@ -567,6 +567,7 @@ player_msghdr_t hdr; void* payload; int encode_msglen; + #if HAVE_Z player_map_data_t* zipped_data=NULL; #endif @@ -581,6 +582,8 @@ client->writebuffer, MIN(client->writebufferlen, PLAYERTCP_WRITEBUFFER_SIZE)); + + if(numwritten < 0) { if(errno == EAGAIN) @@ -612,79 +615,79 @@ // instances of the message on other queues. hdr = *msg->GetHeader(); payload = msg->GetPayload(); - // Locate the appropriate packing function - if(!(packfunc = playerxdr_get_packfunc(hdr.addr.interf, - hdr.type, hdr.subtype))) + + // Make sure there's room in the buffer for the encoded messsage. + // 4 times the message (including dynamic data) is a safe upper bound + size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDataSize()); + if(maxsize > (size_t)(client->writebuffersize)) { - // TODO: Allow the user to register a callback to handle unsupported - // messages - PLAYER_WARN4("skipping message from %s:%u with unsupported type %s:%u", - interf_to_str(hdr.addr.interf), hdr.addr.index, msgtype_to_str(hdr.type), hdr.subtype); - } - else - { - // Make sure there's room in the buffer for the encoded messsage. - // 4 times the message (including dynamic data) is a safe upper bound - size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDataSize()); - if(maxsize > (size_t)(client->writebuffersize)) + // Get at least twice as much space + client->writebuffersize = MAX((size_t)(client->writebuffersize * 2), + maxsize); + // Did we hit the limit (or overflow and become negative)? + if((client->writebuffersize >= PLAYERXDR_MAX_MESSAGE_SIZE) || + (client->writebuffersize < 0)) { - // Get at least twice as much space - client->writebuffersize = MAX((size_t)(client->writebuffersize * 2), - maxsize); - // Did we hit the limit (or overflow and become negative)? - if((client->writebuffersize >= PLAYERXDR_MAX_MESSAGE_SIZE) || - (client->writebuffersize < 0)) - { - PLAYER_WARN1("allocating maximum %d bytes to outgoing message buffer", + PLAYER_WARN1("allocating maximum %d bytes to outgoing message buffer", PLAYERXDR_MAX_MESSAGE_SIZE); - client->writebuffersize = PLAYERXDR_MAX_MESSAGE_SIZE; - } - client->writebuffer = (char*)realloc(client->writebuffer, + client->writebuffersize = PLAYERXDR_MAX_MESSAGE_SIZE; + } + client->writebuffer = (char*)realloc(client->writebuffer, client->writebuffersize); - assert(client->writebuffer); - memset(client->writebuffer, 0, client->writebuffersize); - } + assert(client->writebuffer); + memset(client->writebuffer, 0, client->writebuffersize); + } - // HACK: special handling for map data to compress it before sending - // them out over the network. - if((hdr.addr.interf == PLAYER_MAP_CODE) && - (hdr.type == PLAYER_MSGTYPE_RESP_ACK) && - (hdr.subtype == PLAYER_MAP_REQ_GET_DATA)) - { + // HACK: special handling for map data to compress it before sending + // them out over the network. + if((hdr.addr.interf == PLAYER_MAP_CODE) && + (hdr.type == PLAYER_MSGTYPE_RESP_ACK) && + (hdr.subtype == PLAYER_MAP_REQ_GET_DATA)) + { #if HAVE_Z - player_map_data_t* raw_data = (player_map_data_t*)payload; - zipped_data = (player_map_data_t*)calloc(1,sizeof(player_map_data_t)); - assert(zipped_data); + player_map_data_t* raw_data = (player_map_data_t*)payload; + zipped_data = (player_map_data_t*)calloc(1,sizeof(player_map_data_t)); + assert(zipped_data); - // copy the metadata - *zipped_data = *raw_data; - uLongf count = compressBound(raw_data->data_count); - zipped_data->data = (int8_t*)malloc(count); + // copy the metadata + *zipped_data = *raw_data; + uLongf count = compressBound(raw_data->data_count); + zipped_data->data = (int8_t*)malloc(count); - // compress the tile - int ret; - ret = compress((Bytef*)zipped_data->data,&count, + // compress the tile + int ret; + ret = compress((Bytef*)zipped_data->data,&count, (const Bytef*)raw_data->data, raw_data->data_count); - if((ret != Z_OK) && (ret != Z_STREAM_END)) - { - PLAYER_ERROR("failed to compress map data"); - free(zipped_data); - client->writebufferlen = 0; - delete msg; - return(0); - } + if((ret != Z_OK) && (ret != Z_STREAM_END)) + { + PLAYER_ERROR("failed to compress map data"); + free(zipped_data); + client->writebufferlen = 0; + delete msg; + return(0); + } - zipped_data->data_count = count; + zipped_data->data_count = count; - // swap the payload pointer to point at the zipped version - payload = (void*)zipped_data; + // swap the payload pointer to point at the zipped version + payload = (void*)zipped_data; #else - PLAYER_WARN("not compressing map data, because zlib was not found at compile time"); + PLAYER_WARN("not compressing map data, because zlib was not found at compile time"); #endif + } + + if (payload) + { + // Locate the appropriate packing function + if(!(packfunc = playerxdr_get_packfunc(hdr.addr.interf, + hdr.type, hdr.subtype))) + { + // TODO: Allow the user to register a callback to handle unsupported messages + PLAYER_WARN4("skipping message from %s:%u with unsupported type %s:%u", + interf_to_str(hdr.addr.interf), hdr.addr.index, msgtype_to_str(hdr.type), hdr.subtype); } - - if (payload) - { + else + { // Encode the body first if((encode_msglen = (*packfunc)(client->writebuffer + PLAYERXDR_MSGHDR_SIZE, @@ -706,33 +709,34 @@ return(0); } } - else - { - encode_msglen = 0; - } - // Rewrite the size in the header with the length of the encoded - // body, then encode the header. - hdr.size = encode_msglen; - if((encode_msglen = player_msghdr_pack(client->writebuffer, + } + else + { + encode_msglen = 0; + } + // Rewrite the size in the header with the length of the encoded + // body, then encode the header. + hdr.size = encode_msglen; + if((encode_msglen = player_msghdr_pack(client->writebuffer, PLAYERXDR_MSGHDR_SIZE, &hdr, PLAYERXDR_ENCODE)) < 0) + { + PLAYER_ERROR("failed to encode msg header"); +#if HAVE_Z + if(zipped_data) { - PLAYER_ERROR("failed to encode msg header"); -#if HAVE_Z - if(zipped_data) - { - free(zipped_data->data); - free(zipped_data); - zipped_data=NULL; - } + free(zipped_data->data); + free(zipped_data); + zipped_data=NULL; + } #endif - client->writebufferlen = 0; - delete msg; - return(0); - } + client->writebufferlen = 0; + delete msg; + return(0); + } - client->writebufferlen = PLAYERXDR_MSGHDR_SIZE + hdr.size; - } + client->writebufferlen = PLAYERXDR_MSGHDR_SIZE + hdr.size; + delete msg; #if HAVE_Z if(zipped_data) Modified: code/player/trunk/libplayertcp/playerudp.cc =================================================================== --- code/player/trunk/libplayertcp/playerudp.cc 2009-01-24 01:07:34 UTC (rev 7294) +++ code/player/trunk/libplayertcp/playerudp.cc 2009-01-24 02:25:59 UTC (rev 7295) @@ -517,8 +517,6 @@ player_map_data_t* zipped_data=NULL; #endif - //printf("WriteClient(%d)\n", cli); - client = this->clients + cli; for(;;) { @@ -562,120 +560,128 @@ // instances of the message on other queues. hdr = *msg->GetHeader(); payload = msg->GetPayload(); - // Locate the appropriate packing function - if(!(packfunc = playerxdr_get_packfunc(hdr.addr.interf, - hdr.type, hdr.subtype))) + + // Make sure there's room in the buffer for the encoded messsage. + // 4 times the message (including dynamic data) is a safe upper bound + size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDataSize()); + if(maxsize > (size_t)(client->writebuffersize)) { - // TODO: Allow the user to register a callback to handle unsupported - // messages - PLAYER_WARN4("skipping message from %s:%u with unsupported type %s:%u", - interf_to_str(hdr.addr.interf), hdr.addr.index, msgtype_to_str(hdr.type), hdr.subtype); - } - else - { - // Make sure there's room in the buffer for the encoded messsage. - // 4 times the message is a safe upper bound - size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDataSize()); - if(maxsize > (size_t)(client->writebuffersize)) + // Get at least twice as much space + client->writebuffersize = MAX((size_t)(client->writebuffersize * 2), + maxsize); + // Did we hit the limit (or overflow and become negative)? + if((client->writebuffersize >= PLAYERXDR_MAX_MESSAGE_SIZE) || + (client->writebuffersize < 0)) { - // Get at least twice as much space - client->writebuffersize = MAX((size_t)(client->writebuffersize * 2), - maxsize); - // Did we hit the limit (or overflow and become negative)? - if((client->writebuffersize >= PLAYERXDR_MAX_MESSAGE_SIZE) || - (client->writebuffersize < 0)) - { - PLAYER_WARN1("allocating maximum %d bytes to outgoing message buffer", + PLAYER_WARN1("allocating maximum %d bytes to outgoing message buffer", PLAYERXDR_MAX_MESSAGE_SIZE); - client->writebuffersize = PLAYERXDR_MAX_MESSAGE_SIZE; - } - client->writebuffer = (char*)realloc(client->writebuffer, + client->writebuffersize = PLAYERXDR_MAX_MESSAGE_SIZE; + } + client->writebuffer = (char*)realloc(client->writebuffer, client->writebuffersize); - assert(client->writebuffer); - memset(client->writebuffer, 0, client->writebuffersize); - } + assert(client->writebuffer); + memset(client->writebuffer, 0, client->writebuffersize); + } - // HACK: special handling for map data to compress it before sending - // them out over the network. - if((hdr.addr.interf == PLAYER_MAP_CODE) && - (hdr.type == PLAYER_MSGTYPE_RESP_ACK) && - (hdr.subtype == PLAYER_MAP_REQ_GET_DATA)) - { + // HACK: special handling for map data to compress it before sending + // them out over the network. + if((hdr.addr.interf == PLAYER_MAP_CODE) && + (hdr.type == PLAYER_MSGTYPE_RESP_ACK) && + (hdr.subtype == PLAYER_MAP_REQ_GET_DATA)) + { #if HAVE_Z - player_map_data_t* raw_data = (player_map_data_t*)payload; - zipped_data = (player_map_data_t*)calloc(1,sizeof(player_map_data_t)); - assert(zipped_data); + player_map_data_t* raw_data = (player_map_data_t*)payload; + zipped_data = (player_map_data_t*)calloc(1,sizeof(player_map_data_t)); + assert(zipped_data); - // copy the metadata - *zipped_data = *raw_data; - uLongf count = compressBound(raw_data->data_count); - zipped_data->data = (int8_t*)malloc(count); + // copy the metadata + *zipped_data = *raw_data; + uLongf count = compressBound(raw_data->data_count); + zipped_data->data = (int8_t*)malloc(count); - // compress the tile - if(compress((Bytef*)zipped_data->data,&count, - (const Bytef*)raw_data->data, raw_data->data_count) != Z_OK) - { - PLAYER_ERROR("failed to compress map data"); - free(zipped_data); - client->writebufferlen = 0; - delete msg; - return(0); - } + // compress the tile + int ret; + ret = compress((Bytef*)zipped_data->data,&count, + (const Bytef*)raw_data->data, raw_data->data_count); + if((ret != Z_OK) && (ret != Z_STREAM_END)) + { + PLAYER_ERROR("failed to compress map data"); + free(zipped_data); + client->writebufferlen = 0; + delete msg; + return(0); + } - zipped_data->data_count = count; + zipped_data->data_count = count; - // swap the payload pointer to point at the zipped version - payload = (void*)zipped_data; + // swap the payload pointer to point at the zipped version + payload = (void*)zipped_data; #else - PLAYER_WARN("not compressing map data, because zlib was not found at compile time"); + PLAYER_WARN("not compressing map data, because zlib was not found at compile time"); #endif + } + + if (payload) + { + // Locate the appropriate packing function + if(!(packfunc = playerxdr_get_packfunc(hdr.addr.interf, + hdr.type, hdr.subtype))) + { + // TODO: Allow the user to register a callback to handle unsupported messages + PLAYER_WARN4("skipping message from %s:%u with unsupported type %s:%u", + interf_to_str(hdr.addr.interf), hdr.addr.index, msgtype_to_str(hdr.type), hdr.subtype); } - - // Encode the body first - if((encode_msglen = - (*packfunc)(client->writebuffer + PLAYERXDR_MSGHDR_SIZE, + else + { + // Encode the body first + if((encode_msglen = + (*packfunc)(client->writebuffer + PLAYERXDR_MSGHDR_SIZE, maxsize - PLAYERXDR_MSGHDR_SIZE, payload, PLAYERXDR_ENCODE)) < 0) - { - PLAYER_WARN4("encoding failed on message from %s:%u with type %s:%u", + { + PLAYER_WARN4("encoding failed on message from %s:%u with type %s:%u", interf_to_str(hdr.addr.interf), hdr.addr.index, msgtype_to_str(hdr.type), hdr.subtype); #if HAVE_Z - if(zipped_data) - { - free(zipped_data->data); - free(zipped_data); - zipped_data=NULL; + if(zipped_data) + { + free(zipped_data->data); + free(zipped_data); + zipped_data=NULL; + } +#endif + client->writebufferlen = 0; + delete msg; + return(0); } -#endif - client->writebufferlen = 0; - delete msg; - return(0); } - - // Rewrite the size in the header with the length of the encoded - // body, then encode the header. - hdr.size = encode_msglen; - if((encode_msglen = - player_msghdr_pack(client->writebuffer, - PLAYERXDR_MSGHDR_SIZE, &hdr, - PLAYERXDR_ENCODE)) < 0) + } + else + { + encode_msglen = 0; + } + // Rewrite the size in the header with the length of the encoded + // body, then encode the header. + hdr.size = encode_msglen; + if((encode_msglen = player_msghdr_pack(client->writebuffer, + PLAYERXDR_MSGHDR_SIZE, &hdr, + PLAYERXDR_ENCODE)) < 0) + { + PLAYER_ERROR("failed to encode msg header"); +#if HAVE_Z + if(zipped_data) { - PLAYER_ERROR("failed to encode msg header"); -#if HAVE_Z - if(zipped_data) - { - free(zipped_data->data); - free(zipped_data); - zipped_data=NULL; - } + free(zipped_data->data); + free(zipped_data); + zipped_data=NULL; + } #endif - client->writebufferlen = 0; - delete msg; - return(0); - } + client->writebufferlen = 0; + delete msg; + return(0); + } - client->writebufferlen = PLAYERXDR_MSGHDR_SIZE + hdr.size; - } + client->writebufferlen = PLAYERXDR_MSGHDR_SIZE + hdr.size; + delete msg; #if HAVE_Z if(zipped_data) @@ -687,10 +693,7 @@ #endif } else - { - //puts("no messages"); return(0); - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rt...@us...> - 2009-01-26 23:07:45
|
Revision: 7303 http://playerstage.svn.sourceforge.net/playerstage/?rev=7303&view=rev Author: rtv Date: 2009-01-26 22:41:12 +0000 (Mon, 26 Jan 2009) Log Message: ----------- simplified plugin loader and added more informative error output to it Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/cmake/internal/LibraryUtils.cmake code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/libplayercore/plugins.cc code/player/trunk/server/server.cc Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-01-26 00:45:25 UTC (rev 7302) +++ code/player/trunk/CMakeLists.txt 2009-01-26 22:41:12 UTC (rev 7303) @@ -46,11 +46,15 @@ INCLUDE (${PLAYER_CMAKE_DIR}/internal/LibraryUtils.cmake) # Set some common include directories, including the binary dir to get config.h -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libplayercore) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libplayercore /opt/local/include ) # Extra directories where needed libraries, etc may be located (set by the user) INCLUDE_DIRECTORIES (${PLAYER_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYER_EXTRA_LIB_DIRS}) +# rtv hack +link_directories( /opt/local/lib ) +include_directories( /opt/local/include ) + # If on Windows, only build the client libraries. (this won't actually work yet cause libplayerc needs some stuff from core) ADD_SUBDIRECTORY (client_libs) ADD_SUBDIRECTORY (libplayercore) Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-01-26 00:45:25 UTC (rev 7302) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-01-26 22:41:12 UTC (rev 7303) @@ -1,7 +1,10 @@ ADD_SUBDIRECTORY (bindings) -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs /opt/local/include) +link_directories( /opt/local/lib ) + + SET (PLAYERC_EXTRA_LINK_LIBRARIES) SET (playercSrcs playerc.h mclient.c @@ -57,7 +60,7 @@ APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" z m) PLAYER_ADD_LIBRARY (playerc ${playercSrcs}) -ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src) +ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src ) TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror ${PLAYERC_EXTRA_LINK_LIBRARIES}) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (playerc playerjpeg) Modified: code/player/trunk/cmake/internal/LibraryUtils.cmake =================================================================== --- code/player/trunk/cmake/internal/LibraryUtils.cmake 2009-01-26 00:45:25 UTC (rev 7302) +++ code/player/trunk/cmake/internal/LibraryUtils.cmake 2009-01-26 22:41:12 UTC (rev 7303) @@ -10,7 +10,9 @@ SET_TARGET_PROPERTIES (${_name} PROPERTIES VERSION ${PLAYER_VERSION} SOVERSION ${PLAYER_API_VERSION} - INSTALL_NAME_DIR @rpath +# @rpath is not expanded on OS X, so I replaced this line with the version below [see patch 2318489] +# INSTALL_NAME_DIR @rpath + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" INSTALL_RPATH "${INSTALL_RPATH};${CMAKE_INSTALL_PREFIX}/lib" BUILD_WITH_INSTALL_RPATH TRUE) INSTALL (TARGETS ${_name} DESTINATION lib/) Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-01-26 00:45:25 UTC (rev 7302) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-01-26 22:41:12 UTC (rev 7303) @@ -1,5 +1,6 @@ INCLUDE (${PLAYER_CMAKE_DIR}/PlayerUtils.cmake) + INCLUDE (CheckFunctionExists) INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) @@ -51,6 +52,13 @@ SET (CMAKE_REQUIRED_INCLUDES) SET (CMAKE_REQUIRED_LIBRARIES) +link_directories( /opt/local/lib ) +include_directories( /opt/local/include ) + +INCLUDE(CheckIncludeFile) +CHECK_INCLUDE_FILE( jpeglib.h HAVE_JPEG_HEADER ) +MESSAGE( "Result" ${HAVE_JPEG_HEADER} ) + CHECK_LIBRARY_EXISTS (jpeg jpeg_read_header "${PLAYER_EXTRA_LIB_DIRS}" HAVE_LIBJPEG) CHECK_INCLUDE_FILES ("stdio.h;jpeglib.h" HAVE_JPEGLIB_H) IF (HAVE_LIBJPEG AND HAVE_JPEGLIB_H) Modified: code/player/trunk/libplayercore/plugins.cc =================================================================== --- code/player/trunk/libplayercore/plugins.cc 2009-01-26 00:45:25 UTC (rev 7302) +++ code/player/trunk/libplayercore/plugins.cc 2009-01-26 22:41:12 UTC (rev 7303) @@ -55,36 +55,6 @@ #include "plugins.h" -class plugin_path_list -{ -public: - plugin_path_list(plugin_path_list * parent) - { - memset(fullpath,0,sizeof(fullpath)); - next = NULL; - if (parent) - { - parent->next = this; - } - } - - ~plugin_path_list() - { - delete next; - } - - plugin_path_list * last() - { - plugin_path_list * ret = NULL; - for (ret = this; ret->next != NULL; ret = ret->next); - return ret; - } - - char fullpath[PATH_MAX]; - plugin_path_list * next; -}; - - // Try to load a given plugin, using a particular search algorithm. // Returns true on success and false on failure. lt_dlhandle @@ -92,9 +62,9 @@ { #if HAVE_LIBLTDL static int init_done = 0; - + if( !init_done ) - { + { int errors = 0; if((errors = lt_dlinit())) { @@ -105,110 +75,67 @@ else init_done = 1; } - - lt_dlhandle handle=NULL; - plugin_path_list paths(NULL); - - char* playerpath; - char* tmp; - char* cfgdir; - unsigned int i,j; - + // allocate a buffer to put the searched paths in so we can just display the error at the end // rather than during plugin loading // see if we got an absolute path if(pluginname[0] == '/' || pluginname[0] == '~') - { - strncpy(paths.fullpath,pluginname,PATH_MAX); - } + { + PLAYER_WARN1( "absolute path plugin %s", pluginname ); + } else - { - // we got a relative path, so search for the module - // did the user set PLAYERPATH? - if((playerpath = getenv("PLAYERPATH"))) - { - PLAYER_MSG1(1,"PLAYERPATH: %s\n", playerpath); + { + // we got a relative path, so set up a search path + char* playerpath = NULL; - // yep, now parse it, as a colon-separated list of directories - i=0; - while(i<strlen(playerpath)) - { - j=i; - while(j<strlen(playerpath)) - { - if(playerpath[j] == ':') - { - break; - } - j++; - } - plugin_path_list * path = paths.last(); - new plugin_path_list(path); - strncpy(path->fullpath,playerpath+i,j-i); - strcat(path->fullpath,"/"); - strcat(path->fullpath,pluginname); - - i=j+1; - } - } - - // try to load it from the directory where the config file is - if(cfgfile) - { - // Note that dirname() modifies the contents, so - // we need to make a copy of the filename. - tmp = strdup(cfgfile); - assert(tmp); - plugin_path_list * path = paths.last(); - new plugin_path_list(path); - cfgdir = dirname(tmp); - if(cfgdir[0] != '/' && cfgdir[0] != '~') - { - char * ret = getcwd(path->fullpath, PATH_MAX); - if (ret == NULL) - { - PLAYER_ERROR("Failed to get working directory"); - assert(false); - // TODO: handle this error properly - } - strncat(path->fullpath,"/", PATH_MAX); - } - strncat(path->fullpath,cfgdir, PATH_MAX); - strncat(path->fullpath,"/", PATH_MAX); - strncat(path->fullpath,pluginname, PATH_MAX); - free(tmp); // this should ha - } - - // try to load it from prefix/lib - plugin_path_list * path = paths.last(); - new plugin_path_list(path); - strncpy(path->fullpath,PLAYER_INSTALL_PREFIX, PATH_MAX); - strncat(path->fullpath,"/lib/", PATH_MAX); - strncat(path->fullpath,pluginname, PATH_MAX); - - // just pass the libname to lt_dlopenext, to see if it can handle it - // (this may work when the plugin is installed in a default system - // location). - path = paths.last(); - strncpy(path->fullpath,pluginname,PATH_MAX); - - PLAYER_MSG1(3, "loading plugin %s", pluginname); - } - for (plugin_path_list *path = &paths;!handle && path;path = path->next) - { - if((handle = lt_dlopenext(path->fullpath))) - { - break; - } - } - + // start with $PLAYERPATH, if set + if(( playerpath = getenv("PLAYERPATH"))) + { + if( lt_dlsetsearchpath( playerpath ) ) + PLAYER_ERROR( "failed to initialize plugin path to $PLAYERPATH" ); + } + + // add the working directory + char workingdir[PATH_MAX]; + getcwd( workingdir, PATH_MAX ); + if( lt_dladdsearchdir( workingdir ) ) + PLAYER_ERROR1( "failed to add working directory %s to the plugin path", workingdir ); + + // add the directory where the config file is + if(cfgfile) + { + // Note that dirname() modifies the contents on some + // platforms, so we need to make a copy of the filename. + char* tmp = strdup(cfgfile); + assert(tmp); + char* cfgdir = dirname(tmp); + if( lt_dladdsearchdir( cfgdir ) ) + PLAYER_ERROR1( "failed to add config file directory %s to the plugin path", cfgdir ); + free(tmp); + } + + // add $PLAYER_INSTALL_PREFIX/lib + char installdir[ PATH_MAX ]; + strncpy( installdir, PLAYER_INSTALL_PREFIX, PATH_MAX); + strncat( installdir, "/lib/", PATH_MAX); + if( lt_dladdsearchdir( installdir ) ) + PLAYER_ERROR1( "failed to add working directory %s to the plugin path", installdir ); + } + + PLAYER_MSG1(3, "loading plugin %s", pluginname); + + lt_dlhandle handle = handle = lt_dlopenext( pluginname ); + if(!handle) - { - PLAYER_ERROR1("failed to load plugin %s, tried paths:",pluginname); - for (plugin_path_list *path = &paths;path;path = path->next) - PLAYER_ERROR1("\t%s", path->fullpath); - } - + { + PLAYER_ERROR1( "Failed to load plugin %s.", + pluginname ); + PLAYER_ERROR1( "libtool reports error: %s", + lt_dlerror() ); + PLAYER_ERROR1( "plugin search path: %s", + lt_dlgetsearchpath() ); + } + return handle; #else Modified: code/player/trunk/server/server.cc =================================================================== --- code/player/trunk/server/server.cc 2009-01-26 00:45:25 UTC (rev 7302) +++ code/player/trunk/server/server.cc 2009-01-26 22:41:12 UTC (rev 7303) @@ -373,7 +373,7 @@ PrintCopyrightMsg() { fprintf(stderr,"\n* Part of the Player/Stage/Gazebo Project [http://playerstage.sourceforge.net].\n"); - fprintf(stderr, "* Copyright (C) 2000 - 2006 Brian Gerkey, Richard Vaughan, Andrew Howard,\n* Nate Koenig, and contributors."); + fprintf(stderr, "* Copyright (C) 2000 - 2009 Brian Gerkey, Richard Vaughan, Andrew Howard,\n* Nate Koenig, and contributors."); fprintf(stderr," Released under the GNU General Public License.\n"); fprintf(stderr,"* Player comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n* are welcome to redistribute it under certain conditions; see COPYING\n* for details.\n\n"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-01-27 01:19:06
|
Revision: 7305 http://playerstage.svn.sourceforge.net/playerstage/?rev=7305&view=rev Author: gbiggs Date: 2009-01-27 01:18:55 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Support for building natively on Windows. Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/client_libs/CMakeLists.txt code/player/trunk/client_libs/libplayerc/CMakeLists.txt code/player/trunk/client_libs/libplayerc/client.c code/player/trunk/client_libs/libplayerc/dev_actarray.c code/player/trunk/client_libs/libplayerc/dev_audio.c code/player/trunk/client_libs/libplayerc/dev_blackboard.c code/player/trunk/client_libs/libplayerc/dev_blinkenlight.c code/player/trunk/client_libs/libplayerc/dev_bumper.c code/player/trunk/client_libs/libplayerc/dev_camera.c code/player/trunk/client_libs/libplayerc/dev_fiducial.c code/player/trunk/client_libs/libplayerc/dev_gps.c code/player/trunk/client_libs/libplayerc/dev_graphics2d.c code/player/trunk/client_libs/libplayerc/dev_graphics3d.c code/player/trunk/client_libs/libplayerc/dev_gripper.c code/player/trunk/client_libs/libplayerc/dev_health.c code/player/trunk/client_libs/libplayerc/dev_imu.c code/player/trunk/client_libs/libplayerc/dev_joystick.c code/player/trunk/client_libs/libplayerc/dev_laser.c code/player/trunk/client_libs/libplayerc/dev_limb.c code/player/trunk/client_libs/libplayerc/dev_localize.c code/player/trunk/client_libs/libplayerc/dev_log.c code/player/trunk/client_libs/libplayerc/dev_map.c code/player/trunk/client_libs/libplayerc/dev_opaque.c code/player/trunk/client_libs/libplayerc/dev_pointcloud3d.c code/player/trunk/client_libs/libplayerc/dev_position1d.c code/player/trunk/client_libs/libplayerc/dev_position2d.c code/player/trunk/client_libs/libplayerc/dev_position3d.c code/player/trunk/client_libs/libplayerc/dev_ranger.c code/player/trunk/client_libs/libplayerc/dev_rfid.c code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c code/player/trunk/client_libs/libplayerc/dev_stereo.c code/player/trunk/client_libs/libplayerc/dev_vectormap.c code/player/trunk/client_libs/libplayerc/dev_wsn.c code/player/trunk/client_libs/libplayerc/device.c code/player/trunk/client_libs/libplayerc/mclient.c code/player/trunk/client_libs/libplayerc/playerc.h code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/cmake/CMakeLists.txt code/player/trunk/cmake/UsePlayerC.cmake code/player/trunk/cmake/internal/DriverUtils.cmake code/player/trunk/cmake/internal/FindOS.cmake code/player/trunk/cmake/internal/LibraryUtils.cmake code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/config.h.in code/player/trunk/examples/CMakeLists.txt code/player/trunk/examples/plugins/opaquedriver/opaque.c code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/libplayercore/addr_util.c code/player/trunk/libplayercore/addr_util.h code/player/trunk/libplayercore/configfile.cc code/player/trunk/libplayercore/configfile.h code/player/trunk/libplayercore/device.cc code/player/trunk/libplayercore/device.h code/player/trunk/libplayercore/devicetable.cc code/player/trunk/libplayercore/devicetable.h code/player/trunk/libplayercore/driver.cc code/player/trunk/libplayercore/driver.h code/player/trunk/libplayercore/drivertable.h code/player/trunk/libplayercore/error.h code/player/trunk/libplayercore/filewatcher.cc code/player/trunk/libplayercore/filewatcher.h code/player/trunk/libplayercore/globals.cc code/player/trunk/libplayercore/globals.h code/player/trunk/libplayercore/interface_util.c code/player/trunk/libplayercore/interface_util.h code/player/trunk/libplayercore/message.h code/player/trunk/libplayercore/playercommon.h code/player/trunk/libplayercore/playertime.h code/player/trunk/libplayercore/plugins.cc code/player/trunk/libplayercore/plugins.h code/player/trunk/libplayercore/property.cpp code/player/trunk/libplayercore/property.h code/player/trunk/libplayercore/threaded_driver.cc code/player/trunk/libplayercore/wallclocktime.h code/player/trunk/libplayersd/CMakeLists.txt code/player/trunk/libplayertcp/CMakeLists.txt code/player/trunk/libplayertcp/playertcp.cc code/player/trunk/libplayertcp/playertcp.h code/player/trunk/libplayertcp/playerudp.cc code/player/trunk/libplayertcp/playerudp.h code/player/trunk/libplayertcp/remote_driver.cc code/player/trunk/libplayertcp/remote_driver.h code/player/trunk/libplayertcp/socket_util.c code/player/trunk/libplayertcp/socket_util.h code/player/trunk/libplayerxdr/CMakeLists.txt code/player/trunk/libplayerxdr/functiontable.h code/player/trunk/libplayerxdr/playerxdrgen.py code/player/trunk/playerconfig.h.in code/player/trunk/replace/cfmakeraw.c code/player/trunk/replace/clock_gettime.c code/player/trunk/replace/poll.c code/player/trunk/replace/replace.h code/player/trunk/replace/round.c code/player/trunk/server/CMakeLists.txt code/player/trunk/server/drivers/actarray/CMakeLists.txt code/player/trunk/server/drivers/audio/CMakeLists.txt code/player/trunk/server/drivers/base/imagebase.cc code/player/trunk/server/drivers/blackboard/localbb/localbb.cpp code/player/trunk/server/drivers/blobfinder/acts/CMakeLists.txt code/player/trunk/server/drivers/blobfinder/cmvision/P2CMV.cc code/player/trunk/server/drivers/blobfinder/cmvision/cmvision.cc code/player/trunk/server/drivers/blobfinder/cmvision/conversions.c code/player/trunk/server/drivers/camera/1394/CMakeLists.txt code/player/trunk/server/drivers/camera/sphere/CMakeLists.txt code/player/trunk/server/drivers/camera/unicap/CMakeLists.txt code/player/trunk/server/drivers/camera/uvc/CMakeLists.txt code/player/trunk/server/drivers/camera/v4l/CMakeLists.txt code/player/trunk/server/drivers/fiducial/CMakeLists.txt code/player/trunk/server/drivers/fiducial/laserbar.cc code/player/trunk/server/drivers/fiducial/laserbarcode.cc code/player/trunk/server/drivers/fiducial/laservisualbarcode.cc code/player/trunk/server/drivers/fiducial/laservisualbw.cc code/player/trunk/server/drivers/gps/CMakeLists.txt code/player/trunk/server/drivers/imu/MTComm.cpp code/player/trunk/server/drivers/imu/XSensMT.cc code/player/trunk/server/drivers/laser/CMakeLists.txt code/player/trunk/server/drivers/laser/bumper2laser.cc code/player/trunk/server/drivers/laser/lasercspace.cc code/player/trunk/server/drivers/laser/lasercutter.cc code/player/trunk/server/drivers/laser/laserposeinterpolator.cc code/player/trunk/server/drivers/laser/laserrescan.cc code/player/trunk/server/drivers/laser/lasertransform.h code/player/trunk/server/drivers/laser/sickLDMRS.cc code/player/trunk/server/drivers/laser/sicks3000.cc code/player/trunk/server/drivers/localization/amcl/amcl.cc code/player/trunk/server/drivers/localization/amcl/amcl_laser.cc code/player/trunk/server/drivers/localization/amcl/map/map.c code/player/trunk/server/drivers/localization/amcl/map/map.h code/player/trunk/server/drivers/localization/amcl/map/map_range.c code/player/trunk/server/drivers/localization/amcl/models/gps.c code/player/trunk/server/drivers/localization/amcl/models/imu.c code/player/trunk/server/drivers/localization/amcl/models/laser.c code/player/trunk/server/drivers/localization/amcl/models/sonar.c code/player/trunk/server/drivers/localization/amcl/pf/eig3.c code/player/trunk/server/drivers/localization/amcl/pf/pf.c code/player/trunk/server/drivers/localization/amcl/pf/pf_kdtree.c code/player/trunk/server/drivers/localization/amcl/pf/pf_pdf.c code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c code/player/trunk/server/drivers/localization/fakelocalize.cc code/player/trunk/server/drivers/map/maptransform.h code/player/trunk/server/drivers/map/vmapfile.cc code/player/trunk/server/drivers/mixed/botrics/CMakeLists.txt code/player/trunk/server/drivers/mixed/clodbuster/CMakeLists.txt code/player/trunk/server/drivers/mixed/cmucam2/CMakeLists.txt code/player/trunk/server/drivers/mixed/erratic/CMakeLists.txt code/player/trunk/server/drivers/mixed/evolution/er1/CMakeLists.txt code/player/trunk/server/drivers/mixed/irobot/create/CMakeLists.txt code/player/trunk/server/drivers/mixed/irobot/roomba/CMakeLists.txt code/player/trunk/server/drivers/mixed/khepera/CMakeLists.txt code/player/trunk/server/drivers/mixed/nomad/CMakeLists.txt code/player/trunk/server/drivers/mixed/p2os/CMakeLists.txt code/player/trunk/server/drivers/mixed/rflex/CMakeLists.txt code/player/trunk/server/drivers/mixed/robotino/CMakeLists.txt code/player/trunk/server/drivers/mixed/wbr/914/CMakeLists.txt code/player/trunk/server/drivers/opaque/CMakeLists.txt code/player/trunk/server/drivers/planner/wavefront/CMakeLists.txt code/player/trunk/server/drivers/planner/wavefront/plan.c code/player/trunk/server/drivers/planner/wavefront/plan_control.c code/player/trunk/server/drivers/planner/wavefront/plan_plan.c code/player/trunk/server/drivers/pointcloud3d/laserptzcloud.cc code/player/trunk/server/drivers/position/ascension/CMakeLists.txt code/player/trunk/server/drivers/position/bumpersafe/bumpersafe.cc code/player/trunk/server/drivers/position/lasersafe/lasersafe.cc code/player/trunk/server/drivers/position/mbicp/mbicp_driver.cc code/player/trunk/server/drivers/position/microstrain/CMakeLists.txt code/player/trunk/server/drivers/position/motionmind/motionmind.cc code/player/trunk/server/drivers/position/nav200/nav200.cc code/player/trunk/server/drivers/position/nav200/nav200.h code/player/trunk/server/drivers/position/nav200/sicknav200.cc code/player/trunk/server/drivers/position/nd/nd.cc code/player/trunk/server/drivers/position/nd/nd_plugin.cc code/player/trunk/server/drivers/position/roboteq/CMakeLists.txt code/player/trunk/server/drivers/position/vfh/vfh.cc code/player/trunk/server/drivers/position/vfh/vfh_algorithm.cc code/player/trunk/server/drivers/ptz/CMakeLists.txt code/player/trunk/server/drivers/ranger/lasertoranger.cc code/player/trunk/server/drivers/ranger/rangertolaser.cc code/player/trunk/server/drivers/rfid/CMakeLists.txt code/player/trunk/server/drivers/shell/dummy.cc code/player/trunk/server/drivers/shell/kartowriter.cc code/player/trunk/server/drivers/shell/passthrough.cc code/player/trunk/server/drivers/shell/readlog.cc code/player/trunk/server/drivers/shell/readlog_time.cc code/player/trunk/server/drivers/shell/relay.cc code/player/trunk/server/drivers/shell/writelog.cc code/player/trunk/server/drivers/sonar/CMakeLists.txt code/player/trunk/server/drivers/sonar/aiotosonar.cc code/player/trunk/server/drivers/speech/CMakeLists.txt code/player/trunk/server/drivers/stereo/CMakeLists.txt code/player/trunk/server/drivers/wifi/CMakeLists.txt code/player/trunk/server/drivers/wsn/CMakeLists.txt code/player/trunk/server/drivers/wsn/accel_calib.cc code/player/trunk/server/libplayerdrivers/CMakeLists.txt code/player/trunk/server/server.cc Added Paths: ----------- code/player/trunk/cmake/UsePlayerC.cmake.in code/player/trunk/libplayertcp/playertcp_errutils.h code/player/trunk/replace/CMakeLists.txt code/player/trunk/replace/gettimeofday.c code/player/trunk/replace/nanosleep.c code/player/trunk/replace/rpc/ code/player/trunk/replace/rpc/types.h code/player/trunk/replace/rpc/xdr.h code/player/trunk/replace/usleep.c code/player/trunk/replace/xdr.c code/player/trunk/replace/xdr_array.c code/player/trunk/replace/xdr_float.c code/player/trunk/replace/xdr_intXX_t.c code/player/trunk/replace/xdr_mem.c code/player/trunk/replace/xdr_sizeof.c code/player/trunk/win32_todo.txt Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/CMakeLists.txt 2009-01-27 01:18:55 UTC (rev 7305) @@ -46,16 +46,11 @@ INCLUDE (${PLAYER_CMAKE_DIR}/internal/LibraryUtils.cmake) # Set some common include directories, including the binary dir to get config.h -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libplayercore /opt/local/include ) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/libplayercore) # Extra directories where needed libraries, etc may be located (set by the user) INCLUDE_DIRECTORIES (${PLAYER_EXTRA_INCLUDE_DIRS}) LINK_DIRECTORIES (${PLAYER_EXTRA_LIB_DIRS}) -# rtv hack -link_directories( /opt/local/lib ) -include_directories( /opt/local/include ) - -# If on Windows, only build the client libraries. (this won't actually work yet cause libplayerc needs some stuff from core) ADD_SUBDIRECTORY (client_libs) ADD_SUBDIRECTORY (libplayercore) ADD_SUBDIRECTORY (libplayerxdr) @@ -66,9 +61,14 @@ ADD_SUBDIRECTORY (rtk2) ADD_SUBDIRECTORY (server) ADD_SUBDIRECTORY (examples) -ADD_SUBDIRECTORY (utils) -ADD_SUBDIRECTORY (doc) +IF (NOT PLAYER_OS_WIN) + ADD_SUBDIRECTORY (utils) + ADD_SUBDIRECTORY (doc) +ENDIF (NOT PLAYER_OS_WIN) ADD_SUBDIRECTORY (cmake) # CMake modules for Player libraries +IF (PLAYER_OS_WIN) + ADD_SUBDIRECTORY (replace) +ENDIF (PLAYER_OS_WIN) MESSAGE (STATUS "") SET (PLAYER_EXTRA_LINK_LIBRARIES "" CACHE INTERNAL "Libs to link to" FORCE) Modified: code/player/trunk/client_libs/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/CMakeLists.txt 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/CMakeLists.txt 2009-01-27 01:18:55 UTC (rev 7305) @@ -1,4 +1,6 @@ MESSAGE (STATUS "===== Client Libraries =====") ADD_SUBDIRECTORY (libplayerc) -ADD_SUBDIRECTORY (libplayerc++) +IF (NOT PLAYER_OS_WIN) + ADD_SUBDIRECTORY (libplayerc++) +ENDIF (NOT PLAYER_OS_WIN) MESSAGE (STATUS "============================") Modified: code/player/trunk/client_libs/libplayerc/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/CMakeLists.txt 2009-01-27 01:18:55 UTC (rev 7305) @@ -1,10 +1,11 @@ ADD_SUBDIRECTORY (bindings) -INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs /opt/local/include) +INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs) +# Possibly use our own copy of XDR, and need gettimeofday replacement +IF (NOT HAVE_XDR OR NOT HAVE_GETTIMEOFDAY) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) +ENDIF (NOT HAVE_XDR OR NOT HAVE_GETTIMEOFDAY) -link_directories( /opt/local/lib ) - - SET (PLAYERC_EXTRA_LINK_LIBRARIES) SET (playercSrcs playerc.h mclient.c @@ -54,19 +55,30 @@ dev_vectormap.c dev_wifi.c dev_wsn.c) +IF (NOT HAVE_GETTIMEOFDAY) + SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/gettimeofday.c) +ENDIF (NOT HAVE_GETTIMEOFDAY) IF (NOT HAVE_POLL) - SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/poll.c) + SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/poll.c) ENDIF (NOT HAVE_POLL) -APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" z m) +IF (NOT HAVE_NANOSLEEP) + SET (playercSrcs ${playercSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) +ENDIF (NOT HAVE_NANOSLEEP) PLAYER_ADD_LIBRARY (playerc ${playercSrcs}) -ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src ) +ADD_DEPENDENCIES (playerc player_interfaces playerxdr_src) TARGET_LINK_LIBRARIES (playerc playerxdr playerutils playererror ${PLAYERC_EXTRA_LINK_LIBRARIES}) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (playerc playerjpeg) ENDIF (HAVE_JPEG) +IF (HAVE_M) + TARGET_LINK_LIBRARIES (playerc m) + APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" m) + SET (libmLinkStr "-lm") +ENDIF (HAVE_M) IF (HAVE_Z) TARGET_LINK_LIBRARIES (playerc z) + APPEND_TO_CACHED_LIST (PLAYERC_EXTRA_LINK_LIBRARIES "Libs to link to with playerc" z) ENDIF (HAVE_Z) IF (HAVE_GEOS) TARGET_LINK_LIBRARIES (playerc ${GEOS_LIBS}) @@ -76,7 +88,10 @@ ELSEIF (PLAYER_OS_SOLARIS) TARGET_LINK_LIBRARIES (playerc socket nsl rt) ENDIF (PLAYER_OS_QNX) +IF (PLAYER_OS_WIN) + TARGET_LINK_LIBRARIES (playerc Ws2_32) +ENDIF (PLAYER_OS_WIN) PLAYER_INSTALL_HEADERS (playerc playerc.h) -PLAYER_MAKE_PKGCONFIG ("playerc" "Andrew Howard's Player C client library - part of the Player Project" "playerxdr playererror" "" "" "-lm") +PLAYER_MAKE_PKGCONFIG ("playerc" "Andrew Howard's Player C client library - part of the Player Project" "playerxdr playererror" "" "" "${libmLinkStr}") Modified: code/player/trunk/client_libs/libplayerc/client.c =================================================================== --- code/player/trunk/client_libs/libplayerc/client.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/client.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -50,19 +50,21 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include <signal.h> -#include <netinet/in.h> #if ENABLE_TCP_NODELAY #include <netinet/tcp.h> #endif -#include <sys/socket.h> -#include <netdb.h> // for gethostbyname() #include <errno.h> -#include <sys/time.h> #include <time.h> -#include <unistd.h> #include <fcntl.h> +#if !defined (WIN32) + #include <sys/socket.h> + #include <netinet/in.h> + #include <unistd.h> + #include <netdb.h> // for gethostbyname() + #include <sys/time.h> + #include <unistd.h> +#endif #ifdef HAVE_POLL #include <sys/poll.h> @@ -73,6 +75,23 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf + #define strdup _strdup + #define ErrNo WSAGetLastError() + const int ERRNO_EAGAIN = WSAEWOULDBLOCK; + LPVOID errBuffer = NULL; + #define STRERROR(errMacro,text) { \ + FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, \ + ErrNo, 0, (LPTSTR) &errBuffer, 0, NULL); \ + errMacro (text, ErrNo, (LPTSTR) errBuffer); \ + LocalFree (errBuffer);} +#else + #define ErrNo errno + const int ERRNO_EAGAIN = EAGAIN; + #define STRERROR(errMacro,text) errMacro (text, ErrNo, strerror (ErrNo)); +#endif + // Have we done one-time intialization work yet? static int init_done; @@ -131,6 +150,18 @@ playerc_client_t *playerc_client_create(playerc_mclient_t *mclient, const char *host, int port) { playerc_client_t *client; +#if defined (WIN32) + // Initialise Windows sockets API (this can safely be done as many times as we like) + // Thus must be called once for every client creation, in order to match the calls on + // client destruction (winsocks uses an internal reference counter to ensure only the + // final call to WSACleanup actually does anything). + WSADATA info; + int result; + if ((result = WSAStartup (MAKEWORD (2, 2), &info)) != 0) + { + PLAYERC_ERR1 ("Failed to initialise Windows sockets API with error %d", result); + } +#endif // Have we done one-time intialization work yet? if(!init_done) @@ -193,6 +224,12 @@ playerxdr_cleanup_message(client->data,header.addr.interf, header.type, header.subtype); } +#if defined (WIN32) + // Clean up the Windows sockets API (this can safely be done as many times as we like) + if (WSACleanup () != 0) + PLAYER_ERROR1 ("Failed to clean up Windows sockets API with error %s", WSAGetLastError ()); +#endif + free(client->data); free(client->write_xdrdata); free(client->read_xdrdata); @@ -218,23 +255,31 @@ struct hostent* entp = NULL; #endif char banner[PLAYER_IDENT_STRLEN]; - int old_flags; int ret; //double t; /* struct timeval last; struct timeval curr; */ +#if defined (WIN32) + unsigned long setting = 0; +#else + int old_flags; struct itimerval timer; + struct sigaction sigact; +#endif struct sockaddr_in clientaddr; - struct sigaction sigact; // Construct socket if(client->transport == PLAYERC_TRANSPORT_UDP) { +#if defined (WIN32) + if((client->sock = socket(PF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) +#else if((client->sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) +#endif { - PLAYERC_ERR1("socket call failed with error [%s]", strerror(errno)); + STRERROR(PLAYERC_ERR2, "socket() failed with error [%d: %s]"); return -1; } /* @@ -251,15 +296,19 @@ if(bind(client->sock, (struct sockaddr*)&clientaddr, sizeof(clientaddr)) < -1) { - PLAYERC_ERR1("bind call failed with error [%s]", strerror(errno)); + STRERROR(PLAYERC_ERR2, "bind() failed with error [%d: %s]"); return -1; } } else { +#if defined (WIN32) + if((client->sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) +#else if((client->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) +#endif { - PLAYERC_ERR1("socket call failed with error [%s]", strerror(errno)); + STRERROR(PLAYERC_ERR2, "socket() failed with error [%d: %s]"); return -1; } } @@ -309,7 +358,7 @@ if (entp == NULL) { playerc_client_disconnect(client); - PLAYERC_ERR1("gethostbyname() failed with error [%s]", strerror(errno)); + STRERROR(PLAYERC_ERR2, "gethostbyname() failed with error [%d: %s]"); return -1; } assert(entp->h_length <= sizeof (client->server.sin_addr)); @@ -336,6 +385,7 @@ } while (ret == -1 && (errno == EALREADY || errno == EAGAIN || errno == EINPROGRESS)); */ +#if !defined (WIN32) /* Set up a timer to interrupt the connection process */ timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; @@ -361,10 +411,12 @@ PLAYER_WARN("failed to set SIGALRM action data; " "unexpected exit may result"); } +#endif ret = connect(client->sock, (struct sockaddr*)&client->server, sizeof(client->server)); +#if !defined (WIN32) /* Turn off timer */ timer.it_value.tv_sec = 0; timer.it_value.tv_usec = 0; @@ -380,12 +432,21 @@ #endif PLAYER_WARN("failed to reset SIGALRM action data; " "unexpected behavior may result"); +#endif if (ret < 0) { playerc_client_disconnect(client); +#if defined (WIN32) + FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + ErrNo, 0, (LPTSTR) &errBuffer, 0, NULL); + PLAYERC_ERR4 ("connect call on [%s:%d] failed with error [%d:%s]", + client->host, client->port, ErrNo, (LPTSTR) errBuffer); + LocalFree (errBuffer); +#else PLAYERC_ERR4("connect call on [%s:%d] failed with error [%d:%s]", - client->host, client->port, errno, strerror(errno)); + client->host, client->port, errno, strerror(ErrNo)); +#endif return -1; } @@ -394,12 +455,21 @@ { if(send(client->sock, NULL, 0, 0) < 0) { - PLAYERC_ERR1("send() failed with error [%s]", strerror(errno)); + STRERROR(PLAYERC_ERR2, "send() failed with error [%d: %s]"); return -1; } } // set socket to be blocking +#if defined (WIN32) + if (ioctlsocket (client->sock, FIONBIO, &setting) == SOCKET_ERROR) + { + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + ErrNo, 0, (LPTSTR) &errBuffer, 0, NULL); + PLAYERC_ERR1("error getting socket flags [%s]", (LPTSTR) errBuffer); + LocalFree(errBuffer); + } +#else if ((old_flags = fcntl(client->sock, F_GETFL)) < 0) { PLAYERC_ERR1("error getting socket flags [%s]", strerror(errno)); @@ -410,6 +480,7 @@ PLAYERC_ERR1("error setting socket non-blocking [%s]", strerror(errno)); return -1; } +#endif // Get the banner @@ -437,7 +508,7 @@ int j; struct timespec sleeptime; - sleeptime.tv_sec = client->retry_time; + sleeptime.tv_sec = (long) client->retry_time; sleeptime.tv_nsec = 0; /* Disconnect */ @@ -500,12 +571,22 @@ // Disconnect from the server int playerc_client_disconnect(playerc_client_t *client) { +#if defined (WIN32) + if (closesocket(client->sock) != 0) + { + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + ErrNo, 0, (LPTSTR) &errBuffer, 0, NULL); + PLAYERC_ERR1("closesocket failed with error [%s]", (LPTSTR) errBuffer); + LocalFree(errBuffer); + } +#else if (close(client->sock) < 0) { PLAYERC_ERR1("close failed with error [%s]", strerror(errno)); client->sock = -1; return -1; } +#endif client->sock = -1; client->connected = 0; return 0; @@ -765,7 +846,7 @@ return playerc_client_writepacket(client, &header, cmd); } -inline double tdiff (const struct timeval t1, const struct timeval t2) +double tdiff (const struct timeval t1, const struct timeval t2) { return (double)(t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec)/1e6; } @@ -896,7 +977,7 @@ // proxy structure rather than returned to the caller. int playerc_client_get_devlist(playerc_client_t *client) { - int i; + uint32_t i; player_device_devlist_t *rep_config; if(playerc_client_request(client, NULL, PLAYER_PLAYER_REQ_DEVLIST, @@ -1074,7 +1155,7 @@ nbytes = timed_recv(client->sock, client->read_xdrdata + client->read_xdrdata_len, PLAYERXDR_MSGHDR_SIZE - client->read_xdrdata_len, - 0, client->request_timeout * 1e3); + 0, (int) client->request_timeout * 1000); if (nbytes <= 0) { if(nbytes == 0) @@ -1083,7 +1164,7 @@ continue; else { - PLAYERC_ERR1("recv failed with error [%s]", strerror(errno)); + STRERROR (PLAYERC_ERR2, "recv failed with error [%d: %s]"); //playerc_client_disconnect(client); if(playerc_client_disconnect_retry(client) < 0) return(-1); @@ -1118,13 +1199,13 @@ nbytes = timed_recv(client->sock, client->read_xdrdata + client->read_xdrdata_len, header->size - client->read_xdrdata_len, - 0, client->request_timeout*1e3); + 0, (int) client->request_timeout*1000); if (nbytes <= 0) { if(errno == EINTR) continue; { - PLAYERC_ERR1("recv failed with error [%s]", strerror(errno)); + STRERROR (PLAYERC_ERR2, "recv failed with error [%d: %s]"); //playerc_client_disconnect(client); if(playerc_client_disconnect_retry(client) < 0) return(-1); @@ -1251,9 +1332,13 @@ { bytes -= ret; } - else if (ret < 0 && (errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK)) +#if defined (WIN32) + else if (ret < 0 && (errno != ERRNO_EAGAIN && errno != WSAEINPROGRESS)) +#else + else if (ret < 0 && (errno != ERRNO_EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK)) +#endif { - PLAYERC_ERR2("send on body failed with error [%d:%s]", errno, strerror(errno)); + STRERROR (PLAYERC_ERR2, "send on body failed with error [%d: %s]"); //playerc_client_disconnect(client); return(playerc_client_disconnect_retry(client)); } Modified: code/player/trunk/client_libs/libplayerc/dev_actarray.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_actarray.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_actarray.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -44,6 +44,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_actarray_putmsg(playerc_actarray_t *device, player_msghdr_t *header, @@ -87,7 +91,7 @@ player_msghdr_t *header, player_actarray_data_t *data, size_t len) { - int i = 0; + uint32_t i = 0; if((header->type == PLAYER_MSGTYPE_DATA) && (header->subtype == PLAYER_ACTARRAY_DATA_STATE)) { @@ -105,14 +109,14 @@ } /** Accessor method for the actuator data */ -player_actarray_actuator_t playerc_actarray_get_actuator_data(playerc_actarray_t *device, int index) +player_actarray_actuator_t playerc_actarray_get_actuator_data(playerc_actarray_t *device, uint32_t index) { assert(index < device->actuators_count); return device->actuators_data[index]; } /** Accessor method for the actuator geom */ -player_actarray_actuatorgeom_t playerc_actarray_get_actuator_geom(playerc_actarray_t *device, int index) +player_actarray_actuatorgeom_t playerc_actarray_get_actuator_geom(playerc_actarray_t *device, uint32_t index) { assert(index < device->actuators_geom_count); return device->actuators_geom[index]; @@ -122,7 +126,7 @@ int playerc_actarray_get_geom(playerc_actarray_t *device) { player_actarray_geom_t *geom; - int ii = 0, result = 0; + uint32_t ii = 0, result = 0; if((result = playerc_client_request(device->info.client, &device->info, PLAYER_ACTARRAY_REQ_GET_GEOM, NULL, (void*)&geom)) < 0) Modified: code/player/trunk/client_libs/libplayerc/dev_audio.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_audio.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_audio.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -43,6 +43,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_audio_putmsg(playerc_audio_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_blackboard.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_blackboard.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_blackboard.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -51,8 +51,16 @@ #include "playerc.h" #include "error.h" #include <libplayerxdr/playerxdr.h> -#include <sys/time.h> +#if !defined (WIN32) + #include <sys/time.h> +#endif +#if defined (WIN32) + #define snprintf _snprintf + #define strdup _strdup + #include <replace.h> +#endif + player_blackboard_entry_t *playerc_pack_blackboard_entry_string(const char* key, const char* group, const char *str); player_blackboard_entry_t *playerc_pack_blackboard_entry_int(const char* key, const char* group, const int i); player_blackboard_entry_t *playerc_pack_blackboard_entry_double(const char* key, const char* group, const double d); Modified: code/player/trunk/client_libs/libplayerc/dev_blinkenlight.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_blinkenlight.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_blinkenlight.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -25,6 +25,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_blinkenlight_putmsg(playerc_blinkenlight_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_bumper.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_bumper.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_bumper.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -47,7 +47,9 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc/dev_camera.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_camera.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_camera.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -51,11 +51,17 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_camera_putmsg(playerc_camera_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_fiducial.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_fiducial.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_fiducial.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -28,11 +28,16 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif // Process incoming data void playerc_fiducial_putmsg(playerc_fiducial_t *device, Modified: code/player/trunk/client_libs/libplayerc/dev_gps.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_gps.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_gps.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -47,11 +47,16 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif // Local declarations void playerc_gps_putmsg(playerc_gps_t *device, Modified: code/player/trunk/client_libs/libplayerc/dev_graphics2d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_graphics2d.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_graphics2d.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -26,7 +26,9 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc/dev_graphics3d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_graphics3d.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_graphics3d.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -26,7 +26,9 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc/dev_gripper.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_gripper.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_gripper.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -46,7 +46,9 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc/dev_health.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_health.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_health.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -31,6 +31,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_health_putmsg (playerc_health_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_imu.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_imu.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_imu.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -27,11 +27,17 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_imu_putmsg (playerc_imu_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_joystick.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_joystick.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_joystick.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -49,11 +49,17 @@ #include <math.h> #include <stdlib.h> #include <string.h> -#include <netinet/in.h> +#if !defined (WIN32) + #include <netinet/in.h> +#endif #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_joystick_putmsg(playerc_joystick_t *device, player_msghdr_t *header, @@ -100,7 +106,7 @@ void playerc_joystick_putmsg(playerc_joystick_t *device, player_msghdr_t *header, player_joystick_data_t *data, size_t len) { - int i; + uint32_t i; if((header->type == PLAYER_MSGTYPE_DATA) && (header->subtype == PLAYER_JOYSTICK_DATA_STATE)) { Modified: code/player/trunk/client_libs/libplayerc/dev_laser.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_laser.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_laser.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -52,6 +52,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_laser_putmsg(playerc_laser_t *device, player_msghdr_t *header, @@ -118,7 +122,7 @@ player_msghdr_t *header, void *data) { - int i; + uint32_t i; double r, b, db; if((header->type == PLAYER_MSGTYPE_DATA) && Modified: code/player/trunk/client_libs/libplayerc/dev_limb.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_limb.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_limb.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -43,6 +43,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_limb_putmsg(playerc_limb_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_localize.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_localize.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_localize.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -51,6 +51,9 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif // Local declarations void playerc_localize_putmsg(playerc_localize_t *device, player_msghdr_t *header, @@ -100,7 +103,7 @@ void playerc_localize_putmsg(playerc_localize_t *device, player_msghdr_t *header, player_localize_data_t *data, size_t len) { - int i;//, k; + uint32_t i;//, k; device->pending_count = data->pending_count; device->pending_time = data->pending_time; Modified: code/player/trunk/client_libs/libplayerc/dev_log.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_log.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_log.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -50,6 +50,9 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif // Create a new log proxy playerc_log_t *playerc_log_create(playerc_client_t *client, int index) Modified: code/player/trunk/client_libs/libplayerc/dev_map.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_map.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_map.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -57,6 +57,9 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif // Create a new map proxy playerc_map_t *playerc_map_create(playerc_client_t *client, int index) Modified: code/player/trunk/client_libs/libplayerc/dev_opaque.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_opaque.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_opaque.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -52,6 +52,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_opaque_putmsg(playerc_opaque_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_pointcloud3d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_pointcloud3d.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_pointcloud3d.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -29,6 +29,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_pointcloud3d_putmsg (playerc_pointcloud3d_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_position1d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_position1d.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_position1d.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -50,6 +50,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_position1d_putmsg(playerc_position1d_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_position2d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_position2d.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_position2d.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -50,6 +50,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_position2d_putmsg(playerc_position2d_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_position3d.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_position3d.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_position3d.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -51,6 +51,9 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif // Local declarations void playerc_position3d_putmsg(playerc_position3d_t *device, Modified: code/player/trunk/client_libs/libplayerc/dev_ranger.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_ranger.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_ranger.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -43,6 +43,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Local declarations void playerc_ranger_putmsg(playerc_ranger_t *device, player_msghdr_t *header, void *data, size_t len); Modified: code/player/trunk/client_libs/libplayerc/dev_rfid.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_rfid.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_rfid.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -31,6 +31,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_rfid_putmsg (playerc_rfid_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -43,7 +43,7 @@ void playerc_speech_recognition_putmsg(playerc_speechrecognition_t *device, player_msghdr_t *hdr, player_speech_recognition_data_t *buffer, size_t len) { - int ii,jj; + uint32_t ii,jj; if((hdr->type == PLAYER_MSGTYPE_DATA) && (hdr->subtype == PLAYER_SPEECH_RECOGNITION_DATA_STRING )) { Modified: code/player/trunk/client_libs/libplayerc/dev_stereo.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_stereo.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_stereo.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -29,6 +29,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_stereo_putmsg (playerc_stereo_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/dev_vectormap.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -59,8 +59,13 @@ #include "error.h" #include <libplayerxdr/playerxdr.h> +#if defined (WIN32) + #define snprintf _snprintf + #define strdup _strdup +#endif + /** Dummy function passed as a function pointer GEOS when it is initialised. GEOS uses this for logging. */ -inline void geosprint(const char* format, ...) +void geosprint(const char* format, ...) { va_list ap; va_start(ap,format); @@ -120,7 +125,7 @@ // Get vectormap meta-data int playerc_vectormap_get_map_info(playerc_vectormap_t* device) { - int ii; + uint32_t ii; player_vectormap_info_t *info_req; // try to get map info Modified: code/player/trunk/client_libs/libplayerc/dev_wsn.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_wsn.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/dev_wsn.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -31,6 +31,10 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Process incoming data void playerc_wsn_putmsg (playerc_wsn_t *device, player_msghdr_t *header, Modified: code/player/trunk/client_libs/libplayerc/device.c =================================================================== --- code/player/trunk/client_libs/libplayerc/device.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/device.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -50,6 +50,9 @@ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define strdup _strdup +#endif void playerc_device_init(playerc_device_t *device, playerc_client_t *client, int code, int index, playerc_putmsg_fn_t putmsg) Modified: code/player/trunk/client_libs/libplayerc/mclient.c =================================================================== --- code/player/trunk/client_libs/libplayerc/mclient.c 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/mclient.c 2009-01-27 01:18:55 UTC (rev 7305) @@ -46,17 +46,23 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> -#include <sys/socket.h> -#include <netdb.h> // for gethostbyname() -#include <netinet/in.h> // for struct sockaddr_in, htons(3) #include <errno.h> +#if !defined (WIN32) + #include <sys/socket.h> + #include <unistd.h> + #include <netdb.h> // for gethostbyname() + #include <netinet/in.h> // for struct sockaddr_in, htons(3) +#endif #include <replace/replace.h> /* for poll */ #include "playerc.h" #include "error.h" +#if defined (WIN32) + #define snprintf _snprintf +#endif + // Create a multi-client playerc_mclient_t *playerc_mclient_create() { Modified: code/player/trunk/client_libs/libplayerc/playerc.h =================================================================== --- code/player/trunk/client_libs/libplayerc/playerc.h 2009-01-26 22:42:12 UTC (rev 7304) +++ code/player/trunk/client_libs/libplayerc/playerc.h 2009-01-27 01:18:55 UTC (rev 7305) @@ -51,7 +51,9 @@ #ifndef PLAYERC_H #define PLAYERC_H -#include <netinet/in.h> /* need this for struct sockaddr_in */ +#if !defined (WIN32) + #include <netinet/in.h> /* need this for struct sockaddr_in */ +#endif #include <stdio.h> #include <playerconfig.h> @@ -71,6 +73,9 @@ #include <libplayercore/interface_util.h> #include <libplayerxdr/playerxdr.h> #include <libplayerxdr/functiontable.h> +#if defined (WIN32) + #include <winsock2.h> +#endif #ifndef MIN #define MIN(a,b) ((a < b) ? a : b) @@ -79,6 +84,19 @@ #define MAX(a,b) ((a > b) ? a : b) #endif +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERC_EXPORT + #elif defined (playerc_EXPORTS) + #define PLAYERC_EXPORT __declspec (dllexport) + #else + #define PLAYERC_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERC_EXPORT +#endif + + #ifdef __cplusplus extern "C" { #endif @@ -329,7 +347,7 @@ in will return 0 on success and non-zero value on error; a descriptive error message can be obtained by calling this function. */ -const char *playerc_error_str(void); +PLAYERC_EXPORT const char *playerc_error_str(void); /** Get the name for a given interface code. */ /*const char *playerc_lookup_name(int code);*/ @@ -338,7 +356,7 @@ /*int playerc_lookup_code(const char *name);*/ /** Add new entries to the XDR function table. */ -int playerc_add_xdr_ftable(playerxdr_function_t *flist, int replace); +PLAYERC_EXPORT int playerc_add_xdr_ftable(playerxdr_function_t *flist, int replace); /** @}*/ /***************************************************************************/ @@ -389,21 +407,21 @@ } playerc_mclient_t; /* Create a multi-client object*/ -playerc_mclient_t *playerc_mclient_create(void); +PLAYERC_EXPORT playerc_mclient_t *playerc_mclient_create(void); /* Destroy a multi-client object*/ -void playerc_mclient_destroy(playerc_mclient_t *mclient); +PLAYERC_EXPORT void playerc_mclient_destroy(playerc_mclient_t *mclient); /* Add a client to the multi-client (private).*/ -int playerc_mclient_addclient(playerc_mclient_t *mclient, struct _playerc_client_t *client); +PLAYERC_EXPORT int playerc_mclient_addclient(playerc_mclient_t *mclient, struct _playerc_client_t *client); /* Test to see if there is pending data. Returns -1 on error, 0 or 1 otherwise.*/ -int playerc_mclient_peek(playerc_mclient_t *mclient, int timeout); +PLAYERC_EXPORT int playerc_mclient_peek(playerc_mclient_t *mclient, int timeout); /* Read incoming data. The timeout is in ms. Set timeout to a negative value to wait indefinitely.*/ -int playerc_mclient_read(playerc_mclient_t *mclient, int timeout); +PLAYERC_EXPORT int playerc_mclient_read(playerc_mclient_t *mclient, int timeout); /** @} */ /***************************************************************************/ @@ -422,10 +440,10 @@ */ /** @brief Typedef for proxy callback function */ -typedef void (*playerc_putmsg_fn_t) (void *device, char *header, char *data); +PLAYERC_EXPORT typedef void (*playerc_putmsg_fn_t) (void *device, char *header, char *data); /** @brief Typedef for proxy callback function */ -typedef void (*playerc_callback_fn_t) (void *data); +PLAYERC_EXPORT typedef void (*playerc_callback_fn_t) (void *data); /** @brief Info about an available (but not necessarily subscribed) @@ -532,7 +550,7 @@ playerc_client_destroy() to delete the object. */ -playerc_client_t *playerc_client_create(playerc_mclient_t *mclient, +PLAYERC_EXPORT playerc_client_t *playerc_client_create(playerc_mclient_t *mclient, const char *host, int port); /** @brief Destroy a client object. @@ -540,13 +558,13 @@ @param client Pointer to client object. */ -void playerc_client_destroy(playerc_client_t *client); +PLAYERC_EXPORT void playerc_client_destroy(playerc_client_t *client); /** @brief Set the transport type. @param transport Either PLAYERC_TRANSPORT_UDP or PLAYERC_TRANSPORT_TCP */ -void playerc_client_set_transport(playerc_client_t* client, +PLAYERC_EXPORT void playerc_client_set_transport(playerc_client_t* client, unsigned int transport); /** @brief Connect to the server. @@ -557,7 +575,7 @@ playerc_error_str() to get a descriptive error message. */ -int playerc_client_connect(playerc_client_t *client); +PLAYERC_EXPORT int playerc_client_connect(playerc_client_t *client); /** @brief Disconnect from the server. @@ -567,7 +585,7 @@ playerc_error_str() to get a descriptive error message. */ -int playerc_client_disconnect(playerc_client_t *client); +PLAYERC_EXPORT int playerc_client_disconnect(playerc_client_t *client); /** @brief Disconnect from the server, with potential retry. @internal @@ -575,7 +593,7 @@ @returns Returns 0 on success, non-zero otherwise. */ -int playerc_client_disconnect_retry(playerc_client_t *client); +PLAYERC_EXPORT int playerc_client_disconnect_retry(playerc_client_t *client); /** @brief Change the server's data delivery mode. @@ -591,7 +609,7 @@ playerc_error_str() to get a descriptive error message. */ -int playerc_client_datamode(playerc_client_t *client, uint8_t mode); +PLAYERC_EXPORT int playerc_client_datamode(playerc_client_t *client, uint8_t mode); /** @brief Request a round of data. @@ -604,7 +622,7 @@ Use @ref playerc_client_datamode to change modes. */ -int playerc_client_requestdata(playerc_client_t* client); +PLAYERC_EXPORT int playerc_client_requestdata(playerc_client_t* client); /** @brief Set a replace rule for the client queue on the server @@ -628,26 +646,26 @@ playerc_error_str() to get a descriptive error message. */ -int playerc_client_set_replace_rule(playerc_client_t *client, int interf, int index, int type, int subtype, int replace); +PLAYERC_EXPORT int playerc_client_set_replace_rule(playerc_client_t *client, int interf, int index, int type, int subtype, int replace); /** @brief Add a device proxy. @internal */ -int playerc_client_adddevice(playerc_client_t *client, struct _playerc_device_t *device); +PLAYERC_EXPORT int playerc_client_adddevice(playerc_client_t *client, struct _playerc_device_t *device); /** @brief Remove a device proxy. @internal */ -int playerc_client_deldevice(playerc_client_t *client, struct _playerc_device_t *device); +PLAYERC_EXPORT int playerc_client_deldevice(playerc_client_t *client, struct _playerc_device_t *device); /** @brief Add user callbacks (called when new data arrives). @internal */ -int playerc_client_addcallback(playerc_client_t *client, struct _playerc_device_t *device, +PLAYERC_EXPORT int playerc_client_addcallback(playerc_client_t *client, struct _playerc_device_t *device, playerc_callback_fn_t callback, void *data); /** @brief Remove user callbacks (called when new data arrives). @internal */ -int playerc_client_delcallback(playerc_client_t *client, struct _playerc_device_t *device, +PLAYERC_EXPORT int playerc_client_delcallback(playerc_client_t *client, struct _playerc_device_t *device, playerc_callback_fn_t callback, void *data); /** @brief Get the list of available device ids. @@ -661,16 +679,16 @@ playerc_error_str() to get a descriptive error message. */ -int playerc_client_get_devlist(playerc_client_t *client); +PLAYERC_EXPORT int playerc_client_get_devlist(playerc_client_t *client); /** @brief Subscribe a device. @internal */ -int playerc_client_subscribe(playerc_client_t *client, int code, int index, +PLAYERC_EXPORT int playerc_client_subscribe(playerc_client_t *client, int code, int index, int access, char *drivername, size_t len); /** @brief Unsubscribe a device. @internal */ -int playerc_client_unsubscribe(playerc_client_t *client, int code, int index); +PLAYERC_EXPORT int playerc_client_unsubscribe(playerc_client_t *client, int code, int index); /** @brief Issue a request to the server and await a reply (blocking). @internal @@ -682,7 +700,7 @@ @returns Returns -1 on error and -2 on NACK. */ -int playerc_client_request(playerc_client_t *client, +PLAYERC_EXPORT int playerc_client_request(playerc_client_t *client, struct _playerc_device_t *device, uint8_t reqtype, const void *req_data, void **rep_data); @@ -710,7 +728,7 @@ @returns Returns -1 on error, 0 or 1 otherwise. */ -int playerc_client_peek(playerc_client_t *client, int timeout); +PLAYERC_EXPORT int playerc_client_peek(playerc_client_t *client, int timeout); /** @brief Test to see if there is pending data. Don't send a request for data. * This function is reliant on a call being made elsewhere to request data from @@ -724,7 +742,7 @@ @returns Returns -1 on error, 0 or 1 otherwise. */ -int playerc_client_internal_peek(playerc_client_t *client, int timeout); +PLAYERC_EXPORT int playerc_client_internal_peek(playerc_client_t *client, int timeout); /** @brief Read data from the server (blocking). @@ -737,14 +755,14 @@ never return the ID of a proxy other than the client. */ -void *playerc_client_read(playerc_client_t *client); +PLAYERC_EXPORT void *playerc_client_read(playerc_client_t *client); /* Read and process a packet (nonblocking) returns 0 if no data recieved, 1 if data recieved and -1 on error*/ -int playerc_client_read_nonblock(playerc_client_t *client); +PLAYERC_EXPORT int playerc_client_read_nonblock(playerc_client_t *client); /* Read and process a packet (nonblocking), fills in pointer to proxy that got data returns 0 if no data recieved, 1 if data recieved and -1 on error*/ -int playerc_client_read_nonblock_withproxy(playerc_client_t *client, void ** proxy); +PLAYERC_EXPORT int playerc_client_read_nonblock_withproxy(playerc_client_t *client, void ** proxy); /** @brief Set the timeout for client requests. @@ -752,7 +770,7 @@ @param seconds Seconds to wait for a reply. */ -void playerc_client_set_request_timeout(playerc_client_t* client, uint32_t seconds); +PLAYERC_EXPORT void playerc_client_set_request_timeout(playerc_client_t* client, uint32_t seconds); /** @brief Set the connection retry limit. @@ -760,18 +778,18 @@ @param limit The number of times to attempt to reconnect to the server. Give -1 for infinite retry. */ -void playerc_c... [truncated message content] |
From: <gb...@us...> - 2009-01-27 08:59:17
|
Revision: 7307 http://playerstage.svn.sourceforge.net/playerstage/?rev=7307&view=rev Author: gbiggs Date: 2009-01-27 08:59:09 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Worked around a missing Check module in CMake 2.4 Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/libplayercore/interfaces/062_ranger.def Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-01-27 04:02:15 UTC (rev 7306) +++ code/player/trunk/CMakeLists.txt 2009-01-27 08:59:09 UTC (rev 7307) @@ -1,4 +1,9 @@ -CMAKE_MINIMUM_REQUIRED (VERSION 2.4.7 FATAL_ERROR) +IF (WIN32) + # Require 2.6 for Windows + CMAKE_MINIMUM_REQUIRED (VERSION 2.6 FATAL_ERROR) +ELSE (WIN32) + CMAKE_MINIMUM_REQUIRED (VERSION 2.4.7 FATAL_ERROR) +ENDIF (WIN32) # Compatibility settings IF (COMMAND CMAKE_POLICY) Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-01-27 04:02:15 UTC (rev 7306) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-01-27 08:59:09 UTC (rev 7307) @@ -3,7 +3,6 @@ INCLUDE (CheckFunctionExists) INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) -INCLUDE (CheckStructHasMember) INCLUDE (CheckSymbolExists) SET (PLAYER_EXTRA_LIB_DIRS "" CACHE STRING "List of extra library directories.") @@ -36,10 +35,19 @@ ENDIF (HAVE_XDR) SET (CMAKE_REQUIRED_LIBRARIES) +IF (CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 6) + INCLUDE (CheckStructHasMember) + CHECK_STRUCT_HAS_MEMBER ("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC) +ELSE (CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 6) + INCLUDE (CheckCSourceCompiles) + SET (CHECK_TIMESPEC_SOURCE_CODE "#include <time.h> +int main () { struct timespec *tmp; return 0; }") + CHECK_C_SOURCE_COMPILES ("${CHECK_TIMESPEC_SOURCE_CODE}" HAVE_STRUCT_TIMESPEC) +ENDIF (CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 6) + CHECK_FUNCTION_EXISTS (gettimeofday HAVE_GETTIMEOFDAY) CHECK_FUNCTION_EXISTS (usleep HAVE_USLEEP) CHECK_FUNCTION_EXISTS (nanosleep HAVE_NANOSLEEP) -CHECK_STRUCT_HAS_MEMBER ("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC) CHECK_FUNCTION_EXISTS (cfmakeraw HAVE_CFMAKERAW) CHECK_FUNCTION_EXISTS (dirname HAVE_DIRNAME) CHECK_INCLUDE_FILES (linux/joystick.h HAVE_LINUX_JOYSTICK_H) @@ -57,6 +65,7 @@ CHECK_FUNCTION_EXISTS (poll HAVE_POLL) IF (PLAYER_OS_WIN) CHECK_SYMBOL_EXISTS (POLLIN winsock2.h HAVE_POLLIN) + # This macro will have been pulled in by the previous usage on Windows CHECK_STRUCT_HAS_MEMBER ("struct pollfd" fd winsock2.h HAVE_POLLFD) ELSE (PLAYER_OS_WIN) SET (HAVE_POLLIN ${HAVE_POLL}) Modified: code/player/trunk/libplayercore/interfaces/062_ranger.def =================================================================== --- code/player/trunk/libplayercore/interfaces/062_ranger.def 2009-01-27 04:02:15 UTC (rev 7306) +++ code/player/trunk/libplayercore/interfaces/062_ranger.def 2009-01-27 08:59:09 UTC (rev 7307) @@ -1,7 +1,7 @@ description { * @brief A range sensor -Receive data from a range sensor, such as a laser scannar, sonar array or IR +Receive data from a range sensor, such as a laser scanner, sonar array or IR array. @section properties Recommended Properties This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-10 03:58:09
|
Revision: 7324 http://playerstage.svn.sourceforge.net/playerstage/?rev=7324&view=rev Author: gbiggs Date: 2009-02-10 03:58:02 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Fixes to compile with Sun Studio Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/dev_ranger.c code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c code/player/trunk/client_libs/libplayerc/dev_vectormap.c code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/config.h.in code/player/trunk/rtk2/rtk_canvas.c code/player/trunk/rtk2/rtk_menu.c code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c code/player/trunk/server/drivers/map/mapcspace.cc code/player/trunk/server/drivers/mixed/erratic/erratic.h code/player/trunk/server/drivers/mixed/nomad/Nclient.c code/player/trunk/server/drivers/position/ascension/flockofbirds.cc code/player/trunk/utils/logsplitter/CMakeLists.txt code/player/trunk/utils/playerv/playerv.h Modified: code/player/trunk/client_libs/libplayerc/dev_ranger.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_ranger.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/client_libs/libplayerc/dev_ranger.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -39,6 +39,8 @@ #include <string.h> #include <math.h> +#include <stddef.h> +#include <stdlib.h> #include "playerc.h" #include "error.h" Modified: code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/client_libs/libplayerc/dev_speech_recognition.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -70,5 +70,5 @@ device->words[jj++] = &device->rawText[ii+1]; } } -}; +} Modified: code/player/trunk/client_libs/libplayerc/dev_vectormap.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -73,7 +73,7 @@ vfprintf(stderr,format, ap); fflush(stderr); va_end(ap); -}; +} // Create a new vectormap proxy playerc_vectormap_t *playerc_vectormap_create(playerc_client_t *client, int index) Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-10 03:58:02 UTC (rev 7324) @@ -55,6 +55,7 @@ CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) CHECK_INCLUDE_FILES (dns_sd.h HAVE_DNS_SD) CHECK_INCLUDE_FILES (sys/filio.h HAVE_SYS_FILIO_H) +CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H) IF (HAVE_DNS_SD) CHECK_LIBRARY_EXISTS (dns_sd DNSServiceRefDeallocate "${PLAYER_EXTRA_LIB_DIRS}" HAVE_DNS_SD) ENDIF (HAVE_DNS_SD) Modified: code/player/trunk/config.h.in =================================================================== --- code/player/trunk/config.h.in 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/config.h.in 2009-02-10 03:58:02 UTC (rev 7324) @@ -21,4 +21,5 @@ #cmakedefine HAVE_SYS_STAT_H 1 #cmakedefine HAVE_SYS_TYPES_H 1 #cmakedefine HAVE_UNISTD_H 1 +#cmakedefine HAVE_IEEEFP_H 1 #cmakedefine WORDS_BIGENDIAN 1 Modified: code/player/trunk/rtk2/rtk_canvas.c =================================================================== --- code/player/trunk/rtk2/rtk_canvas.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/rtk2/rtk_canvas.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -671,7 +671,7 @@ { GdkImage *im; int ix, iy; - char *pixel; + unsigned char *pixel; guint32 c; unsigned char r, g, b; uint8_t *image; Modified: code/player/trunk/rtk2/rtk_menu.c =================================================================== --- code/player/trunk/rtk2/rtk_menu.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/rtk2/rtk_menu.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -168,7 +168,7 @@ int rtk_menuitem_enable(rtk_menuitem_t *item, int enable) { gtk_widget_set_sensitive(GTK_WIDGET(item->item), enable); - return; + return 0; } Modified: code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c =================================================================== --- code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -10,9 +10,12 @@ //#include <gsl/gsl_matrix.h> //#include <gsl/gsl_eigen.h> //#include <gsl/gsl_linalg.h> +#include <config.h> #if defined (WIN32) #include <float.h> #define finite _finite +#elif defined (__sun) && defined (HAVE_IEEEFP_H) + #include <ieeefp.h> #endif #include "pf_vector.h" @@ -36,11 +39,11 @@ int pf_vector_finite(pf_vector_t a) { int i; - + for (i = 0; i < 3; i++) if (!finite(a.v[i])) return 0; - + return 1; } Modified: code/player/trunk/server/drivers/map/mapcspace.cc =================================================================== --- code/player/trunk/server/drivers/map/mapcspace.cc 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/server/drivers/map/mapcspace.cc 2009-02-10 03:58:02 UTC (rev 7324) @@ -97,7 +97,7 @@ typedef enum { - CIRCLE, + CIRCLE } robot_shape_t; class MapCspace : public MapTransform Modified: code/player/trunk/server/drivers/mixed/erratic/erratic.h =================================================================== --- code/player/trunk/server/drivers/mixed/erratic/erratic.h 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/server/drivers/mixed/erratic/erratic.h 2009-02-10 03:58:02 UTC (rev 7324) @@ -93,7 +93,7 @@ set_pid_trans_i = 82, set_pid_rot_p = 83, set_pid_rot_v = 84, - set_pid_rot_i = 85, + set_pid_rot_i = 85 } command_e; Modified: code/player/trunk/server/drivers/mixed/nomad/Nclient.c =================================================================== --- code/player/trunk/server/drivers/mixed/nomad/Nclient.c 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/server/drivers/mixed/nomad/Nclient.c 2009-02-10 03:58:02 UTC (rev 7324) @@ -155,6 +155,7 @@ #include <fcntl.h> #include <signal.h> #include <unistd.h> +#include <string.h> #include "Nclient.h" #define DEBUG @@ -3609,7 +3610,7 @@ { long result; - short b_index, b_length; + unsigned short b_index, b_length; unsigned char serial_number; unsigned char packet_type; unsigned char user_send_buffer[256]; @@ -3634,7 +3635,7 @@ { long result; - short b_index, b_length; + unsigned short b_index, b_length; unsigned char serial_number; unsigned char packet_type; unsigned char user_send_buffer[256]; @@ -3664,7 +3665,7 @@ { long result; - short b_index, b_length; + unsigned short b_index, b_length; unsigned char serial_number; unsigned char packet_type; unsigned char user_send_buffer[256]; Modified: code/player/trunk/server/drivers/position/ascension/flockofbirds.cc =================================================================== --- code/player/trunk/server/drivers/position/ascension/flockofbirds.cc 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/server/drivers/position/ascension/flockofbirds.cc 2009-02-10 03:58:02 UTC (rev 7324) @@ -95,7 +95,7 @@ { public: - FlockOfBirdsSerial(char * port = FOB_DEFAULT_PORT, int rate = FOB_DEFAULT_RATE); + FlockOfBirdsSerial(const char * port = FOB_DEFAULT_PORT, int rate = FOB_DEFAULT_RATE); ~FlockOfBirdsSerial(); bool Open() {return fd >0;}; @@ -132,7 +132,7 @@ }; -FlockOfBirdsSerial::FlockOfBirdsSerial(char * port, int rate) +FlockOfBirdsSerial::FlockOfBirdsSerial(const char * port, int rate) { fd = -1; Modified: code/player/trunk/utils/logsplitter/CMakeLists.txt =================================================================== --- code/player/trunk/utils/logsplitter/CMakeLists.txt 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/utils/logsplitter/CMakeLists.txt 2009-02-10 03:58:02 UTC (rev 7324) @@ -1,5 +1,8 @@ OPTION (BUILD_UTILS_LOGSPLITTER "Build the logsplitter utility" ON) IF (BUILD_UTILS_LOGSPLITTER) PLAYER_ADD_EXECUTABLE (playerlogsplitter logsplitter.c) + IF (HAVE_M) + TARGET_LINK_LIBRARIES (playerlogsplitter m) + ENDIF (HAVE_M) # Wow, that one was easy! ENDIF (BUILD_UTILS_LOGSPLITTER) Modified: code/player/trunk/utils/playerv/playerv.h =================================================================== --- code/player/trunk/utils/playerv/playerv.h 2009-02-10 01:13:10 UTC (rev 7323) +++ code/player/trunk/utils/playerv/playerv.h 2009-02-10 03:58:02 UTC (rev 7324) @@ -656,7 +656,7 @@ // Image buffer int allocated_size; - char *img_buffer; + unsigned char *img_buffer; // Timestamp on most recent data double datatime; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-10 08:14:54
|
Revision: 7325 http://playerstage.svn.sourceforge.net/playerstage/?rev=7325&view=rev Author: gbiggs Date: 2009-02-10 08:14:48 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Changes to compile on Solaris Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/dev_vectormap.c code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/server/drivers/laser/RS4LeuzeLaserDriver.cc code/player/trunk/server/drivers/laser/lms400_cola.h code/player/trunk/server/drivers/laser/urglaserdriver.cc code/player/trunk/server/drivers/mixed/irobot/create/create_driver.cc code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc code/player/trunk/server/drivers/mixed/khepera/khepera.cc code/player/trunk/server/drivers/wsn/mica2.cc Modified: code/player/trunk/client_libs/libplayerc/dev_vectormap.c =================================================================== --- code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/client_libs/libplayerc/dev_vectormap.c 2009-02-10 08:14:48 UTC (rev 7325) @@ -54,6 +54,7 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> +#include <stddef.h> #include "playerc.h" #include "error.h" Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-10 08:14:48 UTC (rev 7325) @@ -47,7 +47,6 @@ CHECK_FUNCTION_EXISTS (gettimeofday HAVE_GETTIMEOFDAY) CHECK_FUNCTION_EXISTS (usleep HAVE_USLEEP) -CHECK_FUNCTION_EXISTS (nanosleep HAVE_NANOSLEEP) CHECK_FUNCTION_EXISTS (cfmakeraw HAVE_CFMAKERAW) CHECK_FUNCTION_EXISTS (dirname HAVE_DIRNAME) CHECK_INCLUDE_FILES (linux/joystick.h HAVE_LINUX_JOYSTICK_H) @@ -62,6 +61,13 @@ SET (CMAKE_REQUIRED_LIBRARIES dl) CHECK_LIBRARY_EXISTS (ltdl lt_dlopenext "${PLAYER_EXTRA_LIB_DIRS}" HAVE_LIBLTDL) SET (CMAKE_REQUIRED_LIBRARIES) +IF (PLAYER_OS_SUN) + SET (CMAKE_REQUIRED_LIBRARIES rt) + CHECK_FUNCTION_EXISTS (nanosleep HAVE_NANOSLEEP) + SET (CMAKE_REQUIRED_LIBRARIES) +ELSE (PLAYER_OS_SUN) + CHECK_FUNCTION_EXISTS (nanosleep HAVE_NANOSLEEP) +ENDIF (PLAYER_OS_SUN) CHECK_FUNCTION_EXISTS (poll HAVE_POLL) IF (PLAYER_OS_WIN) Modified: code/player/trunk/server/drivers/laser/RS4LeuzeLaserDriver.cc =================================================================== --- code/player/trunk/server/drivers/laser/RS4LeuzeLaserDriver.cc 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/laser/RS4LeuzeLaserDriver.cc 2009-02-10 08:14:48 UTC (rev 7325) @@ -427,7 +427,6 @@ //Registers the driver in the driver table. Called from the // player_driver_init function that the loader looks for -int rs4leuze_Register(DriverTable* table) { +void rs4leuze_Register(DriverTable* table) { table->AddDriver("rs4leuze", RS4LeuzeLaserDriver_Init); - return 0; } Modified: code/player/trunk/server/drivers/laser/lms400_cola.h =================================================================== --- code/player/trunk/server/drivers/laser/lms400_cola.h 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/laser/lms400_cola.h 2009-02-10 08:14:48 UTC (rev 7325) @@ -91,7 +91,7 @@ const char* hostname; int sockfd, portno, n; struct sockaddr_in serv_addr; -#if defined (HAVE_GETADDRINFO) +#if HAVE_GETADDRINFO struct addrinfo *addr_ptr; #else struct hostent *server; Modified: code/player/trunk/server/drivers/laser/urglaserdriver.cc =================================================================== --- code/player/trunk/server/drivers/laser/urglaserdriver.cc 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/laser/urglaserdriver.cc 2009-02-10 08:14:48 UTC (rev 7325) @@ -373,9 +373,8 @@ // Registers the driver in the driver table. Called from the // player_driver_init function that the loader looks for -int +void urglaser_Register (DriverTable* table) { table->AddDriver ("urglaser", URGLaserDriver_Init); - return (0); } Modified: code/player/trunk/server/drivers/mixed/irobot/create/create_driver.cc =================================================================== --- code/player/trunk/server/drivers/mixed/irobot/create/create_driver.cc 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/mixed/irobot/create/create_driver.cc 2009-02-10 08:14:48 UTC (rev 7325) @@ -527,9 +527,20 @@ { uint8_t index = opaque_data.data[1]; uint8_t length = opaque_data.data[2]; - uint8_t notes[length]; - uint8_t note_lengths[length]; + uint8_t *notes; + uint8_t *note_lengths; + if ((notes = new uint8_t[length]) == NULL) + { + PLAYER_ERROR("Failed to allocate memory for notes in create driver."); + return(-1); + } + if ((note_lengths = new uint8_t [length]) == NULL) + { + PLAYER_ERROR("Failed to allocate memory for note_lengths in create driver."); + delete [] notes; + return -1; + } for (unsigned int i=0; i<length; i++) { notes[i] = opaque_data.data[3+i*2]; @@ -538,6 +549,8 @@ create_set_song(this->create_dev, index, length, notes, note_lengths); + delete [] notes; + delete [] note_lengths; } // Set the LEDs else if (opaque_data.data[0] == 2) Modified: code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc =================================================================== --- code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/mixed/irobot/roomba/roomba_driver.cc 2009-02-10 08:14:48 UTC (rev 7325) @@ -111,6 +111,7 @@ #include <string.h> #include <pthread.h> #include <time.h> +#include <stdlib.h> #include <libplayercore/playercore.h> #include "roomba_comms.h" @@ -354,14 +355,20 @@ memset(&bumperdata,0,sizeof(bumperdata)); bumperdata.bumpers_count = 2; - bumperdata.bumpers = new uint8_t[bumperdata.bumpers_count]; - bumperdata.bumpers[0] = this->roomba_dev->bumper_left; - bumperdata.bumpers[1] = this->roomba_dev->bumper_right; + if ((bumperdata.bumpers = new uint8_t[bumperdata.bumpers_count]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for bumper data in roomba driver."); + } + else + { + bumperdata.bumpers[0] = this->roomba_dev->bumper_left; + bumperdata.bumpers[1] = this->roomba_dev->bumper_right; - this->Publish(this->bumper_addr, - PLAYER_MSGTYPE_DATA, PLAYER_BUMPER_DATA_STATE, - (void*)&bumperdata); - delete [] bumperdata.bumpers; + this->Publish(this->bumper_addr, + PLAYER_MSGTYPE_DATA, PLAYER_BUMPER_DATA_STATE, + (void*)&bumperdata); + delete [] bumperdata.bumpers; + } //////////////////////////// // Update IR data @@ -369,23 +376,29 @@ memset(&irdata,0,sizeof(irdata)); irdata.ranges_count = 11; - irdata.ranges = new float [irdata.ranges_count]; - irdata.ranges[0] = (float)this->roomba_dev->wall; - irdata.ranges[1] = (float)this->roomba_dev->cliff_left; - irdata.ranges[2] = (float)this->roomba_dev->cliff_frontleft; - irdata.ranges[3] = (float)this->roomba_dev->cliff_frontright; - irdata.ranges[4] = (float)this->roomba_dev->cliff_right; - irdata.ranges[5] = (float)this->roomba_dev->virtual_wall; - irdata.ranges[6] = (float)this->roomba_dev->dirtdetector_right; - irdata.ranges[7] = (float)this->roomba_dev->dirtdetector_left; - irdata.ranges[8] = (float)this->roomba_dev->wheeldrop_caster; - irdata.ranges[9] = (float)this->roomba_dev->wheeldrop_left; - irdata.ranges[10] = (float)this->roomba_dev->wheeldrop_right; + if ((irdata.ranges = new float [irdata.ranges_count]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for IR data in roomba driver."); + } + else + { + irdata.ranges[0] = (float)this->roomba_dev->wall; + irdata.ranges[1] = (float)this->roomba_dev->cliff_left; + irdata.ranges[2] = (float)this->roomba_dev->cliff_frontleft; + irdata.ranges[3] = (float)this->roomba_dev->cliff_frontright; + irdata.ranges[4] = (float)this->roomba_dev->cliff_right; + irdata.ranges[5] = (float)this->roomba_dev->virtual_wall; + irdata.ranges[6] = (float)this->roomba_dev->dirtdetector_right; + irdata.ranges[7] = (float)this->roomba_dev->dirtdetector_left; + irdata.ranges[8] = (float)this->roomba_dev->wheeldrop_caster; + irdata.ranges[9] = (float)this->roomba_dev->wheeldrop_left; + irdata.ranges[10] = (float)this->roomba_dev->wheeldrop_right; - this->Publish(this->ir_addr, - PLAYER_MSGTYPE_DATA, PLAYER_IR_DATA_RANGES, - (void*)&irdata); - delete [] irdata.ranges; + this->Publish(this->ir_addr, + PLAYER_MSGTYPE_DATA, PLAYER_IR_DATA_RANGES, + (void*)&irdata); + delete [] irdata.ranges; + } //////////////////////////// @@ -408,19 +421,24 @@ memset(&cpdata,0,sizeof(cpdata)); cpdata.data_count=5; - cpdata.data = new uint8_t [cpdata.data_count]; + if ((cpdata.data = new uint8_t [cpdata.data_count]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for opaque data in roomba driver."); + } + else + { + cpdata.data[0]=this->roomba_dev->button_max; + cpdata.data[1]=this->roomba_dev->button_clean; + cpdata.data[2]=this->roomba_dev->button_spot; + cpdata.data[3]=this->roomba_dev->button_power; + cpdata.data[4]=this->roomba_dev->remote_opcode; - cpdata.data[0]=this->roomba_dev->button_max; - cpdata.data[1]=this->roomba_dev->button_clean; - cpdata.data[2]=this->roomba_dev->button_spot; - cpdata.data[3]=this->roomba_dev->button_power; - cpdata.data[4]=this->roomba_dev->remote_opcode; + this->Publish(this->opaque_addr, + PLAYER_MSGTYPE_DATA,PLAYER_OPAQUE_DATA_STATE, + (void*)&cpdata); + delete [] cpdata.data; + } - this->Publish(this->opaque_addr, - PLAYER_MSGTYPE_DATA,PLAYER_OPAQUE_DATA_STATE, - (void*)&cpdata); - delete [] cpdata.data; - struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = CYCLE_TIME_NS; @@ -576,9 +594,21 @@ { uint8_t index = opaque_data.data[1]; uint8_t length = opaque_data.data[2]; - uint8_t notes[length]; - uint8_t note_lengths[length]; + uint8_t *notes; + uint8_t *note_lengths; + if ((notes = new uint8_t[length]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for notes in roomba driver."); + return -1; + } + if ((note_lengths = new uint8_t[length]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for note_lengths in roomba driver."); + delete [] notes; + return -1; + } + for (unsigned int i=0; i<length; i++) { notes[i] = opaque_data.data[3+i*2]; @@ -587,6 +617,8 @@ roomba_set_song(this->roomba_dev, index, length, notes, note_lengths); + delete [] notes; + delete [] note_lengths; } // Set the LEDs else if (opaque_data.data[0] == 2) Modified: code/player/trunk/server/drivers/mixed/khepera/khepera.cc =================================================================== --- code/player/trunk/server/drivers/mixed/khepera/khepera.cc 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/mixed/khepera/khepera.cc 2009-02-10 08:14:48 UTC (rev 7325) @@ -521,7 +521,7 @@ for (unsigned int i =0; i < geometry->ir.poses_count; i++) { - d->ranges[i] = geometry->scale * geometry->ir_calib_a[i] * pow(d->voltages[i],geometry->ir_calib_b[i]); + d->ranges[i] = geometry->scale * geometry->ir_calib_a[i] * pow(static_cast<double> (d->voltages[i]),static_cast<double> (geometry->ir_calib_b[i])); d->voltages[i] = d->voltages[i]; } } Modified: code/player/trunk/server/drivers/wsn/mica2.cc =================================================================== --- code/player/trunk/server/drivers/wsn/mica2.cc 2009-02-10 03:58:02 UTC (rev 7324) +++ code/player/trunk/server/drivers/wsn/mica2.cc 2009-02-10 08:14:48 UTC (rev 7325) @@ -1050,8 +1050,8 @@ wsn_data.data_packet.temperature = (1 / (0.001307050f + 0.000214381f * - log (rthr) + 0.000000093f * - pow (log (rthr),3))) - 273.15; + log (static_cast<double> (rthr)) + 0.000000093f * + pow (log (static_cast<double> (rthr)),3))) - 273.15; // Convert the magnetometer data to Gauss wsn_data.data_packet.magn_x = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-17 00:56:44
|
Revision: 7337 http://playerstage.svn.sourceforge.net/playerstage/?rev=7337&view=rev Author: gbiggs Date: 2009-02-17 00:56:38 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Fixes for compilation on SunStudio Modified Paths: -------------- code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc code/player/trunk/server/drivers/camera/v4l/v4lcapture.c code/player/trunk/server/drivers/camera/v4l/v4lcapture.h code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c code/player/trunk/server/drivers/mixed/rflex/CMakeLists.txt code/player/trunk/server/drivers/rfid/skyetekM1.cc Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-17 00:56:38 UTC (rev 7337) @@ -61,13 +61,13 @@ SET (CMAKE_REQUIRED_LIBRARIES dl) CHECK_LIBRARY_EXISTS (ltdl lt_dlopenext "${PLAYER_EXTRA_LIB_DIRS}" HAVE_LIBLTDL) SET (CMAKE_REQUIRED_LIBRARIES) -IF (PLAYER_OS_SUN) +IF (PLAYER_OS_SOLARIS) SET (CMAKE_REQUIRED_LIBRARIES rt) CHECK_FUNCTION_EXISTS (nanosleep HAVE_NANOSLEEP) SET (CMAKE_REQUIRED_LIBRARIES) -ELSE (PLAYER_OS_SUN) +ELSE (PLAYER_OS_SOLARIS) CHECK_FUNCTION_EXISTS (nanosleep HAVE_NANOSLEEP) -ENDIF (PLAYER_OS_SUN) +ENDIF (PLAYER_OS_SOLARIS) CHECK_FUNCTION_EXISTS (poll HAVE_POLL) IF (PLAYER_OS_WIN) Modified: code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc =================================================================== --- code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc 2009-02-17 00:56:38 UTC (rev 7337) @@ -225,7 +225,7 @@ //////////////////////////////////////////////////////////////////////////////// // Shutdown the device (called by server thread). -int UPCBarcode::MainQuit() +void UPCBarcode::MainQuit() { ImageBase::MainQuit(); @@ -252,8 +252,14 @@ width = this->stored_data.width; height = this->stored_data.height; - int symbols[height][2]; + int symbols[][2]; + if ((symbols = new int[height][2]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for symbols in upcbarcode"); + return -1; + } + // Create input image if it doesnt exist if (this->inpImage == NULL) this->inpImage = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1); @@ -271,6 +277,7 @@ default: { PLAYER_WARN1("image format [%d] is not supported", this->stored_data.format); + delete[] symbols; return -1; } } @@ -299,7 +306,7 @@ for (x = 0; x < width; x += step_x) { // Extract raw symbols - symbol_count = this->ExtractSymbols(x, sizeof(symbols) / sizeof(symbols[0]), symbols); + symbol_count = this->ExtractSymbols(x, height * 2, symbols); // Identify barcode id = this->ExtractCode(symbol_count, symbols, &min, &max); @@ -345,6 +352,7 @@ WriteBlobfinderData(); + delete[] symbols; return 0; } Modified: code/player/trunk/server/drivers/camera/v4l/v4lcapture.c =================================================================== --- code/player/trunk/server/drivers/camera/v4l/v4lcapture.c 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/server/drivers/camera/v4l/v4lcapture.c 2009-02-17 00:56:38 UTC (rev 7337) @@ -442,7 +442,7 @@ if ((fg->picture.palette) == VIDEO_PALETTE_JPEG) { - buf = (unsigned char *)(fg->mb_map + fg->mbuf.offsets[fg->cur_frame]); + buf = ((unsigned char *)(fg->mb_map)) + fg->mbuf.offsets[fg->cur_frame]; insize = frame_get_size(fr) - sizeof(int); count = insize - 1; for (i = 1024; i < count; i++) @@ -459,7 +459,7 @@ { // Save video buffer into our own memory memcpy( fr->data, - fg->mb_map + fg->mbuf.offsets[fg->cur_frame], + ((unsigned char *)(fg->mb_map)) + fg->mbuf.offsets[fg->cur_frame], frame_get_size( fr ) ); } Modified: code/player/trunk/server/drivers/camera/v4l/v4lcapture.h =================================================================== --- code/player/trunk/server/drivers/camera/v4l/v4lcapture.h 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/server/drivers/camera/v4l/v4lcapture.h 2009-02-17 00:56:38 UTC (rev 7337) @@ -53,8 +53,10 @@ #include <sys/mman.h> #include <sys/ioctl.h> -#include <linux/fs.h> -#include <linux/kernel.h> +#if !defined (sun) + #include <linux/fs.h> + #include <linux/kernel.h> +#endif #include <linux/videodev.h> #include "v4lframe.h" Modified: code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c =================================================================== --- code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c 2009-02-17 00:56:38 UTC (rev 7337) @@ -14,7 +14,7 @@ #if defined (WIN32) #include <float.h> #define finite _finite -#elif defined (__sun) && defined (HAVE_IEEEFP_H) +#elif defined (sun) && defined (HAVE_IEEEFP_H) #include <ieeefp.h> #endif Modified: code/player/trunk/server/drivers/mixed/rflex/CMakeLists.txt =================================================================== --- code/player/trunk/server/drivers/mixed/rflex/CMakeLists.txt 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/server/drivers/mixed/rflex/CMakeLists.txt 2009-02-17 00:56:38 UTC (rev 7337) @@ -1,3 +1,4 @@ PLAYERDRIVER_OPTION (rflex build_rflex ON) PLAYERDRIVER_REJECT_OS (rflex build_rflex PLAYER_OS_WIN) +PLAYERDRIVER_REJECT_OS (reflex build_rflex PLAYER_OS_SOLARIS) PLAYERDRIVER_ADD_DRIVER (rflex build_rflex SOURCES rflex.cc rflex_commands.cc rflex-io.cc) Modified: code/player/trunk/server/drivers/rfid/skyetekM1.cc =================================================================== --- code/player/trunk/server/drivers/rfid/skyetekM1.cc 2009-02-16 01:59:06 UTC (rev 7336) +++ code/player/trunk/server/drivers/rfid/skyetekM1.cc 2009-02-17 00:56:38 UTC (rev 7337) @@ -429,12 +429,25 @@ if (response_buf[0] == 0x02) len = response_buf[1]; - unsigned char TID[len]; - memset (&TID, 0, sizeof (TID)); // clear the struct for new port settings + unsigned char *TID; + if (len <= 0) + { + PLAYER_WARN ("skyetekM1: len <= 0 after serial read"); + return; + } + if ((TID = new unsigned char[len]) == NULL) + { + PLAYER_ERROR ("Failed to allocate memory for TID in skyetekM1 driver."); + return; + } + memset (&TID, 0, len); // clear the struct for new port settings usleep (10000); // sleep for 10ms ReadSerial (TID, len); if (response_buf[2] == 0x94) + { + delete[] TID; break; + } if (response_buf[0] == 0x02) { @@ -455,6 +468,7 @@ this->Data.tags[this->Data.tags_count].guid[j] = TID[j+1]; this->Data.tags_count++; } + delete[] TID; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-18 00:09:38
|
Revision: 7341 http://playerstage.svn.sourceforge.net/playerstage/?rev=7341&view=rev Author: gbiggs Date: 2009-02-18 00:09:26 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Fixes for Solaris Modified Paths: -------------- code/player/trunk/playerconfig.h.in code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c Modified: code/player/trunk/playerconfig.h.in =================================================================== --- code/player/trunk/playerconfig.h.in 2009-02-17 08:39:45 UTC (rev 7340) +++ code/player/trunk/playerconfig.h.in 2009-02-18 00:09:26 UTC (rev 7341) @@ -13,7 +13,7 @@ #cmakedefine INCLUDE_RTK 1 #cmakedefine INCLUDE_RTKGUI 1 #cmakedefine HAVE_CLOCK_GETTIME 1 -#cmakedefine HAVE_XDR +#cmakedefine HAVE_XDR 1 #cmakedefine HAVE_XDR_LONGLONG_T 1 #cmakedefine HAVE_STL 1 #cmakedefine HAVE_M 1 Modified: code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc =================================================================== --- code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc 2009-02-17 08:39:45 UTC (rev 7340) +++ code/player/trunk/server/drivers/blobfinder/upcbarcode/upcbarcode.cc 2009-02-18 00:09:26 UTC (rev 7341) @@ -252,7 +252,7 @@ width = this->stored_data.width; height = this->stored_data.height; - int symbols[][2]; + int (*symbols)[2]; if ((symbols = new int[height][2]) == NULL) { Modified: code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c =================================================================== --- code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c 2009-02-17 08:39:45 UTC (rev 7340) +++ code/player/trunk/server/drivers/localization/amcl/pf/pf_vector.c 2009-02-18 00:09:26 UTC (rev 7341) @@ -14,7 +14,8 @@ #if defined (WIN32) #include <float.h> #define finite _finite -#elif defined (sun) && defined (HAVE_IEEEFP_H) +#endif +#if defined (HAVE_IEEEFP_H) #include <ieeefp.h> #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-18 03:43:42
|
Revision: 7342 http://playerstage.svn.sourceforge.net/playerstage/?rev=7342&view=rev Author: gbiggs Date: 2009-02-18 03:43:36 +0000 (Wed, 18 Feb 2009) Log Message: ----------- C++ client library now compiles on Windows, as do some utilities. Added libreplace code for getopt. Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/client_libs/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/aioproxy.cc code/player/trunk/client_libs/libplayerc++/blackboardproxy.cc code/player/trunk/client_libs/libplayerc++/clientproxy.h code/player/trunk/client_libs/libplayerc++/playerc++.h code/player/trunk/client_libs/libplayerc++/playerclient.cc code/player/trunk/client_libs/libplayerc++/playerclient.h code/player/trunk/client_libs/libplayerc++/playererror.h code/player/trunk/client_libs/libplayerc++/rfidproxy.cc code/player/trunk/client_libs/libplayerc++/speechproxy.cc code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/test/test.cc code/player/trunk/client_libs/libplayerc++/test/test_actarray.cc code/player/trunk/client_libs/libplayerc++/test/test_aio.cc code/player/trunk/client_libs/libplayerc++/test/test_bumper.cc code/player/trunk/client_libs/libplayerc++/test/test_dio.cc code/player/trunk/client_libs/libplayerc++/test/test_gripper.cc code/player/trunk/client_libs/libplayerc++/test/test_gripper_holdsub.cc code/player/trunk/client_libs/libplayerc++/test/test_laser.cc code/player/trunk/client_libs/libplayerc++/test/test_position2d.cc code/player/trunk/client_libs/libplayerc++/test/test_position2d_holdsub.cc code/player/trunk/client_libs/libplayerc++/test/test_power.cc code/player/trunk/client_libs/libplayerc++/test/test_ptz.cc code/player/trunk/client_libs/libplayerc++/test/test_ranger.cc code/player/trunk/client_libs/libplayerc++/test/test_sonar.cc code/player/trunk/client_libs/libplayerc++/test/test_speech.cc code/player/trunk/client_libs/libplayerc++/utility.h code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/config.h.in code/player/trunk/replace/replace.h code/player/trunk/server/CMakeLists.txt code/player/trunk/server/server.cc code/player/trunk/utils/logsplitter/logsplitter.c code/player/trunk/utils/playerjoy/CMakeLists.txt code/player/trunk/utils/playerprint/CMakeLists.txt code/player/trunk/utils/playerprint/playerprint.cc code/player/trunk/utils/playerprop/CMakeLists.txt code/player/trunk/utils/playerprop/playerprop.cpp code/player/trunk/utils/pmap/CMakeLists.txt code/player/trunk/win32_todo.txt Added Paths: ----------- code/player/trunk/replace/getopt.c Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -66,10 +66,8 @@ ADD_SUBDIRECTORY (rtk2) ADD_SUBDIRECTORY (server) ADD_SUBDIRECTORY (examples) -IF (NOT PLAYER_OS_WIN) - ADD_SUBDIRECTORY (utils) - ADD_SUBDIRECTORY (doc) -ENDIF (NOT PLAYER_OS_WIN) +ADD_SUBDIRECTORY (utils) +ADD_SUBDIRECTORY (doc) ADD_SUBDIRECTORY (cmake) # CMake modules for Player libraries IF (PLAYER_OS_WIN) ADD_SUBDIRECTORY (replace) Modified: code/player/trunk/client_libs/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -1,6 +1,6 @@ MESSAGE (STATUS "===== Client Libraries =====") ADD_SUBDIRECTORY (libplayerc) -IF (NOT PLAYER_OS_WIN) +#IF (NOT PLAYER_OS_WIN) ADD_SUBDIRECTORY (libplayerc++) -ENDIF (NOT PLAYER_OS_WIN) +#ENDIF (NOT PLAYER_OS_WIN) MESSAGE (STATUS "============================") Modified: code/player/trunk/client_libs/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -202,6 +202,10 @@ wifiproxy.cc wsnproxy.cc) + IF (NOT HAVE_NANOSLEEP) + SET (playerccSrcs ${playerccSrcs} ${PROJECT_SOURCE_DIR}/replace/nanosleep.c) + ENDIF (NOT HAVE_NANOSLEEP) + PLAYER_ADD_LIBRARY (playerc++ ${playerccSrcs} ${playercppconfig_h}) TARGET_LINK_LIBRARIES (playerc++ playerxdr playerutils playerc ${PLAYERCC_EXTRA_LINK_LIBRARIES}) IF (PLAYER_OS_SOLARIS) Modified: code/player/trunk/client_libs/libplayerc++/aioproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/aioproxy.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/aioproxy.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -87,7 +87,7 @@ AioProxy::SetVoltage(uint32_t aIndex, double aVoltage) { scoped_lock_t lock(mPc->mMutex); - playerc_aio_set_output(mDevice, aIndex, aVoltage); + playerc_aio_set_output(mDevice, aIndex, static_cast<float> (aVoltage)); } std::ostream& Modified: code/player/trunk/client_libs/libplayerc++/blackboardproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/blackboardproxy.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/blackboardproxy.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -49,7 +49,7 @@ using namespace PlayerCc; // Constructor -BlackBoardProxy::BlackBoardProxy(PlayerClient *aPc, uint aIndex) : ClientProxy(aPc, aIndex), +BlackBoardProxy::BlackBoardProxy(PlayerClient *aPc, uint32_t aIndex) : ClientProxy(aPc, aIndex), mDevice(NULL) { Subscribe(aIndex); @@ -63,7 +63,7 @@ } // Subscribe -void BlackBoardProxy::Subscribe(uint aIndex) +void BlackBoardProxy::Subscribe(uint32_t aIndex) { scoped_lock_t lock(mPc->mMutex); mDevice = playerc_blackboard_create(mClient, aIndex); Modified: code/player/trunk/client_libs/libplayerc++/clientproxy.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/clientproxy.h 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/clientproxy.h 2009-02-18 03:43:36 UTC (rev 7342) @@ -48,6 +48,19 @@ #ifndef PLAYERCC_CLIENTPROXY_H #define PLAYERCC_CLIENTPROXY_H + +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERCC_EXPORT + #elif defined (playerc___EXPORTS) + #define PLAYERCC_EXPORT __declspec (dllexport) + #else + #define PLAYERCC_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERCC_EXPORT +#endif + namespace PlayerCc { @@ -63,7 +76,7 @@ * depending on Boost's presence in the system. See the @em configure script * for more information. */ -class ClientProxy +class PLAYERCC_EXPORT ClientProxy { friend class PlayerClient; Modified: code/player/trunk/client_libs/libplayerc++/playerc++.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/playerc++.h 2009-02-18 03:43:36 UTC (rev 7342) @@ -62,6 +62,18 @@ #include "libplayerc++/clientproxy.h" #include "libplayercore/interface_util.h" +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERCC_EXPORT + #elif defined (playerc___EXPORTS) + #define PLAYERCC_EXPORT __declspec (dllexport) + #else + #define PLAYERCC_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERCC_EXPORT +#endif + // Don't think we need to include these here /* #ifdef HAVE_BOOST_SIGNALS @@ -125,7 +137,7 @@ The @p ActArrayProxy class is used to control a @ref interface_actarray device. */ -class ActArrayProxy : public ClientProxy +class PLAYERCC_EXPORT ActArrayProxy : public ClientProxy { private: @@ -191,7 +203,7 @@ /** The @p AioProxy class is used to read from a @ref interface_aio (analog I/O) device. */ -class AioProxy : public ClientProxy +class PLAYERCC_EXPORT AioProxy : public ClientProxy { private: @@ -229,7 +241,7 @@ /** The @p AudioProxy class controls an @ref interface_audio device. */ -class AudioProxy : public ClientProxy +class PLAYERCC_EXPORT AudioProxy : public ClientProxy { private: @@ -330,10 +342,10 @@ * to that entries key. * If an entry does not exist, the default value of that entry is returned. */ -class BlackBoardProxy : public ClientProxy +class PLAYERCC_EXPORT BlackBoardProxy : public ClientProxy { private: - void Subscribe(uint aIndex); + void Subscribe(uint32_t aIndex); void Unsubscribe(); // libplayerc data structure @@ -341,7 +353,7 @@ public: /** Constructor */ - BlackBoardProxy(PlayerClient *aPc, uint aIndex=0); + BlackBoardProxy(PlayerClient *aPc, uint32_t aIndex=0); /** Destructor */ ~BlackBoardProxy(); /** Subscribe to a key. If the key does not exist the default value is returned. The user must free the entry. */ @@ -364,7 +376,7 @@ // The @p BlinkenlightProxy class is used to enable and disable // a flashing indicator light, and to set its period, via a @ref // interface_blinkenlight device */ -// class BlinkenLightProxy : public ClientProxy +// class PLAYERCC_EXPORT BlinkenLightProxy : public ClientProxy // { // private: // @@ -403,7 +415,7 @@ color blob data is stored in @p blobs, a dynamically allocated 2-D array, indexed by color channel. */ -class BlobfinderProxy : public ClientProxy +class PLAYERCC_EXPORT BlobfinderProxy : public ClientProxy { private: @@ -454,7 +466,7 @@ The @p BumperProxy class is used to read from a @ref interface_bumper device. */ -class BumperProxy : public ClientProxy +class PLAYERCC_EXPORT BumperProxy : public ClientProxy { private: @@ -494,14 +506,14 @@ /// For example, given a @p BumperProxy named @p bp, the following /// expressions are equivalent: @p bp.IsBumped[0] and @p bp[0]. bool operator [](uint32_t aIndex) const - { return IsBumped(aIndex); } + { return IsBumped(aIndex) != 0 ? true : false; } }; /** The @p CameraProxy class can be used to get images from a @ref interface_camera device. */ -class CameraProxy : public ClientProxy +class PLAYERCC_EXPORT CameraProxy : public ClientProxy { private: @@ -574,7 +586,7 @@ The @p DioProxy class is used to read from a @ref interface_dio (digital I/O) device. */ -class DioProxy : public ClientProxy +class PLAYERCC_EXPORT DioProxy : public ClientProxy { private: @@ -615,7 +627,7 @@ interface_fiducial devices. The latest set of detected beacons is stored in the @p beacons array. */ -class FiducialProxy : public ClientProxy +class PLAYERCC_EXPORT FiducialProxy : public ClientProxy { private: void Subscribe(uint32_t aIndex); @@ -663,7 +675,7 @@ /** The @p GpsProxy class is used to control a @ref interface_gps device. The latest pose data is stored in three class attributes. */ -class GpsProxy : public ClientProxy +class PLAYERCC_EXPORT GpsProxy : public ClientProxy { private: @@ -719,7 +731,7 @@ * so you can draw into the Stage window. This is very useful to * visualize what's going on in your controller. */ -class Graphics2dProxy : public ClientProxy +class PLAYERCC_EXPORT Graphics2dProxy : public ClientProxy { private: @@ -765,7 +777,7 @@ * rendering device provided by Player using the graphics3d * interface. */ -class Graphics3dProxy : public ClientProxy +class PLAYERCC_EXPORT Graphics3dProxy : public ClientProxy { private: @@ -802,7 +814,7 @@ The @p GripperProxy class is used to control a @ref interface_gripper device. The latest gripper data is held in a handful of class attributes. */ -class GripperProxy : public ClientProxy +class PLAYERCC_EXPORT GripperProxy : public ClientProxy { private: @@ -855,7 +867,7 @@ /** The @p HealthProxy class is used to get infos of the player-server. */ -class HealthProxy : public ClientProxy +class PLAYERCC_EXPORT HealthProxy : public ClientProxy { private: @@ -915,7 +927,7 @@ The @p ImuProxy class is used to control an @ref interface_imu device. */ -class ImuProxy : public ClientProxy +class PLAYERCC_EXPORT ImuProxy : public ClientProxy { private: void Subscribe(uint32_t aIndex); @@ -961,7 +973,7 @@ The @p IrProxy class is used to control an @ref interface_ir device. */ -class IrProxy : public ClientProxy +class PLAYERCC_EXPORT IrProxy : public ClientProxy { private: @@ -1010,7 +1022,7 @@ device. The latest scan data is held in two arrays: @p ranges and @p intensity. The laser scan range, resolution and so on can be configured using the Configure() method. */ -class LaserProxy : public ClientProxy +class PLAYERCC_EXPORT LaserProxy : public ClientProxy { private: @@ -1061,7 +1073,7 @@ double GetConfMaxAngle() const { return max_angle; }; /// Whether or not reflectance (i.e., intensity) values are being returned. - bool IntensityOn() const { return GetVar(mDevice->intensity_on); }; + bool IntensityOn() const { return GetVar(mDevice->intensity_on) != 0 ? true : false; }; // /// Scan data (polar): range (m) and bearing (radians) // double GetScan(uint32_t aIndex) const @@ -1183,7 +1195,7 @@ The @p LimbProxy class is used to control a @ref interface_limb device. */ -class LimbProxy : public ClientProxy +class PLAYERCC_EXPORT LimbProxy : public ClientProxy { private: @@ -1235,7 +1247,7 @@ device. The most recent joystick range measuremts can be read from the range attribute, or using the the [] operator. */ -class LinuxjoystickProxy : public ClientProxy +class PLAYERCC_EXPORT LinuxjoystickProxy : public ClientProxy { private: @@ -1285,7 +1297,7 @@ interface_localize device, which can provide multiple pose hypotheses for a robot. */ -class LocalizeProxy : public ClientProxy +class PLAYERCC_EXPORT LocalizeProxy : public ClientProxy { private: @@ -1356,7 +1368,7 @@ /** The @p LogProxy proxy provides access to a @ref interface_log device. */ -class LogProxy : public ClientProxy +class PLAYERCC_EXPORT LogProxy : public ClientProxy { private: @@ -1403,7 +1415,7 @@ /** The @p map proxy provides access to a @ref interface_map device. */ -class MapProxy : public ClientProxy +class PLAYERCC_EXPORT MapProxy : public ClientProxy { private: @@ -1458,7 +1470,7 @@ interface_opaque. See examples/plugins/opaquedriver for an example of using this interface in combination with a custom plugin. */ -class OpaqueProxy : public ClientProxy +class PLAYERCC_EXPORT OpaqueProxy : public ClientProxy { private: @@ -1498,7 +1510,7 @@ /** The @p PlannerProxy proxy provides an interface to a 2D motion @ref interface_planner. */ -class PlannerProxy : public ClientProxy +class PLAYERCC_EXPORT PlannerProxy : public ClientProxy { private: @@ -1640,7 +1652,7 @@ /** The Pointcloud3d proxy provides an interface to a pointcloud3d device. */ -class Pointcloud3dProxy : public ClientProxy +class PLAYERCC_EXPORT Pointcloud3dProxy : public ClientProxy { private: @@ -1675,7 +1687,7 @@ The @p Position1dProxy class is used to control a @ref interface_position1d device. The latest position data is contained in the attributes pos, vel , etc. */ -class Position1dProxy : public ClientProxy +class PLAYERCC_EXPORT Position1dProxy : public ClientProxy { private: @@ -1758,7 +1770,7 @@ double GetVel() const { return GetVar(mDevice->vel); }; /// Accessor method - bool GetStall() const { return GetVar(mDevice->stall); }; + bool GetStall() const { return GetVar(mDevice->stall) != 0 ? true : false; }; /// Accessor method uint8_t GetStatus() const { return GetVar(mDevice->status); }; @@ -1799,7 +1811,7 @@ The @p Position2dProxy class is used to control a @ref interface_position2d device. The latest position data is contained in the attributes xpos, ypos, etc. */ -class Position2dProxy : public ClientProxy +class PLAYERCC_EXPORT Position2dProxy : public ClientProxy { private: @@ -1838,12 +1850,12 @@ /// Same as the previous GoTo(), but doesn't take speed void GoTo(player_pose2d_t pos) - {GoTo(pos,(player_pose2d_t) {0,0,0}); } + { player_pose2d_t vel = {0,0,0}; GoTo(pos, vel); } /// Same as the previous GoTo(), but only takes position arguments, /// no motion speed setting void GoTo(double aX, double aY, double aYaw) - {GoTo((player_pose2d_t) {aX,aY,aYaw},(player_pose2d_t) {0,0,0}); } + { player_pose2d_t pos = {aX,aY,aYaw}; player_pose2d_t vel = {0,0,0}; GoTo(pos, vel); } /// Sets command for carlike robot void SetCarlike(double aXSpeed, double aDriveAngle); @@ -1945,7 +1957,7 @@ double GetYawSpeed() const { return GetVar(mDevice->va); }; /// Accessor method - bool GetStall() const { return GetVar(mDevice->stall); }; + bool GetStall() const { return GetVar(mDevice->stall) != 0 ? true : false; }; }; @@ -1955,7 +1967,7 @@ a interface_position3d device. The latest position data is contained in the attributes xpos, ypos, etc. */ -class Position3dProxy : public ClientProxy +class PLAYERCC_EXPORT Position3dProxy : public ClientProxy { private: @@ -2006,15 +2018,16 @@ /// Same as the previous GoTo(), but does'n take vel argument void GoTo(player_pose3d_t aPos) - { GoTo(aPos, (player_pose3d_t) {0,0,0,0,0,0}); } + { player_pose3d_t vel = {0,0,0,0,0,0}; GoTo(aPos, vel); } /// Same as the previous GoTo(), but only takes position arguments, /// no motion speed setting void GoTo(double aX, double aY, double aZ, double aRoll, double aPitch, double aYaw) - { GoTo((player_pose3d_t) {aX,aY,aZ,aRoll,aPitch,aYaw}, - (player_pose3d_t) {0,0,0,0,0,0}); + { player_pose3d_t pos = {aX,aY,aZ,aRoll,aPitch,aYaw}; + player_pose3d_t vel = {0,0,0,0,0,0}; + GoTo(pos, vel); } /// Enable/disable the motors. @@ -2091,11 +2104,11 @@ double GetYawSpeed() const { return GetVar(mDevice->vel_yaw); }; /// Accessor method - bool GetStall () const { return GetVar(mDevice->stall); }; + bool GetStall () const { return GetVar(mDevice->stall) != 0 ? true : false; }; }; /** The @p PowerProxy class controls a @ref interface_power device. */ -class PowerProxy : public ClientProxy +class PLAYERCC_EXPORT PowerProxy : public ClientProxy { private: @@ -2124,10 +2137,10 @@ double GetWatts() const {return GetVar(mDevice->watts); }; /// Returns whether charging is taking place - bool GetCharging() const {return GetVar(mDevice->charging);}; + bool GetCharging() const {return GetVar(mDevice->charging) != 0 ? true : false;}; // Return whether the power data is valid - bool IsValid() const {return GetVar(mDevice->valid);}; + bool IsValid() const {return GetVar(mDevice->valid) != 0 ? true : false;}; }; /** @@ -2136,7 +2149,7 @@ device. The state of the camera can be read from the pan, tilt, zoom attributes and changed using the SetCam() method. */ -class PtzProxy : public ClientProxy +class PLAYERCC_EXPORT PtzProxy : public ClientProxy { private: @@ -2182,7 +2195,7 @@ /** The @p RangerProxy class is used to control a @ref interface_ranger device. */ -class RangerProxy : public ClientProxy +class PLAYERCC_EXPORT RangerProxy : public ClientProxy { private: @@ -2270,7 +2283,7 @@ /** The @p RFIDProxy class is used to control a @ref interface_rfid device. */ -class RFIDProxy : public ClientProxy +class PLAYERCC_EXPORT RFIDProxy : public ClientProxy { private: @@ -2305,7 +2318,7 @@ The @p SimulationProxy proxy provides access to a @ref interface_simulation device. */ -class SimulationProxy : public ClientProxy +class PLAYERCC_EXPORT SimulationProxy : public ClientProxy { private: @@ -2352,7 +2365,7 @@ device. The most recent sonar range measuremts can be read from the range attribute, or using the the [] operator. */ -class SonarProxy : public ClientProxy +class PLAYERCC_EXPORT SonarProxy : public ClientProxy { private: @@ -2400,7 +2413,7 @@ The @p SpeechProxy class is used to control a @ref interface_speech device. Use the say method to send things to say. */ -class SpeechProxy : public ClientProxy +class PLAYERCC_EXPORT SpeechProxy : public ClientProxy { private: @@ -2425,7 +2438,7 @@ /** The @p SpeechRecognition proxy provides access to a @ref interface_speech_recognition device. */ -class SpeechRecognitionProxy : public ClientProxy +class PLAYERCC_EXPORT SpeechRecognitionProxy : public ClientProxy { void Subscribe(uint32_t aIndex); void Unsubscribe(); @@ -2453,7 +2466,7 @@ /** * The @p VectorMapProxy class is used to interface to a vectormap. */ -class VectorMapProxy : public ClientProxy +class PLAYERCC_EXPORT VectorMapProxy : public ClientProxy { private: @@ -2484,7 +2497,7 @@ /** The @p WiFiProxy class controls a @ref interface_wifi device. */ -class WiFiProxy: public ClientProxy +class PLAYERCC_EXPORT WiFiProxy: public ClientProxy { private: @@ -2552,7 +2565,7 @@ /** The @p WSNProxy class is used to control a @ref interface_wsn device. */ -class WSNProxy : public ClientProxy +class PLAYERCC_EXPORT WSNProxy : public ClientProxy { private: @@ -2587,52 +2600,52 @@ namespace std { - std::ostream& operator << (std::ostream& os, const player_point_2d_t& c); - std::ostream& operator << (std::ostream& os, const player_pose2d_t& c); - std::ostream& operator << (std::ostream& os, const player_pose3d_t& c); - std::ostream& operator << (std::ostream& os, const player_bbox2d_t& c); - std::ostream& operator << (std::ostream& os, const player_bbox3d_t& c); - std::ostream& operator << (std::ostream& os, const player_segment_t& c); - std::ostream& operator << (std::ostream& os, const player_extent2d_t& c); - std::ostream& operator << (std::ostream& os, const playerc_device_info_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_point_2d_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_pose2d_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_pose3d_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_bbox2d_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_bbox3d_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_segment_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const player_extent2d_t& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const playerc_device_info_t& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::ClientProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::ActArrayProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::AioProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::AudioProxy& a); - //std::ostream& operator << (std::ostream& os, const PlayerCc::BlinkenLightProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::BlobfinderProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::BumperProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::CameraProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::DioProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::FiducialProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::GpsProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::GripperProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::ImuProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::IrProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::LaserProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::LimbProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::LinuxjoystickProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::LocalizeProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::LogProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::MapProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::OpaqueProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::PlannerProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::Position1dProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::Position2dProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::Position3dProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::PowerProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::PtzProxy& c); - std::ostream& operator << (std::ostream &os, const PlayerCc::RangerProxy &c); - std::ostream& operator << (std::ostream& os, const PlayerCc::SimulationProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::SonarProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechRecognitionProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::VectorMapProxy& c); - //std::ostream& operator << (std::ostream& os, const PlayerCc::WafeformProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::WiFiProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::RFIDProxy& c); - std::ostream& operator << (std::ostream& os, const PlayerCc::WSNProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::ClientProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::ActArrayProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::AioProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::AudioProxy& a); + //PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::BlinkenLightProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::BlobfinderProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::BumperProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::CameraProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::DioProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::FiducialProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::GpsProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::GripperProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::ImuProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::IrProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::LaserProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::LimbProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::LinuxjoystickProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::LocalizeProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::LogProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::MapProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::OpaqueProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::PlannerProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::Position1dProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::Position2dProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::Position3dProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::PowerProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::PtzProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream &os, const PlayerCc::RangerProxy &c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::SimulationProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::SonarProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::SpeechRecognitionProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::VectorMapProxy& c); + //PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::WafeformProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::WiFiProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::RFIDProxy& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::WSNProxy& c); } #endif Modified: code/player/trunk/client_libs/libplayerc++/playerclient.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerclient.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/playerclient.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -56,6 +56,8 @@ #include "debug.h" +#include <replace.h> + using namespace PlayerCc; PlayerClient::PlayerClient(const std::string aHostname, uint32_t aPort, @@ -212,7 +214,7 @@ int ret = playerc_client_peek(mClient, aTimeout); if (ret < 0) throw PlayerError("PlayerClient::Peek()", playerc_error_str()); - return ret; + return ret != 0 ? true : false; } Modified: code/player/trunk/client_libs/libplayerc++/playerclient.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playerclient.h 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/playerclient.h 2009-02-18 03:43:36 UTC (rev 7342) @@ -50,6 +50,18 @@ #include <string> #include <list> +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERCC_EXPORT + #elif defined (playerc___EXPORTS) + #define PLAYERCC_EXPORT __declspec (dllexport) + #else + #define PLAYERCC_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERCC_EXPORT +#endif + #ifdef HAVE_BOOST_SIGNALS #include <boost/signal.hpp> #endif @@ -65,13 +77,13 @@ // in all the proxies namespace boost { - class thread + class PLAYERCC_EXPORT thread { public: thread() {}; }; - class mutex + class PLAYERCC_EXPORT mutex { public: mutex() {}; @@ -100,7 +112,7 @@ * library being present on the system. The StartThread() and StopThread() are * the only functions conditionally available based on this. */ -class PlayerClient +class PLAYERCC_EXPORT PlayerClient { friend class ClientProxy; @@ -292,7 +304,7 @@ namespace std { - std::ostream& operator << (std::ostream& os, const PlayerCc::PlayerClient& c); + PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::PlayerClient& c); } #endif Modified: code/player/trunk/client_libs/libplayerc++/playererror.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/playererror.h 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/playererror.h 2009-02-18 03:43:36 UTC (rev 7342) @@ -43,6 +43,18 @@ #include <string> #include <iostream> +#if defined (WIN32) + #if defined (PLAYER_STATIC) + #define PLAYERCC_EXPORT + #elif defined (playerc___EXPORTS) + #define PLAYERCC_EXPORT __declspec (dllexport) + #else + #define PLAYERCC_EXPORT __declspec (dllimport) + #endif +#else + #define PLAYERCC_EXPORT +#endif + namespace PlayerCc { @@ -51,7 +63,7 @@ * When @em libplayerc++ receives an error from @em libplayerc * it throws a PlayerError exception. */ -class PlayerError +class PLAYERCC_EXPORT PlayerError { private: @@ -82,7 +94,7 @@ namespace std { -std::ostream& operator << (std::ostream& os, const PlayerCc::PlayerError& e); +PLAYERCC_EXPORT std::ostream& operator << (std::ostream& os, const PlayerCc::PlayerError& e); } #endif Modified: code/player/trunk/client_libs/libplayerc++/rfidproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/rfidproxy.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/rfidproxy.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -48,6 +48,10 @@ #include <cmath> #include <climits> +#if defined (WIN32) + #define snprintf _snprintf +#endif + using namespace PlayerCc; RFIDProxy::RFIDProxy(PlayerClient *aPc, uint32_t aIndex) Modified: code/player/trunk/client_libs/libplayerc++/speechproxy.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/speechproxy.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/speechproxy.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -45,6 +45,10 @@ #include <cstring> #include "playerc++.h" +#if defined (WIN32) + #define strdup _strdup +#endif + using namespace PlayerCc; SpeechProxy::SpeechProxy(PlayerClient *aPc, uint32_t aIndex) Modified: code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -3,6 +3,11 @@ OPTION (BUILD_CC_TESTS "Build the C++ client library tests" ON) IF (BUILD_CC_TESTS) + # Possibly use our own copy of XDR, and need gettimeofday replacement + IF (NOT HAVE_XDR OR NOT HAVE_GETTIMEOFDAY) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + ENDIF (NOT HAVE_XDR OR NOT HAVE_GETTIMEOFDAY) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${PROJECT_BINARY_DIR}/client_libs) SET (testsSrcs test.cc test.h @@ -24,6 +29,13 @@ test_speech.cc test_ranger.cc) + IF (NOT HAVE_USLEEP) + SET (testsSrcs ${testsSrcs} ${PROJECT_SOURCE_DIR}/replace/usleep.c) + ENDIF (NOT HAVE_USLEEP) + IF (NOT HAVE_ROUND) + SET (testsSrcs ${testsSrcs} ${PROJECT_SOURCE_DIR}/replace/round.c) + ENDIF (NOT HAVE_ROUND) + ADD_DEFINITIONS (${PLAYERCC_DEFINITIONS}) ADD_EXECUTABLE (playerc++_test ${testsSrcs}) TARGET_LINK_LIBRARIES (playerc++_test playerc playerc++ playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} ${PLAYERCC_EXTRA_LINK_LIBRARIES}) Modified: code/player/trunk/client_libs/libplayerc++/test/test.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -6,13 +6,19 @@ **************************************************************************/ #include <cstring> -#include <unistd.h> #include <cstring> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <config.h> #include "test.h" +#if defined (WIN32) + #define strdup _strdup +#endif + bool use_stage; int main(int argc, const char *argv[]) Modified: code/player/trunk/client_libs/libplayerc++/test/test_actarray.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_actarray.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_actarray.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif using namespace PlayerCc; @@ -86,7 +88,7 @@ PASS(); TEST("moving #0 at speed -0.3, then setting speed to 0"); - aap.MoveAtSpeed(0, -0.3); + aap.MoveAtSpeed(0, -0.3f); for(int i = 0; i < wait_iters; ++i) { client->Read(); Modified: code/player/trunk/client_libs/libplayerc++/test/test_aio.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_aio.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_aio.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif using namespace PlayerCc; Modified: code/player/trunk/client_libs/libplayerc++/test/test_bumper.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_bumper.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_bumper.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif int test_bumper(PlayerClient* client, int index) Modified: code/player/trunk/client_libs/libplayerc++/test/test_dio.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_dio.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_dio.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,8 +5,12 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif +#include <replace.h> + using namespace PlayerCc; int Modified: code/player/trunk/client_libs/libplayerc++/test/test_gripper.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_gripper.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_gripper.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,8 +5,12 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif +#include <replace.h> + using namespace PlayerCc; int @@ -30,27 +34,27 @@ TEST("gripper open"); gp.Open(); - sleep(5); + usleep(5000000); PASS(); TEST("gripper close"); gp.Close(); - sleep(8); + usleep(8000000); PASS(); TEST("gripper open"); gp.Open(); - sleep(5); + usleep(5000000); PASS(); TEST("gripper store object (only on some grippers, e.g. stage)"); gp.Store(); - sleep(3); + usleep(3000000); PASS(); TEST("gripper retrieve object (only on some grippers, e.g. stage"); gp.Retrieve(); - sleep(3); + usleep(3000000); PASS(); PASS(); Modified: code/player/trunk/client_libs/libplayerc++/test/test_gripper_holdsub.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_gripper_holdsub.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_gripper_holdsub.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif using namespace PlayerCc; Modified: code/player/trunk/client_libs/libplayerc++/test/test_laser.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_laser.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_laser.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,11 +5,15 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <math.h> +#if defined (WIN32) + #include <replace.h> +#endif - int test_laser(PlayerClient* client, int index) { @@ -33,14 +37,24 @@ lp.RequestConfigure(); TEST("check configuration sanity"); +#if defined (WIN32) + if((((int)round(RTOD(lp.GetMinAngle()))) != min) || + (((int)round(RTOD(lp.GetMaxAngle()))) != max)) +#else if((((int)rint(RTOD(lp.GetMinAngle()))) != min) || (((int)rint(RTOD(lp.GetMaxAngle()))) != max)) +#endif { FAIL(); return(-1); } +#if defined (WIN32) + else if((((int)round(RTOD(lp.GetScanRes())*100.0)) != resolution) || + (lp.GetRangeRes() != range_res)) +#else else if((((int)rint(RTOD(lp.GetScanRes())*100.0)) != resolution) || (lp.GetRangeRes() != range_res)) +#endif { FAIL(); return(-1); Modified: code/player/trunk/client_libs/libplayerc++/test/test_position2d.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_position2d.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_position2d.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,9 +5,13 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <math.h> +#include <replace.h> + using namespace PlayerCc; int @@ -55,7 +59,11 @@ if((p2d.GetXPos() != ox) || (p2d.GetYPos() != oy) || +#if defined (WIN32) + ((int)round(RTOD(p2d.GetYaw())) != oa)) +#else ((int)rint(RTOD(p2d.GetYaw())) != oa)) +#endif { FAIL(); //return(-1); @@ -67,7 +75,7 @@ TEST("resetting odometry"); p2d.ResetOdometry(); - sleep(1); + usleep(1000000); PASS(); TEST("enabling motors"); @@ -76,54 +84,54 @@ TEST("moving forward"); p2d.SetSpeed(0.1,0); - sleep(3); + usleep(3000000); PASS(); TEST("moving backward"); p2d.SetSpeed(-0.1,0); - sleep(3); + usleep(3000000); PASS(); TEST("moving left"); p2d.SetSpeed(0,0.1,0); - sleep(3); + usleep(3000000); PASS(); TEST("moving right"); p2d.SetSpeed(0,-0.1,0); - sleep(3); + usleep(3000000); PASS(); TEST("turning right"); p2d.SetSpeed(0,DTOR(-25.0)); - sleep(3); + usleep(3000000); PASS(); TEST("turning left"); p2d.SetSpeed(0,DTOR(25.0)); - sleep(3); + usleep(3000000); PASS(); TEST("moving left and anticlockwise (testing omnidrive)"); p2d.SetSpeed( 0, 0.1, DTOR(45.0) ); - sleep(3); + usleep(3000000); PASS(); TEST("moving right and clockwise (testing omnidrive)"); p2d.SetSpeed( 0, -0.1, DTOR(-45) ); - sleep(3); + usleep(3000000); PASS(); TEST("stopping"); p2d.SetSpeed(0,0); - sleep(3); + usleep(3000000); PASS(); TEST("disabling motors"); p2d.SetMotorEnable(0); - sleep(1); + usleep(1000000); PASS(); /* @@ -140,7 +148,7 @@ TEST("resetting odometry"); p2d.ResetOdometry(); - sleep(1); + usleep(1000000); PASS(); Modified: code/player/trunk/client_libs/libplayerc++/test/test_position2d_holdsub.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_position2d_holdsub.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_position2d_holdsub.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <math.h> using namespace PlayerCc; Modified: code/player/trunk/client_libs/libplayerc++/test/test_power.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_power.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_power.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif int test_power(PlayerClient* client, int index) Modified: code/player/trunk/client_libs/libplayerc++/test/test_ptz.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_ptz.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_ptz.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,8 +5,12 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif +#include <replace.h> + using namespace PlayerCc; int @@ -28,32 +32,32 @@ TEST("panning left"); zp.SetCam(DTOR(90),0,0); - sleep(3); + usleep(3000000); PASS(); TEST("panning right"); zp.SetCam(DTOR(-90),0,0); - sleep(3); + usleep(3000000); PASS(); TEST("tilting up"); zp.SetCam(0,DTOR(25),0); - sleep(3); + usleep(3000000); PASS(); TEST("tilting down"); zp.SetCam(0,DTOR(-25),0); - sleep(3); + usleep(3000000); PASS(); TEST("zooming in"); zp.SetCam(0,0,DTOR(10)); - sleep(3); + usleep(3000000); PASS(); TEST("zooming out"); zp.SetCam(0,0,DTOR(60)); - sleep(3); + usleep(3000000); PASS(); Modified: code/player/trunk/client_libs/libplayerc++/test/test_ranger.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_ranger.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_ranger.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -1,5 +1,7 @@ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif int test_ranger(PlayerClient* client, int index) Modified: code/player/trunk/client_libs/libplayerc++/test/test_sonar.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_sonar.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_sonar.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -5,7 +5,9 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif int test_sonar(PlayerClient* client, int index) Modified: code/player/trunk/client_libs/libplayerc++/test/test_speech.cc =================================================================== --- code/player/trunk/client_libs/libplayerc++/test/test_speech.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/test/test_speech.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -3,9 +3,13 @@ */ #include "test.h" -#include <unistd.h> +#if !defined (WIN32) + #include <unistd.h> +#endif #include <string> +#include <replace.h> + using namespace std; using namespace PlayerCc; Modified: code/player/trunk/client_libs/libplayerc++/utility.h =================================================================== --- code/player/trunk/client_libs/libplayerc++/utility.h 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/client_libs/libplayerc++/utility.h 2009-02-18 03:43:36 UTC (rev 7342) @@ -84,6 +84,9 @@ } /// Return the minimum of a, b +#if defined (min) + #undef min +#endif template<typename T> inline T min(T a, T b) { @@ -94,6 +97,9 @@ } /// Return the maximum of a, b +#if defined (max) + #undef max +#endif template<typename T> inline T max(T a, T b) { Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-18 03:43:36 UTC (rev 7342) @@ -49,6 +49,7 @@ CHECK_FUNCTION_EXISTS (usleep HAVE_USLEEP) CHECK_FUNCTION_EXISTS (cfmakeraw HAVE_CFMAKERAW) CHECK_FUNCTION_EXISTS (dirname HAVE_DIRNAME) +CHECK_FUNCTION_EXISTS (getopt HAVE_GETOPT) CHECK_INCLUDE_FILES (linux/joystick.h HAVE_LINUX_JOYSTICK_H) CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H) CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H) Modified: code/player/trunk/config.h.in =================================================================== --- code/player/trunk/config.h.in 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/config.h.in 2009-02-18 03:43:36 UTC (rev 7342) @@ -23,3 +23,5 @@ #cmakedefine HAVE_UNISTD_H 1 #cmakedefine HAVE_IEEEFP_H 1 #cmakedefine WORDS_BIGENDIAN 1 +#cmakedefine HAVE_GETOPT 1 + Added: code/player/trunk/replace/getopt.c =================================================================== --- code/player/trunk/replace/getopt.c (rev 0) +++ code/player/trunk/replace/getopt.c 2009-02-18 03:43:36 UTC (rev 7342) @@ -0,0 +1,89 @@ +// NOTE: This does not implement the '+' and '-' modes required by POSIX, the +// two-colons GNU extension nor the -W GNU extension. + +#include <stdio.h> +#include <string.h> + +char *optarg = NULL; +int optind = 1, opterr = 1, optopt = 0; + +int getopt (int argc, char * const argv[], const char *optstring) +{ + char c, *cptr = NULL; + int index = 1; + + // Filter out: exhausted args list, NULL args (shouldn't happen?), args not + // beginning with -, and args that are just - + if (optind >= argc || argv[optind][0] == '\0' || argv[optind][0] != '-' || + (argv[optind][0] == '-' && argv[optind][1] == '\0')) + { + return -1; + } + + // -- marks the end of the command line arguments list + if (strncmp (argv[optind], "--", strlen (argv[optind])) == 0) + { + optind++; + return -1; + } + + // Get the option character + optopt = c = argv[optind][index]; + // Check if it's a legal option + if ((cptr = strchr (optstring, c)) == NULL) + { + if (opterr != 0) + fprintf (stderr, "%s: Illegal option: %c", argv[0], c); + // Check if this argument string has been exhausted, if so reset to beginning of the next one + if (argv[optind][index] == '\0') + { + optind++; + index = 1; + } + else + index++; + return '?'; + } + + // Does this option require an argument? + if (*(cptr + 1) == ':') + { + // The argument might be the remainder of this argv string or the whole of the next one + if (argv[optind][index + 1] != '\0') + { + optarg = &(argv[optind][index + 1]); + optind++; + index = 1; + } + else if (optind + 1 < argc) + { + optarg = argv[optind + 1]; + optind += 2; + index = 1; + } + else + { + if (optstring[0] == ':') + { + if (opterr != 0) + fprintf (stderr, "%s: Missing argument for option %c", argv[0], c); + return ':'; + } + else + return '?'; + } + } + else + { + // Check if this argument string has been exhausted, if so reset to beginning of the next one + if (argv[optind][index] == '\0') + { + optind++; + index = 1; + } + else + index++; + } + + return c; +} Modified: code/player/trunk/replace/replace.h =================================================================== --- code/player/trunk/replace/replace.h 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/replace/replace.h 2009-02-18 03:43:36 UTC (rev 7342) @@ -137,6 +137,12 @@ int gettimeofday (struct timeval *tv, void *tzp); #endif +#if !HAVE_GETOPT + int getopt (int argc, char * const argv[], const char *optstring); + extern char *optarg; + extern int optind, opterr, optopt; +#endif + #ifdef __cplusplus } #endif Modified: code/player/trunk/server/CMakeLists.txt =================================================================== --- code/player/trunk/server/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/server/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -13,6 +13,7 @@ # Build the server app # Extra include dir for the server (why do we need this directoy?) INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}/drivers/shell) + IF (PLAYER_OS_WIN) INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) ENDIF (PLAYER_OS_WIN) @@ -22,11 +23,15 @@ IF (NOT PTHREAD_LIB_DIR STREQUAL "") LINK_DIRECTORIES (${PTHREAD_LIB_DIR}) ENDIF (NOT PTHREAD_LIB_DIR STREQUAL "") +IF (NOT HAVE_GETOPT) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + SET (getoptSrc ${PROJECT_SOURCE_DIR}/replace/getopt.c) +ENDIF (NOT HAVE_GETOPT) # Source files SET (playerSrcs server.cc) # Server executable -ADD_EXECUTABLE (player ${playerSrcs}) +ADD_EXECUTABLE (player ${playerSrcs} ${getoptSrc}) TARGET_LINK_LIBRARIES (player playerdrivers playercore playererror playerutils playertcp playerudp playerxdr ${PLAYER_EXTRA_LINK_LIBRARIES}) IF (INCLUDE_RTKGUI) TARGET_LINK_LIBRARIES (player rtk) Modified: code/player/trunk/server/server.cc =================================================================== --- code/player/trunk/server/server.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/server/server.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -108,6 +108,9 @@ #include <libplayersd/playersd.h> #endif +#if !HAVE_GETOPT + #include <replace.h> +#endif void PrintVersion(); void PrintCopyrightMsg(); @@ -417,13 +420,6 @@ ParseArgs(int* port, int* debuglevel, char** cfgfilename, int* gz_serverid, char **logfilename, int argc, char** argv) { -#if defined (WIN32) - // TODO: write some option parsing code or put a getopt implementation in replace. - if (argc > 1) - *cfgfilename = argv[1]; - else - return -1; -#else int ch; const char* optflags = "d:p:hq"; @@ -456,7 +452,6 @@ return(-1); *cfgfilename = argv[optind]; -#endif return(0); } Modified: code/player/trunk/utils/logsplitter/logsplitter.c =================================================================== --- code/player/trunk/utils/logsplitter/logsplitter.c 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/utils/logsplitter/logsplitter.c 2009-02-18 03:43:36 UTC (rev 7342) @@ -27,13 +27,20 @@ */ #include <stdio.h> #include <string.h> -#include <unistd.h> #include <sys/types.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <sys/stat.h> +#if !defined (WIN32) + #include <unistd.h> +#endif +#if defined (WIN32) + #define snprintf _snprintf + #define fileno _fileno +#endif + // Splits a logfile and returns the new file handle FILE *copySplitData (FILE *input, double t2, long before) @@ -116,7 +123,11 @@ fflush (rest); // Truncate the remainings from the source file - ftruncate (fileno (input), currentPos - before); +#if defined (WIN32) + _chsize_s (_fileno (input), currentPos - before); +#else + ftruncate (fileno (input), currentPos - before); +#endif fclose (input); return rest; @@ -152,7 +163,7 @@ } // Get the minimum time difference between two consecutive timestamps - min_timedifference = atof (argv[1]); + min_timedifference = (float) atof (argv[1]); base_filename = argv[2]; printf ("I: Minimum time difference is: %f seconds.\n", min_timedifference); @@ -228,8 +239,10 @@ if ((fabs (t2 - t1) > min_timedifference) && (after - before > 0)) { time_t t = (time_t)t1; -#if defined (__SVR4) && defined (__sun) +#if defined (__SVR4) && defined (sun) ctime_r (&t, btime, sizeof (btime)); +#elif defined (WIN32) + ctime_s (btime, sizeof (btime), &t); #else ctime_r (&t, btime); #endif Modified: code/player/trunk/utils/playerjoy/CMakeLists.txt =================================================================== --- code/player/trunk/utils/playerjoy/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/utils/playerjoy/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -1,11 +1,15 @@ OPTION (BUILD_UTILS_PLAYERJOY "Build the playerjoy utility" ON) IF (BUILD_UTILS_PLAYERJOY) - IF (BUILD_PLAYERCC) - INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${PROJECT_BINARY_DIR}/client_libs) + IF (PLAYER_OS_WIN) + MESSAGE (STATUS "playerjoy will not be built - termios and joystick are not supported under Windows") + ELSE (PLAYER_OS_WIN) + IF (BUILD_PLAYERCC) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${PROJECT_BINARY_DIR}/client_libs) - PLAYER_ADD_EXECUTABLE (playerjoy playerjoy.cc) - TARGET_LINK_LIBRARIES (playerjoy playerc++ playerc playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} ${PLAYERCC_EXTRA_LINK_LIBRARIES} pthread) - ELSE (BUILD_PLAYERCC) - MESSAGE (STATUS "playerjoy will not be built - playerc++ client library is disabled") - ENDIF (BUILD_PLAYERCC) + PLAYER_ADD_EXECUTABLE (playerjoy playerjoy.cc) + TARGET_LINK_LIBRARIES (playerjoy playerc++ playerc playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} ${PLAYERCC_EXTRA_LINK_LIBRARIES} pthread) + ELSE (BUILD_PLAYERCC) + MESSAGE (STATUS "playerjoy will not be built - playerc++ client library is disabled") + ENDIF (BUILD_PLAYERCC) + ENDIF (PLAYER_OS_WIN) ENDIF (BUILD_UTILS_PLAYERJOY) Modified: code/player/trunk/utils/playerprint/CMakeLists.txt =================================================================== --- code/player/trunk/utils/playerprint/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/utils/playerprint/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -1,10 +1,27 @@ OPTION (BUILD_UTILS_PLAYERPRINT "Build the playerprint utility" ON) IF (BUILD_UTILS_PLAYERPRINT) IF (BUILD_PLAYERCC) + # Possibly use our own copy of XDR or getopt + IF (NOT HAVE_XDR) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + ENDIF (NOT HAVE_XDR) + IF (NOT HAVE_GETOPT) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + SET (getoptSrc ${PROJECT_SOURCE_DIR}/replace/getopt.c) + ENDIF (NOT HAVE_GETOPT) + IF (NOT HAVE_USLEEP) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + SET (usleepSrc ${PROJECT_SOURCE_DIR}/replace/usleep.c) + ENDIF (NOT HAVE_USLEEP) + IF (NOT HAVE_GETTIMEOFDAY) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/replace) + SET (gettimeofdaySrc ${PROJECT_SOURCE_DIR}/replace/gettimeofday.c) + ENDIF (NOT HAVE_GETTIMEOFDAY) + INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/client_libs ${PROJECT_BINARY_DIR}/client_libs) ADD_DEFINITIONS (${PLAYERCC_DEFINITIONS}) - PLAYER_ADD_EXECUTABLE (playerprint playerprint.cc) + PLAYER_ADD_EXECUTABLE (playerprint playerprint.cc ${getoptSrc} ${usleepSrc} ${gettimeofdaySrc}) TARGET_LINK_LIBRARIES (playerprint playerc++ playerc playerxdr playererror ${PLAYERC_EXTRA_LINK_LIBRARIES} ${PLAYERCC_EXTRA_LINK_LIBRARIES}) ELSE (BUILD_PLAYERCC) MESSAGE (STATUS "playerprint will not be built - playerc++ client library is disabled") Modified: code/player/trunk/utils/playerprint/playerprint.cc =================================================================== --- code/player/trunk/utils/playerprint/playerprint.cc 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/utils/playerprint/playerprint.cc 2009-02-18 03:43:36 UTC (rev 7342) @@ -77,12 +77,19 @@ #include <stdio.h> #include <iostream> -#include <unistd.h> #include <stdlib.h> // for atoi(3) //#include <libplayerc/playerc.h> // for libplayerc client stuff #include <libplayerc++/playerc++.h> // for libplayerc++ client stuff -#include <sys/time.h> +#if !defined (WIN32) + #include <unistd.h> + #include <sys/time.h> +#endif +#include <config.h> +#if !defined (HAVE_GETOPT) + #include <replace.h> +#endif + #include <assert.h> #define USAGE \ Modified: code/player/trunk/utils/playerprop/CMakeLists.txt =================================================================== --- code/player/trunk/utils/playerprop/CMakeLists.txt 2009-02-18 00:09:26 UTC (rev 7341) +++ code/player/trunk/utils/playerprop/CMakeLists.txt 2009-02-18 03:43:36 UTC (rev 7342) @@ -1,9 +1,16 @@ OPTION (BUILD_UTILS_PLAYERPROP "Build the playerprop utility" ON) IF (BUI... [truncated message content] |
From: <gb...@us...> - 2009-02-19 03:07:09
|
Revision: 7344 http://playerstage.svn.sourceforge.net/playerstage/?rev=7344&view=rev Author: gbiggs Date: 2009-02-19 01:39:57 +0000 (Thu, 19 Feb 2009) Log Message: ----------- Removed requirement for pkg-config from installed cmake modules to make them usable on systems without pkg-config. Modified Paths: -------------- code/player/trunk/client_libs/CMakeLists.txt code/player/trunk/client_libs/libplayerc++/CMakeLists.txt code/player/trunk/cmake/CMakeLists.txt code/player/trunk/cmake/UsePlayerC.cmake.in code/player/trunk/cmake/internal/SearchForStuff.cmake code/player/trunk/libplayercore/CMakeLists.txt code/player/trunk/win32_todo.txt Added Paths: ----------- code/player/trunk/cmake/UsePlayerC++.cmake.in code/player/trunk/cmake/UsePlayerPlugin.cmake.in Removed Paths: ------------- code/player/trunk/cmake/UsePlayerC++.cmake code/player/trunk/cmake/UsePlayerC.cmake code/player/trunk/cmake/UsePlayerPlugin.cmake Modified: code/player/trunk/client_libs/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/CMakeLists.txt 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/client_libs/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) @@ -1,6 +1,4 @@ MESSAGE (STATUS "===== Client Libraries =====") ADD_SUBDIRECTORY (libplayerc) -#IF (NOT PLAYER_OS_WIN) - ADD_SUBDIRECTORY (libplayerc++) -#ENDIF (NOT PLAYER_OS_WIN) +ADD_SUBDIRECTORY (libplayerc++) MESSAGE (STATUS "============================") Modified: code/player/trunk/client_libs/libplayerc++/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/client_libs/libplayerc++/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) @@ -215,10 +215,23 @@ SET (pkgconfigLibFlags) ENDIF (PLAYER_OS_SOLARIS) + IF (Boost_LIBRARY_DIRS) + SET (pkgconfigLibFlags "${pkgconfigLibFlags} -L${Boost_LIBRARY_DIRS}") + ENDIF (Boost_LIBRARY_DIRS) + IF (bostIncludeDir) + SET (pkgconfigIncFlags "-I${boostIncludeDir}") + ENDIF (bostIncludeDir) + IF (boostThreadLib) + SET (pkgconfigLibFlags "${pkgconfigLibFlags} -l${boostThreadLib}") + ENDIF (boostThreadLib) + IF (boostSignalsLib) + SET (pkgconfigLibFlags "${pkgconfigLibFlags} -l${boostSignalsLib}") + ENDIF (boostSignalsLib) PLAYER_MAKE_PKGCONFIG ("playerc++" "C++ wrapper for libplayerc - part of the Player Project" - "playerxdr playerc" "" "-I${boostIncludeDir}" - "-lm -L${Boost_LIBRARY_DIRS} -l${boostThreadLib} -l${boostSignalsLib}") + "playerxdr playerc" "" "${pkgconfigIncFlags}" + "-lm ${pkgconfigLibFlags}") + CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerC++.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerC++.cmake @ONLY) PLAYER_INSTALL_HEADERS (playerc++ ${playercppconfig_h} clientproxy.h Modified: code/player/trunk/cmake/CMakeLists.txt =================================================================== --- code/player/trunk/cmake/CMakeLists.txt 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/cmake/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) @@ -1,9 +1,10 @@ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/UsePlayerC.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerC.cmake @ONLY) +# UsePlayerPlugin.cmake.in is configured in playercore SET (playerModules ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerC.cmake - UsePlayerPlugin.cmake + ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerPlugin.cmake PlayerUtils.cmake) INSTALL (FILES ${playerModules} DESTINATION share/cmake/Modules/) IF (BUILD_PLAYERCC) - INSTALL (FILES UsePlayerC++.cmake DESTINATION share/cmake/Modules/) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerC++.cmake DESTINATION share/cmake/Modules/) ENDIF (BUILD_PLAYERCC) Deleted: code/player/trunk/cmake/UsePlayerC++.cmake =================================================================== --- code/player/trunk/cmake/UsePlayerC++.cmake 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/cmake/UsePlayerC++.cmake 2009-02-19 01:39:57 UTC (rev 7344) @@ -1,63 +0,0 @@ -CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) -INCLUDE (PlayerUtils) - -INCLUDE (FindPkgConfig) -IF (NOT PKG_CONFIG_FOUND) - MESSAGE (FATAL_ERROR "Could not find pkg-config.") -ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLAYERCPP playerc++) - IF (NOT PLAYERCPP_FOUND) - MESSAGE (FATAL_ERROR "Could not find playerc++ with pkg-config.") - ENDIF (NOT PLAYERCPP_FOUND) -ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLAYERCPP_CFLAGS_STR "${PLAYERCPP_CFLAGS}") -LIST_TO_STRING (PLAYERCPP_LDFLAGS_STR "${PLAYERCPP_LDFLAGS}") - - -############################################################################### -# Macro to build a simple client. -# _clientName: The name of the executable to create -# Pass source files, flags, etc. as extra args preceded by keywords as follows: -# SOURCES <source file list> -# INCLUDEDIRS <include directories list> -# LIBDIRS <library directories list> -# LINKFLAGS <link flags list> -# CFLAGS <compile flags list> -# See the examples directory (typically, ${prefix}/share/player/examples) for -# example CMakeLists.txt files. -MACRO (PLAYER_ADD_PLAYERCPP_CLIENT _clientName) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) - IF (_junk) - MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLAYERCPP_CLIENT: ${_junk}") - ENDIF (_junk) - LIST_TO_STRING (_cFlags "${_cFlags}") - - IF (_includeDirs OR PLAYERCPP_INCLUDE_DIRS) - INCLUDE_DIRECTORIES (${_includeDirs} ${PLAYERCPP_INCLUDE_DIRS}) - ENDIF (_includeDirs OR PLAYERCPP_INCLUDE_DIRS) - IF (_libDirs OR PLAYERCPP_LIBRARY_DIRS) - LINK_DIRECTORIES (${_libDirs} ${PLAYERCPP_LIBRARY_DIRS}) - ENDIF (_libDirs OR PLAYERCPP_LIBRARY_DIRS) - - ADD_EXECUTABLE (${_clientName} ${_srcs}) - SET_TARGET_PROPERTIES (${_clientName} PROPERTIES - LINK_FLAGS ${PLAYERCPP_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLAYERCPP_LIBDIR} - BUILD_WITH_INSTALL_RPATH TRUE) - - # Get the current cflags for each source file, and add the global ones - # (this allows the user to specify individual cflags for each source file - # without the global ones overriding them). - IF (PLAYERCPP_CFLAGS_STR OR _cFlags) - FOREACH (_file ${_srcs}) - GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) - IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLAYERCPP_CFLAGS_STR} ${_cFlags}") - ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLAYERCPP_CFLAGS_STR} ${_cFlags}") - ENDIF (_fileCFlags STREQUAL NOTFOUND) - SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES - COMPILE_FLAGS ${_newCFlags}) - ENDFOREACH (_file) - ENDIF (PLAYERCPP_CFLAGS_STR OR _cFlags) -ENDMACRO (PLAYER_ADD_PLAYERCPP_CLIENT) Copied: code/player/trunk/cmake/UsePlayerC++.cmake.in (from rev 7341, code/player/trunk/cmake/UsePlayerC++.cmake) =================================================================== --- code/player/trunk/cmake/UsePlayerC++.cmake.in (rev 0) +++ code/player/trunk/cmake/UsePlayerC++.cmake.in 2009-02-19 01:39:57 UTC (rev 7344) @@ -0,0 +1,64 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) +INCLUDE (PlayerUtils) + +INCLUDE (FindPkgConfig) +IF (NOT PKG_CONFIG_FOUND) + SET (PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@ @pkgconfigIncFlags@") + SET (PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib -lm @pkgconfigLibFlags@") +ELSE (NOT PKG_CONFIG_FOUND) + pkg_check_modules (PLAYERCPP playerc++) + IF (NOT PLAYERCPP_FOUND) + MESSAGE (FATAL_ERROR "Could not find playerc++ with pkg-config.") + ENDIF (NOT PLAYERCPP_FOUND) +ENDIF (NOT PKG_CONFIG_FOUND) +LIST_TO_STRING (PLAYERCPP_CFLAGS_STR "${PLAYERCPP_CFLAGS}") +LIST_TO_STRING (PLAYERCPP_LDFLAGS_STR "${PLAYERCPP_LDFLAGS}") + + +############################################################################### +# Macro to build a simple client. +# _clientName: The name of the executable to create +# Pass source files, flags, etc. as extra args preceded by keywords as follows: +# SOURCES <source file list> +# INCLUDEDIRS <include directories list> +# LIBDIRS <library directories list> +# LINKFLAGS <link flags list> +# CFLAGS <compile flags list> +# See the examples directory (typically, ${prefix}/share/player/examples) for +# example CMakeLists.txt files. +MACRO (PLAYER_ADD_PLAYERCPP_CLIENT _clientName) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + IF (_junk) + MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLAYERCPP_CLIENT: ${_junk}") + ENDIF (_junk) + LIST_TO_STRING (_cFlags "${_cFlags}") + + IF (_includeDirs OR PLAYERCPP_INCLUDE_DIRS) + INCLUDE_DIRECTORIES (${_includeDirs} ${PLAYERCPP_INCLUDE_DIRS}) + ENDIF (_includeDirs OR PLAYERCPP_INCLUDE_DIRS) + IF (_libDirs OR PLAYERCPP_LIBRARY_DIRS) + LINK_DIRECTORIES (${_libDirs} ${PLAYERCPP_LIBRARY_DIRS}) + ENDIF (_libDirs OR PLAYERCPP_LIBRARY_DIRS) + + ADD_EXECUTABLE (${_clientName} ${_srcs}) + SET_TARGET_PROPERTIES (${_clientName} PROPERTIES + LINK_FLAGS ${PLAYERCPP_LDFLAGS_STR} ${_linkFlags} + INSTALL_RPATH ${PLAYERCPP_LIBDIR} + BUILD_WITH_INSTALL_RPATH TRUE) + + # Get the current cflags for each source file, and add the global ones + # (this allows the user to specify individual cflags for each source file + # without the global ones overriding them). + IF (PLAYERCPP_CFLAGS_STR OR _cFlags) + FOREACH (_file ${_srcs}) + GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) + IF (_fileCFlags STREQUAL NOTFOUND) + SET (_newCFlags "${PLAYERCPP_CFLAGS_STR} ${_cFlags}") + ELSE (_fileCFlags STREQUAL NOTFOUND) + SET (_newCFlags "${_fileCFlags} ${PLAYERCPP_CFLAGS_STR} ${_cFlags}") + ENDIF (_fileCFlags STREQUAL NOTFOUND) + SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES + COMPILE_FLAGS ${_newCFlags}) + ENDFOREACH (_file) + ENDIF (PLAYERCPP_CFLAGS_STR OR _cFlags) +ENDMACRO (PLAYER_ADD_PLAYERCPP_CLIENT) Deleted: code/player/trunk/cmake/UsePlayerC.cmake =================================================================== --- code/player/trunk/cmake/UsePlayerC.cmake 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/cmake/UsePlayerC.cmake 2009-02-19 01:39:57 UTC (rev 7344) @@ -1,65 +0,0 @@ -CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) -INCLUDE (PlayerUtils) - -INCLUDE (FindPkgConfig) -IF (NOT PKG_CONFIG_FOUND) - #MESSAGE (FATAL_ERROR "Could not find pkg-config.") - SET (PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") - SET (PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/Player/lib" "-lplayerc") -ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLAYERC playerc) - IF (NOT PLAYERC_FOUND) - MESSAGE (FATAL_ERROR "Could not find playerc with pkg-config.") - ENDIF (NOT PLAYERC_FOUND) -ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLAYERC_CFLAGS_STR "${PLAYERC_CFLAGS}") -LIST_TO_STRING (PLAYERC_LDFLAGS_STR "${PLAYERC_LDFLAGS}") - - -############################################################################## -# Macro to build a simple client. -# _clientName: The name of the executable to create -# Pass source files, flags, etc. as extra args preceded by keywords as follows: -# SOURCES <source file list> -# INCLUDEDIRS <include directories list> -# LIBDIRS <library directories list> -# LINKFLAGS <link flags list> -# CFLAGS <compile flags list> -# See the examples directory (typically, ${prefix}/share/player/examples) for -# example CMakeLists.txt files. -MACRO (PLAYER_ADD_PLAYERC_CLIENT _clientName) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFLags _junk ${ARGN}) - IF (_junk) - MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLAYERC_CLIENT: ${_junk}") - ENDIF (_junk) - LIST_TO_STRING (_cFlags "${_cFlags}") - - IF (_includeDirs OR PLAYERC_INCLUDE_DIRS) - INCLUDE_DIRECTORIES (${_includeDirs} ${PLAYERC_INCLUDE_DIRS}) - ENDIF (_includeDirs OR PLAYERC_INCLUDE_DIRS) - IF (_libDirs OR PLAYERC_LIBRARY_DIRS) - LINK_DIRECTORIES (${_libDirs} ${PLAYERC_LIBRARY_DIRS}) - ENDIF (_libDirs OR PLAYERC_LIBRARY_DIRS) - - ADD_EXECUTABLE (${_clientName} ${_srcs}) - SET_TARGET_PROPERTIES (${_clientName} PROPERTIES - LINK_FLAGS ${PLAYERC_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLAYERC_LIBDIR} - BUILD_WITH_INSTALL_RPATH TRUE) - - # Get the current cflags for each source file, and add the global ones - # (this allows the user to specify individual cflags for each source file - # without the global ones overriding them). - IF (PLAYERC_CFLAGS_STR OR _cFLags) - FOREACH (_file ${_srcs}) - GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) - IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLAYERC_CFLAGS_STR} ${_cFlags}") - ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLAYERC_CFLAGS_STR} ${_cFlags}") - ENDIF (_fileCFlags STREQUAL NOTFOUND) - SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES - COMPILE_FLAGS ${_newCFlags}) - ENDFOREACH (_file) - ENDIF (PLAYERC_CFLAGS_STR OR _cFLags) -ENDMACRO (PLAYER_ADD_PLAYERC_CLIENT) Modified: code/player/trunk/cmake/UsePlayerC.cmake.in =================================================================== --- code/player/trunk/cmake/UsePlayerC.cmake.in 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/cmake/UsePlayerC.cmake.in 2009-02-19 01:39:57 UTC (rev 7344) @@ -3,7 +3,6 @@ INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) - #MESSAGE (FATAL_ERROR "Could not find pkg-config.") SET (PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") SET (PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib" "-lplayerc") ELSE (NOT PKG_CONFIG_FOUND) Deleted: code/player/trunk/cmake/UsePlayerPlugin.cmake =================================================================== --- code/player/trunk/cmake/UsePlayerPlugin.cmake 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/cmake/UsePlayerPlugin.cmake 2009-02-19 01:39:57 UTC (rev 7344) @@ -1,165 +0,0 @@ -CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) -INCLUDE (PlayerUtils) - -INCLUDE (FindPkgConfig) -IF (NOT PKG_CONFIG_FOUND) - MESSAGE (FATAL_ERROR "Could not find pkg-config.") -ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLUGIN_PLAYERC playerc) - IF (NOT PLUGIN_PLAYERC_FOUND) - MESSAGE (FATAL_ERROR "Could not find playerc with pkg-config.") - ENDIF (NOT PLUGIN_PLAYERC_FOUND) -ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLUGIN_PLAYERC_CFLAGS_STR "${PLUGIN_PLAYERC_CFLAGS}") -LIST_TO_STRING (PLUGIN_PLAYERC_LDFLAGS_STR "${PLUGIN_PLAYERC_LDFLAGS}") - -INCLUDE (FindPkgConfig) -IF (NOT PKG_CONFIG_FOUND) - MESSAGE (FATAL_ERROR "Could not find pkg-config.") -ELSE (NOT PKG_CONFIG_FOUND) - pkg_check_modules (PLAYERCORE playercore) - IF (NOT PLAYERCORE_FOUND) - MESSAGE (FATAL_ERROR "Could not find playercore with pkg-config.") - ENDIF (NOT PLAYERCORE_FOUND) -ENDIF (NOT PKG_CONFIG_FOUND) -LIST_TO_STRING (PLAYERCORE_CFLAGS_STR "${PLAYERCORE_CFLAGS}") -LIST_TO_STRING (PLAYERCORE_LDFLAGS_STR "${PLAYERCORE_LDFLAGS}") - - -# This is slightly different from the one used by the Player build system itself. -# It takes a single file instead of a directory. It also expects playerinterfacegen.py -# to have been installed in the system path (as it should have been with Player). -MACRO (PROCESS_INTERFACES _file _outputFile) - ADD_CUSTOM_COMMAND (OUTPUT ${_outputFile} - COMMAND playerinterfacegen.py ${ARGN} ${_file} > ${_outputFile} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${_file} - ) -ENDMACRO (PROCESS_INTERFACES) - -MACRO (PROCESS_XDR _interfaceH _xdrH _xdrC) - ADD_CUSTOM_COMMAND (OUTPUT ${_xdrH} ${_xdrC} - COMMAND playerxdrgen.py ${_interfaceH} ${_xdrC} ${_xdrH} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${_interfaceH}) -ENDMACRO (PROCESS_XDR) - - -############################################################################### -# Macro to build a plugin driver. -# _driverName: The name of the driver library to create -# Pass source files, flags, etc. as extra args preceded by keywords as follows: -# SOURCES <source file list> -# INCLUDEDIRS <include directories list> -# LIBDIRS <library directories list> -# LINKFLAGS <link flags list> -# CFLAGS <compile flags list> -# See the examples directory (typically, ${prefix}/share/player/examples) for -# example CMakeLists.txt files. -MACRO (PLAYER_ADD_PLUGIN_DRIVER _driverName) - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) - IF (_junk) - MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLUGIN_DRIVER: ${_junk}") - ENDIF (_junk) - LIST_TO_STRING (_cFlags "${_cFlags}") - - IF (_includeDirs OR PLAYERCORE_INCLUDE_DIRS) - INCLUDE_DIRECTORIES (${_includeDirs} ${PLAYERCORE_INCLUDE_DIRS}) - ENDIF (_includeDirs OR PLAYERCORE_INCLUDE_DIRS) - IF (_libDirs OR PLAYERCORE_LIBRARY_DIRS) - LINK_DIRECTORIES (${_libDirs} ${PLAYERCORE_LIBRARY_DIRS}) - ENDIF (_libDirs OR PLAYERCORE_LIBRARY_DIRS) - - ADD_LIBRARY (${_driverName} SHARED ${_srcs}) - SET_TARGET_PROPERTIES (${_driverName} PROPERTIES - LINK_FLAGS ${PLAYERCORE_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLAYERCORE_LIBDIR} - BUILD_WITH_INSTALL_RPATH TRUE) - - # Get the current cflags for each source file, and add the global ones - # (this allows the user to specify individual cflags for each source file - # without the global ones overriding them). - IF (PLAYERCORE_CFLAGS_STR OR _cFLags) - FOREACH (_file ${_srcs}) - GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) - IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLAYERCORE_CFLAGS_STR} ${_cFlags}") - ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLAYERCORE_CFLAGS_STR} ${_cFlags}") - ENDIF (_fileCFlags STREQUAL NOTFOUND) - SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES - COMPILE_FLAGS ${_newCFlags}) - ENDFOREACH (_file) - ENDIF (PLAYERCORE_CFLAGS_STR OR _cFLags) -ENDMACRO (PLAYER_ADD_PLUGIN_DRIVER) - - -############################################################################### -# Macro to build a plugin interface. -# This macro will create generated sources prefixed with the interface name -# _interfName: The name of the interface library (not the interface itself!) -# to create -# _interfDef: The interface definition file -# -# Pass source files, flags, etc. as extra args preceded by keywords as follows: -# SOURCES <source file list> -# INCLUDEDIRS <include directories list> -# LIBDIRS <library directories list> -# LINKFLAGS <link flags list> -# CFLAGS <compile flags list> -# See the examples directory (typically, ${prefix}/share/player/examples) for -# example CMakeLists.txt files. -INCLUDE (FindPythonInterp) -MACRO (PLAYER_ADD_PLUGIN_INTERFACE _interfName _interfDef) - IF (NOT PYTHONINTERP_FOUND) - MESSAGE (FATAL_ERROR "No Python interpreter found. Cannot continue.") - ENDIF (NOT PYTHONINTERP_FOUND) - - PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) - IF (_junk) - MESSAGE (STATUS - "WARNING: unkeyworded arguments found in PLAYER_ADD_PLUGIN_INTERFACE: ${_junk}") - ENDIF (_junk) - LIST_TO_STRING (_cFlags "${_cFlags}") - - IF (_includeDirs OR PLUGIN_PLAYERC_INC_DIR) - INCLUDE_DIRECTORIES (${_includeDirs} ${PLUGIN_PLAYERC_INC_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - ENDIF (_includeDirs OR PLUGIN_PLAYERC_INC_DIR) - IF (_libDirs OR PLUGIN_PLAYERC_LIBRARY_DIRS) - LINK_DIRECTORIES (${_libDirs} ${PLUGIN_PLAYERC_LIBRARY_DIRS}) - ENDIF (_libDirs OR PLUGIN_PLAYERC_LIBRARY_DIRS) - - # Have to generate some source files - SET (interface_h ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_interface.h) - PROCESS_INTERFACES (${_interfDef} ${interface_h} --plugin) - SET (functiontable_c ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_functiontable.c) - PROCESS_INTERFACES (${_interfDef} ${functiontable_c} --plugin --functiontable) - SET_SOURCE_FILES_PROPERTIES (${functiontable_c} PROPERTIES - COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS_STR}) - SET (xdr_h ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_xdr.h) - SET (xdr_c ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_xdr.c) - PROCESS_XDR (${interface_h} ${xdr_h} ${xdr_c}) - SET_SOURCE_FILES_PROPERTIES (${xdr_c} PROPERTIES COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS_STR}) - - ADD_LIBRARY (${_interfName} SHARED ${interface_h} ${functiontable_c} ${xdr_h} ${xdr_c} ${_srcs}) - SET_TARGET_PROPERTIES (${_interfName} PROPERTIES - LINK_FLAGS ${PLUGIN_PLAYERC_LDFLAGS_STR} ${_linkFlags} - INSTALL_RPATH ${PLUGIN_PLAYERC_LIBDIR} - BUILD_WITH_INSTALL_RPATH TRUE) - - # Get the current cflags for each source file, and add the global ones - # (this allows the user to specify individual cflags for each source file - # without the global ones overriding them). - IF (PLUGIN_PLAYERC_CFLAGS_STR OR _cFLags) - FOREACH (_file ${_srcs}) - GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) - IF (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${PLUGIN_PLAYERC_CFLAGS_STR} ${_cFlags}") - ELSE (_fileCFlags STREQUAL NOTFOUND) - SET (_newCFlags "${_fileCFlags} ${PLUGIN_PLAYERC_CFLAGS_STR} ${_cFlags}") - ENDIF (_fileCFlags STREQUAL NOTFOUND) - SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES - COMPILE_FLAGS ${_newCFlags}) - ENDFOREACH (_file) - ENDIF (PLUGIN_PLAYERC_CFLAGS_STR OR _cFLags) -ENDMACRO (PLAYER_ADD_PLUGIN_INTERFACE) Copied: code/player/trunk/cmake/UsePlayerPlugin.cmake.in (from rev 7341, code/player/trunk/cmake/UsePlayerPlugin.cmake) =================================================================== --- code/player/trunk/cmake/UsePlayerPlugin.cmake.in (rev 0) +++ code/player/trunk/cmake/UsePlayerPlugin.cmake.in 2009-02-19 01:39:57 UTC (rev 7344) @@ -0,0 +1,167 @@ +CMAKE_MINIMUM_REQUIRED (VERSION 2.4 FATAL_ERROR) +INCLUDE (PlayerUtils) + +INCLUDE (FindPkgConfig) +IF (NOT PKG_CONFIG_FOUND) + SET (PLUGIN_PLAYERC_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") + SET (PLUGIN_PLAYERC_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib" "-lplayerc") +ELSE (NOT PKG_CONFIG_FOUND) + pkg_check_modules (PLUGIN_PLAYERC playerc) + IF (NOT PLUGIN_PLAYERC_FOUND) + MESSAGE (FATAL_ERROR "Could not find playerc with pkg-config.") + ENDIF (NOT PLUGIN_PLAYERC_FOUND) +ENDIF (NOT PKG_CONFIG_FOUND) +LIST_TO_STRING (PLUGIN_PLAYERC_CFLAGS_STR "${PLUGIN_PLAYERC_CFLAGS}") +LIST_TO_STRING (PLUGIN_PLAYERC_LDFLAGS_STR "${PLUGIN_PLAYERC_LDFLAGS}") + +INCLUDE (FindPkgConfig) +IF (NOT PKG_CONFIG_FOUND) + SET (PLAYERCORE_CFLAGS_STR "-I@CMAKE_INSTALL_PREFIX@/include/player@PLAYER_MAJOR_VERSION@.@PLAYER_MINOR_VERSION@") + SET (PLAYERCORE_LDFLAGS_STR "-L@CMAKE_INSTALL_PREFIX@/lib -lplayercore @corePCLibs@") +ELSE (NOT PKG_CONFIG_FOUND) + pkg_check_modules (PLAYERCORE playercore) + IF (NOT PLAYERCORE_FOUND) + MESSAGE (FATAL_ERROR "Could not find playercore with pkg-config.") + ENDIF (NOT PLAYERCORE_FOUND) +ENDIF (NOT PKG_CONFIG_FOUND) +LIST_TO_STRING (PLAYERCORE_CFLAGS_STR "${PLAYERCORE_CFLAGS}") +LIST_TO_STRING (PLAYERCORE_LDFLAGS_STR "${PLAYERCORE_LDFLAGS}") + + +# This is slightly different from the one used by the Player build system itself. +# It takes a single file instead of a directory. It also expects playerinterfacegen.py +# to have been installed in the system path (as it should have been with Player). +MACRO (PROCESS_INTERFACES _file _outputFile) + ADD_CUSTOM_COMMAND (OUTPUT ${_outputFile} + COMMAND playerinterfacegen.py ${ARGN} ${_file} > ${_outputFile} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${_file} + ) +ENDMACRO (PROCESS_INTERFACES) + +MACRO (PROCESS_XDR _interfaceH _xdrH _xdrC) + ADD_CUSTOM_COMMAND (OUTPUT ${_xdrH} ${_xdrC} + COMMAND playerxdrgen.py ${_interfaceH} ${_xdrC} ${_xdrH} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${_interfaceH}) +ENDMACRO (PROCESS_XDR) + + +############################################################################### +# Macro to build a plugin driver. +# _driverName: The name of the driver library to create +# Pass source files, flags, etc. as extra args preceded by keywords as follows: +# SOURCES <source file list> +# INCLUDEDIRS <include directories list> +# LIBDIRS <library directories list> +# LINKFLAGS <link flags list> +# CFLAGS <compile flags list> +# See the examples directory (typically, ${prefix}/share/player/examples) for +# example CMakeLists.txt files. +MACRO (PLAYER_ADD_PLUGIN_DRIVER _driverName) + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + IF (_junk) + MESSAGE (STATUS "WARNING: unkeyworded arguments found in PLAYER_ADD_PLUGIN_DRIVER: ${_junk}") + ENDIF (_junk) + LIST_TO_STRING (_cFlags "${_cFlags}") + + IF (_includeDirs OR PLAYERCORE_INCLUDE_DIRS) + INCLUDE_DIRECTORIES (${_includeDirs} ${PLAYERCORE_INCLUDE_DIRS}) + ENDIF (_includeDirs OR PLAYERCORE_INCLUDE_DIRS) + IF (_libDirs OR PLAYERCORE_LIBRARY_DIRS) + LINK_DIRECTORIES (${_libDirs} ${PLAYERCORE_LIBRARY_DIRS}) + ENDIF (_libDirs OR PLAYERCORE_LIBRARY_DIRS) + + ADD_LIBRARY (${_driverName} SHARED ${_srcs}) + SET_TARGET_PROPERTIES (${_driverName} PROPERTIES + LINK_FLAGS ${PLAYERCORE_LDFLAGS_STR} ${_linkFlags} + INSTALL_RPATH ${PLAYERCORE_LIBDIR} + BUILD_WITH_INSTALL_RPATH TRUE) + + # Get the current cflags for each source file, and add the global ones + # (this allows the user to specify individual cflags for each source file + # without the global ones overriding them). + IF (PLAYERCORE_CFLAGS_STR OR _cFLags) + FOREACH (_file ${_srcs}) + GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) + IF (_fileCFlags STREQUAL NOTFOUND) + SET (_newCFlags "${PLAYERCORE_CFLAGS_STR} ${_cFlags}") + ELSE (_fileCFlags STREQUAL NOTFOUND) + SET (_newCFlags "${_fileCFlags} ${PLAYERCORE_CFLAGS_STR} ${_cFlags}") + ENDIF (_fileCFlags STREQUAL NOTFOUND) + SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES + COMPILE_FLAGS ${_newCFlags}) + ENDFOREACH (_file) + ENDIF (PLAYERCORE_CFLAGS_STR OR _cFLags) +ENDMACRO (PLAYER_ADD_PLUGIN_DRIVER) + + +############################################################################### +# Macro to build a plugin interface. +# This macro will create generated sources prefixed with the interface name +# _interfName: The name of the interface library (not the interface itself!) +# to create +# _interfDef: The interface definition file +# +# Pass source files, flags, etc. as extra args preceded by keywords as follows: +# SOURCES <source file list> +# INCLUDEDIRS <include directories list> +# LIBDIRS <library directories list> +# LINKFLAGS <link flags list> +# CFLAGS <compile flags list> +# See the examples directory (typically, ${prefix}/share/player/examples) for +# example CMakeLists.txt files. +INCLUDE (FindPythonInterp) +MACRO (PLAYER_ADD_PLUGIN_INTERFACE _interfName _interfDef) + IF (NOT PYTHONINTERP_FOUND) + MESSAGE (FATAL_ERROR "No Python interpreter found. Cannot continue.") + ENDIF (NOT PYTHONINTERP_FOUND) + + PLAYER_PROCESS_ARGUMENTS (_srcs _includeDirs _libDirs _linkFlags _cFlags _junk ${ARGN}) + IF (_junk) + MESSAGE (STATUS + "WARNING: unkeyworded arguments found in PLAYER_ADD_PLUGIN_INTERFACE: ${_junk}") + ENDIF (_junk) + LIST_TO_STRING (_cFlags "${_cFlags}") + + IF (_includeDirs OR PLUGIN_PLAYERC_INC_DIR) + INCLUDE_DIRECTORIES (${_includeDirs} ${PLUGIN_PLAYERC_INC_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + ENDIF (_includeDirs OR PLUGIN_PLAYERC_INC_DIR) + IF (_libDirs OR PLUGIN_PLAYERC_LIBRARY_DIRS) + LINK_DIRECTORIES (${_libDirs} ${PLUGIN_PLAYERC_LIBRARY_DIRS}) + ENDIF (_libDirs OR PLUGIN_PLAYERC_LIBRARY_DIRS) + + # Have to generate some source files + SET (interface_h ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_interface.h) + PROCESS_INTERFACES (${_interfDef} ${interface_h} --plugin) + SET (functiontable_c ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_functiontable.c) + PROCESS_INTERFACES (${_interfDef} ${functiontable_c} --plugin --functiontable) + SET_SOURCE_FILES_PROPERTIES (${functiontable_c} PROPERTIES + COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS_STR}) + SET (xdr_h ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_xdr.h) + SET (xdr_c ${CMAKE_CURRENT_BINARY_DIR}/${_interfName}_xdr.c) + PROCESS_XDR (${interface_h} ${xdr_h} ${xdr_c}) + SET_SOURCE_FILES_PROPERTIES (${xdr_c} PROPERTIES COMPILE_FLAGS ${PLUGIN_PLAYERC_CFLAGS_STR}) + + ADD_LIBRARY (${_interfName} SHARED ${interface_h} ${functiontable_c} ${xdr_h} ${xdr_c} ${_srcs}) + SET_TARGET_PROPERTIES (${_interfName} PROPERTIES + LINK_FLAGS ${PLUGIN_PLAYERC_LDFLAGS_STR} ${_linkFlags} + INSTALL_RPATH ${PLUGIN_PLAYERC_LIBDIR} + BUILD_WITH_INSTALL_RPATH TRUE) + + # Get the current cflags for each source file, and add the global ones + # (this allows the user to specify individual cflags for each source file + # without the global ones overriding them). + IF (PLUGIN_PLAYERC_CFLAGS_STR OR _cFLags) + FOREACH (_file ${_srcs}) + GET_SOURCE_FILE_PROPERTY (_fileCFlags ${_file} COMPILE_FLAGS) + IF (_fileCFlags STREQUAL NOTFOUND) + SET (_newCFlags "${PLUGIN_PLAYERC_CFLAGS_STR} ${_cFlags}") + ELSE (_fileCFlags STREQUAL NOTFOUND) + SET (_newCFlags "${_fileCFlags} ${PLUGIN_PLAYERC_CFLAGS_STR} ${_cFlags}") + ENDIF (_fileCFlags STREQUAL NOTFOUND) + SET_SOURCE_FILES_PROPERTIES (${_file} PROPERTIES + COMPILE_FLAGS ${_newCFlags}) + ENDFOREACH (_file) + ENDIF (PLUGIN_PLAYERC_CFLAGS_STR OR _cFLags) +ENDMACRO (PLAYER_ADD_PLUGIN_INTERFACE) Modified: code/player/trunk/cmake/internal/SearchForStuff.cmake =================================================================== --- code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/cmake/internal/SearchForStuff.cmake 2009-02-19 01:39:57 UTC (rev 7344) @@ -127,7 +127,7 @@ # GTK checks INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) - MESSAGE (STATUS "WARNING: Could not find pkg-config; cannot search for GTK or related.") + MESSAGE (STATUS "WARNING: Could not find pkg-config. This will prevent searching for GTK and building many drivers.") ELSE (NOT PKG_CONFIG_FOUND) pkg_check_modules (GNOMECANVAS_PKG libgnomecanvas-2.0) IF (GNOMECANVAS_PKG_FOUND) Modified: code/player/trunk/libplayercore/CMakeLists.txt =================================================================== --- code/player/trunk/libplayercore/CMakeLists.txt 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/libplayercore/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) @@ -97,6 +97,7 @@ TARGET_LINK_LIBRARIES (playercore ${coreLibs}) PLAYER_MAKE_PKGCONFIG ("playercore" "Player core library - part of the Player Project" "playererror" "" "" "${corePCLibs}") +CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/UsePlayerPlugin.cmake.in ${CMAKE_BINARY_DIR}/cmake/UsePlayerPlugin.cmake @ONLY) SET (playererrorSrcs error.c) Modified: code/player/trunk/win32_todo.txt =================================================================== --- code/player/trunk/win32_todo.txt 2009-02-18 03:53:04 UTC (rev 7343) +++ code/player/trunk/win32_todo.txt 2009-02-19 01:39:57 UTC (rev 7344) @@ -8,5 +8,4 @@ - Use DLL loading for plugins on Win32 instead of ltdl (I have plenty of experience here, it shouldn't take long to do) - Installing and setting paths - Make examples work -- Make the CMake modules not require pkg-config to build clients and plugins, to reduce dependencies for windows users - Clean up all the places that add srcdir/replace as an include directory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-19 03:47:51
|
Revision: 7345 http://playerstage.svn.sourceforge.net/playerstage/?rev=7345&view=rev Author: gbiggs Date: 2009-02-19 03:47:45 +0000 (Thu, 19 Feb 2009) Log Message: ----------- Adding CPack support, making it work for a Windows install wizard. Modified Paths: -------------- code/player/trunk/CMakeLists.txt code/player/trunk/cmake/CMakeLists.txt code/player/trunk/cmake/internal/LibraryUtils.cmake code/player/trunk/config/CMakeLists.txt code/player/trunk/server/CMakeLists.txt Added Paths: ----------- code/player/trunk/PlayerCPackOptions.cmake.in code/player/trunk/cmake/player.bmp code/player/trunk/cmake/player.ico Modified: code/player/trunk/CMakeLists.txt =================================================================== --- code/player/trunk/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) +++ code/player/trunk/CMakeLists.txt 2009-02-19 03:47:45 UTC (rev 7345) @@ -80,8 +80,6 @@ # Create packages INCLUDE (InstallRequiredSystemLibraries) -SET (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") -SET (CPACK_PACKAGE_VERSION_MAJOR "${PLAYER_MAJOR_VERSION}") -SET (CPACK_PACKAGE_VERSION_MINOR "${PLAYER_MINOR_VERSION}") -SET (CPACK_PACKAGE_VERSION_PATCH "${PLAYER_REVISION_VERSION}${PLAYER_CANDIDATE_VERSION}") +CONFIGURE_FILE ("${PROJECT_SOURCE_DIR}/PlayerCPackOptions.cmake.in" "${PROJECT_BINARY_DIR}/PlayerCPackOptions.cmake" @ONLY) +SET (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/PlayerCPackOptions.cmake") INCLUDE (CPack) Added: code/player/trunk/PlayerCPackOptions.cmake.in =================================================================== --- code/player/trunk/PlayerCPackOptions.cmake.in (rev 0) +++ code/player/trunk/PlayerCPackOptions.cmake.in 2009-02-19 03:47:45 UTC (rev 7345) @@ -0,0 +1,39 @@ +SET (CPACK_PACKAGE_NAME "@PROJECT_NAME@") +SET (CPACK_PACKAGE_VERSION_MAJOR "@PLAYER_MAJOR_VERSION@") +SET (CPACK_PACKAGE_VERSION_MINOR "@PLAYER_MINOR_VERSION@") +SET (CPACK_PACKAGE_VERSION_PATCH "@PLAYER_REVISION_VERSION@") +SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Player robot server") +SET (CPACK_PACKAGE_VENDOR "Killbots, Inc.") +SET (CPACK_PACKAGE_INSTALL_DIRECTORY "@PROJECT_NAME@ @PLAYER_VERSION@") +SET (CPACK_PACKAGE_FILE_NAME "@PROJECT_NAME@-@PLAYER_VERSION@") +SET (CPACK_RESOURCE_FILE_LICENSE "@PROJECT_SOURCE_DIR@/COPYING") + +SET (CPACK_COMPONENTS_ALL applications libraries headers pkgconfig cmakestuff samplecfg) +SET (CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Application files") +SET (CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "Executable application files for the server and utilities.") +SET (CPACK_COMPONENT_APPLICATIONS_DEPENDS libraries) +SET (CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +SET (CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Run-time libraries required for the server and clients.") +SET (CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header files") +SET (CPACK_COMPONENT_HEADERS_DESCRIPTION "Header files necessary to compile clients and plugins.") +SET (CPACK_COMPONENT_HEADERS_DEPENDS libraries) +SET (CPACK_COMPONENT_PKGCONFIG_DISPLAY_NAME "pkg-config files") +SET (CPACK_COMPONENT_PKGCONFIG_DESCRIPTION "Files for the pkg-config configuration system.") +SET (CPACK_COMPONENT_PKGCONFIG_DEPENDS libraries headers) +SET (CPACK_COMPONENT_CMAKESTUFF_DISPLAY_NAME "CMake modules") +SET (CPACK_COMPONENT_CMAKESTUFF_DESCRIPTION "Modules for CMake to aid in writing client and plugin CMakeLists.txt files.") +SET (CPACK_COMPONENT_CMAKESTUFF_DEPENDS libraries headers) +SET (CPACK_COMPONENT_SAMPLECFG_DISPLAY_NAME "Sample configuration files") +SET (CPACK_COMPONENT_SAMPLECFG_DESCRIPTION "Sample configuration files for use with the server.") +SET (CPACK_COMPONENT_SAMPLECFG_DEPENDS applications) + +IF (WIN32) + SET (CPACK_NSIS_MUI_ICON "@PROJECT_SOURCE_DIR@/cmake\\player.ico") + SET (CPACK_NSIS_MUI_UNIICON "@PROJECT_SOURCE_DIR@/cmake\\player.ico") + SET (CPACK_PACKAGE_ICON "@PROJECT_SOURCE_DIR@/cmake\\player.bmp") + SET (CPACK_NSIS_HELP_LINK "http://playerstage.sourceforce.net") + SET (CPACK_NSIS_URL_INFO_ABOUT "http://playerstage.sourceforce.net") + # Add to PATH + SET (CPACK_NSIS_MODIFY_PATH ON) +ENDIF (WIN32) + Modified: code/player/trunk/cmake/CMakeLists.txt =================================================================== --- code/player/trunk/cmake/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) +++ code/player/trunk/cmake/CMakeLists.txt 2009-02-19 03:47:45 UTC (rev 7345) @@ -3,8 +3,8 @@ SET (playerModules ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerC.cmake ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerPlugin.cmake PlayerUtils.cmake) -INSTALL (FILES ${playerModules} DESTINATION share/cmake/Modules/) +INSTALL (FILES ${playerModules} DESTINATION share/cmake/Modules/ COMPONENT cmakestuff) IF (BUILD_PLAYERCC) - INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerC++.cmake DESTINATION share/cmake/Modules/) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/UsePlayerC++.cmake DESTINATION share/cmake/Modules/ COMPONENT cmakestuff) ENDIF (BUILD_PLAYERCC) Modified: code/player/trunk/cmake/internal/LibraryUtils.cmake =================================================================== --- code/player/trunk/cmake/internal/LibraryUtils.cmake 2009-02-19 01:39:57 UTC (rev 7344) +++ code/player/trunk/cmake/internal/LibraryUtils.cmake 2009-02-19 03:47:45 UTC (rev 7345) @@ -11,7 +11,6 @@ # PLAYER_ADD_LIBRARY (_name) # Adds a library to be built and installed and sets some common properties on it. MACRO (PLAYER_ADD_LIBRARY _name) -# MESSAGE (STATUS "Building library ${name} with sources ${ARGN}") ADD_LIBRARY (${_name} ${ARGN}) SET_TARGET_PROPERTIES (${_name} PROPERTIES VERSION ${PLAYER_VERSION} @@ -19,7 +18,7 @@ INSTALL_NAME_DIR ${RPATH_VAL} INSTALL_RPATH "${INSTALL_RPATH};${CMAKE_INSTALL_PREFIX}/lib" BUILD_WITH_INSTALL_RPATH TRUE) - INSTALL (TARGETS ${_name} DESTINATION lib/) + INSTALL (TARGETS ${_name} DESTINATION lib/ COMPONENT libraries) ENDMACRO (PLAYER_ADD_LIBRARY) @@ -27,12 +26,11 @@ # PLAYER_ADD_EXECUTABLE (_name) # Adds an executable to be built and installed and sets some common properties on it. MACRO (PLAYER_ADD_EXECUTABLE _name) -# MESSAGE (STATUS "Building library ${name} with sources ${ARGN}") ADD_EXECUTABLE (${_name} ${ARGN}) SET_TARGET_PROPERTIES (${_name} PROPERTIES INSTALL_RPATH "${INSTALL_RPATH};${CMAKE_INSTALL_PREFIX}/lib" BUILD_WITH_INSTALL_RPATH TRUE) - INSTALL (TARGETS ${_name} RUNTIME DESTINATION bin/) + INSTALL (TARGETS ${_name} RUNTIME DESTINATION bin/ COMPONENT applications) ENDMACRO (PLAYER_ADD_EXECUTABLE) @@ -143,7 +141,7 @@ ENDIF (${_intDeps}) CONFIGURE_FILE (${PLAYER_CMAKE_DIR}/pkgconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/${_name}.pc @ONLY) - INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${_name}.pc DESTINATION lib/pkgconfig/) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${_name}.pc DESTINATION lib/pkgconfig/ COMPONENT pkgconfig) ENDMACRO (PLAYER_MAKE_PKGCONFIG) @@ -152,5 +150,6 @@ # Installs header files MACRO (PLAYER_INSTALL_HEADERS _subdir) INSTALL (FILES ${ARGN} - DESTINATION ${PLAYER_INCLUDE_INSTALL_DIR}/lib${_subdir}) + DESTINATION ${PLAYER_INCLUDE_INSTALL_DIR}/lib${_subdir} + COMPONENT headers) ENDMACRO (PLAYER_INSTALL_HEADERS) Added: code/player/trunk/cmake/player.bmp =================================================================== (Binary files differ) Property changes on: code/player/trunk/cmake/player.bmp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: code/player/trunk/cmake/player.ico =================================================================== (Binary files differ) Property changes on: code/player/trunk/cmake/player.ico ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: code/player/trunk/config/CMakeLists.txt =================================================================== --- code/player/trunk/config/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) +++ code/player/trunk/config/CMakeLists.txt 2009-02-19 03:47:45 UTC (rev 7345) @@ -37,4 +37,4 @@ writelog.cfg wsn.cfg) -INSTALL (FILES ${sampleConfigFiles} DESTINATION "share/${PROJECT_NAME_LOWER}/config") +INSTALL (FILES ${sampleConfigFiles} DESTINATION "share/${PROJECT_NAME_LOWER}/config" COMPONENT samplecfg) Modified: code/player/trunk/server/CMakeLists.txt =================================================================== --- code/player/trunk/server/CMakeLists.txt 2009-02-19 01:39:57 UTC (rev 7344) +++ code/player/trunk/server/CMakeLists.txt 2009-02-19 03:47:45 UTC (rev 7345) @@ -47,7 +47,7 @@ IF (PLAYER_DRIVERSLIB_LINKFLAGS) TARGET_LINK_LIBRARIES (player ${PLAYER_DRIVERSLIB_LINKFLAGS}) ENDIF (PLAYER_DRIVERSLIB_LINKFLAGS) -INSTALL (TARGETS player DESTINATION bin/) +INSTALL (TARGETS player DESTINATION bin/ COMPONENT applications) # Clean up stuff from the drivers PLAYERDRIVER_RESET_LISTS () This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gb...@us...> - 2009-02-23 02:22:11
|
Revision: 7346 http://playerstage.svn.sourceforge.net/playerstage/?rev=7346&view=rev Author: gbiggs Date: 2009-02-23 01:34:23 +0000 (Mon, 23 Feb 2009) Log Message: ----------- New Python bindings generation from Luke Gumbley, fixed installation directory for Python bindings. Modified Paths: -------------- code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i code/player/trunk/client_libs/libplayerc/bindings/python/playerc_swig_parse.py code/player/trunk/examples/libplayerc++/example3.cc Modified: code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt 2009-02-19 03:47:45 UTC (rev 7345) +++ code/player/trunk/client_libs/libplayerc/bindings/python/CMakeLists.txt 2009-02-23 01:34:23 UTC (rev 7346) @@ -17,16 +17,21 @@ SET (CMAKE_SWIG_FLAGS "") - # Generate player_oo.i from playerc.h - SET (playerc_oo_i "${CMAKE_CURRENT_BINARY_DIR}/playerc_oo.i") - ADD_CUSTOM_COMMAND (OUTPUT ${playerc_oo_i} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/playerc_swig_parse.py ${PROJECT_SOURCE_DIR}/client_libs/libplayerc/playerc.h ${playerc_oo_i} + # Generate playerc_wrap.i and playerc_wrap.h from playerc.h + SET (playerc_wrap_prefix "${CMAKE_CURRENT_BINARY_DIR}/playerc_wrap") + ADD_CUSTOM_COMMAND (OUTPUT "${playerc_wrap_prefix}.i" + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/playerc_swig_parse.py ${PROJECT_SOURCE_DIR}/client_libs/libplayerc/playerc.h ${playerc_wrap_prefix} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - VERBATIM - ) - # Empty target to ensure playerc_oo.i gets created - ADD_CUSTOM_TARGET (playerc_oo_i_target ALL - DEPENDS ${playerc_oo_i}) + VERBATIM) + + ADD_CUSTOM_COMMAND(OUTPUT "${playerc_wrap_prefix}.h" + DEPENDS "${playerc_wrap_prefix}.i") + + # Empty target to ensure playerc_wrap.i and playerc_wrap.h get created + ADD_CUSTOM_TARGET (playerc_wrap_i_target ALL + DEPENDS "${playerc_wrap_prefix}.i" + DEPENDS "${playerc_wrap_prefix}.h") + # Copy playerc.i to the build directory SET (playerc_i_in "${CMAKE_CURRENT_SOURCE_DIR}/playerc.i") SET (playerc_i "${CMAKE_CURRENT_BINARY_DIR}/playerc.i") @@ -34,18 +39,27 @@ SWIG_ADD_MODULE (playerc python ${playerc_i}) SWIG_LINK_LIBRARIES (playerc ${PYTHON_LIBRARIES}) - ADD_DEPENDENCIES (${SWIG_MODULE_playerc_REAL_NAME} playerc_oo_i_target) + ADD_DEPENDENCIES (${SWIG_MODULE_playerc_REAL_NAME} playerc_wrap_i_target) TARGET_LINK_LIBRARIES (${SWIG_MODULE_playerc_REAL_NAME} playerxdr playerc playererror) IF (HAVE_JPEG) TARGET_LINK_LIBRARIES (${SWIG_MODULE_playerc_REAL_NAME} playerjpeg) ENDIF (HAVE_JPEG) - # Generate the set up script -# CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/setup.py) -# INSTALL (SCRIPT ${PLAYER_CMAKE_DIR}/internal/InstallPythonModule.cmake) + IF (PYTHON_OS_WIN) + GET_FILENAME_COMPONENT (playercpyInstallDir ${PYTHON_EXECUTABLE} PATH) + ELSE (PYTHON_OS_WIN) + # Get the Python version + EXECUTE_PROCESS (COMMAND ${PYTHON_EXECUTABLE} --version + ERROR_VARIABLE pythonVersionString + ERROR_STRIP_TRAILING_WHITESPACE) + STRING (REGEX REPLACE "^Python ([0-9]+\\.[0-9]+).*" "\\1" pythonVersion ${pythonVersionString}) + SET (playercpyInstallDir lib/python${pythonVersion}/site-packages) + ENDIF (PYTHON_OS_WIN) + SET (PYTHON_BINDINGS_INSTALL_DIR ${playercpyInstallDir} CACHE PATH "Python bindings installation directory under $prefix") + MARK_AS_ADVANCED (PYTHON_BINDINGS_INSTALL_DIR) INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/playerc.py ${CMAKE_CURRENT_BINARY_DIR}/_playerc.so - DESTINATION lib/python/site-packages) + DESTINATION ${PYTHON_BINDINGS_INSTALL_DIR}) ELSE (SWIG_FOUND) MESSAGE (STATUS "Python bindings for C client library will not be built - could not find Swig") ENDIF (SWIG_FOUND) @@ -55,3 +69,4 @@ ELSE (PYTHONINTERP_FOUND) MESSAGE (STATUS "Python bindings for C client library will not be built - could not find Python") ENDIF (PYTHONINTERP_FOUND) + Modified: code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i 2009-02-19 03:47:45 UTC (rev 7345) +++ code/player/trunk/client_libs/libplayerc/bindings/python/playerc.i 2009-02-23 01:34:23 UTC (rev 7346) @@ -2,7 +2,7 @@ %module playerc %{ -#include "playerc.h" +#include "playerc_wrap.h" #ifndef Py_RETURN_NONE #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None @@ -408,31 +408,8 @@ // Use this for object-oriented bindings; // e.g., client.connect(...) // This file is created by running ../parse_header.py -%include "playerc_oo.i" +%include "playerc_wrap.i" -%extend playerc_laser -{ -double get_range (int index) -{ - if (index < self->scan_count) - return self->ranges[index]; - else - return 0; -}; -} - -%extend playerc_sonar -{ -double get_scan (int index) -{ - if (index < self->scan_count) - return self->scan[index]; - else - return 0; -}; -} - - %extend playerc_blackboard { Modified: code/player/trunk/client_libs/libplayerc/bindings/python/playerc_swig_parse.py =================================================================== --- code/player/trunk/client_libs/libplayerc/bindings/python/playerc_swig_parse.py 2009-02-19 03:47:45 UTC (rev 7345) +++ code/player/trunk/client_libs/libplayerc/bindings/python/playerc_swig_parse.py 2009-02-23 01:34:23 UTC (rev 7346) @@ -4,309 +4,248 @@ import string import sys +# Global array of PlayerStruct objects (defined below) to hold information about +# structure definitions. +structures=[] -class Rule: +# Accessor functions to allow access to dynamic arrays (e.g. playerc_laser_t.ranges). +# accessor_header goes in playerc_wrap.h, accessor_interface goes in playerc_wrap.i. +accessor_header=""" +typedef struct +{ + TYPE *actual; +} TYPEArray; +""" - def __init__(self): +accessor_interface=""" +typedef struct +{ + TYPE *actual; - self.patterns = [] - self.replacements = [] - self.head = '' - self.foot = '' - return + %extend { + TYPE __getitem__(int index) {return $self->actual[index];} + void __setitem__(int index,TYPE value) {$self->actual[index]=value;} + } +} TYPEArray; +""" +# Class for holding information about a detected structure, including a header +# section for preprocessor directives and typedefs and a 'members' section for +# external functions that become members. +class PlayerStruct: + name='' + header="" + members="" + + def __init__(self,initName): + self.name=initName + + def __eq__(self,other): + if isinstance(other,str): + return self.name==other + return NotImplemented -class Replace: - pass +# Called for every function that matches the regex in main. If successful, +# the function will be removed, temporarily stored in a 'PlayerStruct' class, +# and later reconstituted as a member function. +def memberize(match): + # Used to remove the first parameter from a list of function parameters. + # The first parameter to a potential member function is a pointer to the structure + # to work with, which is not necessary after the transformation. + lastParams=re.compile('\(\s*\w+?.*?,\s*(?P<last>.*)\)',re.DOTALL) + funcName=match.group('name') + # The start of the loop checks chunks of the function name for a recognizable structure + # name. e.g. playerc_some_class_do_some_action will try playerc_some, playerc_some_class + # and so on until a match is found. + objName="playerc" + for i in range(1,funcName.count("_")): + objName=funcName[:funcName.find("_",len(objName)+1)] + action=funcName[len(objName)+1:] + # Once a match is found, transform the external function to a member function. + if objName in structures: + struct=structures[structures.index(objName)] + # e.g. playerc_client_create + if action=="create": + # add the function to a structure + struct.members+="\t\t" + objName + " " + match.group('params') + ";\n" + # add a preprocessor directive to ensure swig picks up the old library + # function name as a constructor. + struct.header+="\t#define new_" + objName + " " + funcName + "\n" + # e.g. playerc_client_destroy + elif action == "destroy": + # add the destructor to the structure. No destructors take parameters + # or return a value. + struct.members+="\t\tvoid destroy(void);\n" + struct.header+="\t#define del_" + objName + " " + funcName + "\n" + # e.g. playerc_client_connect + else: + # set 'last' to every parameter in the parameter list except the first. + # if no match, there are less than two parameters, in which case the + # transformed function will have no parameters (void). + lm=lastParams.match(match.group('params')) + if lm: + last=lm.group('last') + else: + last="void" + # add the function prototype to the structure. + struct.members+="\t\t" + match.group('retval') + " " + action + " (%s);\n" % last + # functions that are not constructors or destructors already match the required SWIG pattern, + # so no preprocessor directive is required. + # Since the function is a member function and will now have a prototype + # inside an 'extend' clause in the structure definition, remove the external + # reference by substituting with '' + return '' + # If the function is not a member function of a structure, take no action. + return match.group() +# This function is called for every structure. It attempts to find dynamically +# allocated arrays of simple types (which are not subscriptable in python with +# standard binding) and wrap them in an accessor structure defined at the top of this file. +def accessorize(match): + # 'text' is the new code for the matched structure (to be returned) + text=match.group('decl')+"{" + # 'body' is everything within the {}s of the structure definition + body=match.group('body'); + # 'arrayMember' is a regex designed to match certain member definitions, + # e.g. 'double *ranges;' (playerc_laser_t) + arrayMember=re.compile(r"\b(?P<type>int|double|float)\s*[*]\s*(?P<name>\w+);",re.MULTILINE) + + # performs a substitution on the member definitions described above, + # e.g. 'double *ranges;' becomes 'doubleArray ranges;', + # and appends the modified struct body to the code. + text+=arrayMember.sub("\g<type>Array \g<name>;",body) + + # terminate the modified structure and add the 'footer', usually just the end + # of the typedef. + text+="}"+match.group('footer') + return text; +# Called for every structure in the input stream. Modifies the code block to include +# an appropriate 'header' section with typedefs and preprocessor directives, +# and adds new member function prototypes in a SWIG 'extend' block at the end of the +# structure. +def genifacestruct(match): + # ensure the structure has previously been scanned (should always be the case) + if match.group('name') in structures: + # retrieve the data about the matched structure + struct=structures[structures.index(match.group('name'))] + # add the header block and a typedef to permit the change from structname_t to structname + # (for clarity in python) + text="%header\n%{\n"+struct.header+"\ttypedef " + struct.name+"_t "+struct.name+";\n%}\n\n" + # add the structure declaration and the body, omitting a closing brace + text+=match.group('decl')+"{"+match.group('body') + # add the extension block with member function protoypes, plus a closing brace. + text+="\t%extend\n\t{\n"+struct.members+"\t}\n}" + # add the remainder of the original structure definition (usually just the typedef name) + text+=match.group('footer') + return text + # if no match, print a statement to that effect and return the original structure definition. + # should never happen. + print "No match on %s" % match.group('name') + return match.group() -def compile_comment(): - """Compile comment rule.""" +# Used to remove _t from structure references. +# Had to do this due to ambiguity with typedef statements and callback function prototypes. +# e.g. typedef void (*playerc_putmsg_fn_t) (void *device, char *header, char *data); +# also typedef player_blobfinder_blob_t playerc_blobfinder_blob_t; +# This function ensures that only structures defined in playerc.h are modified. +def underscore(match): + if match.group('name') in structures: + return match.group('name') + return match.group() - rule = Rule() - rule.type = 'comment' - rule.patterns += [re.compile('/\*.*?\*/', re.DOTALL)] - rule.patterns += [re.compile('//.*')] - - return [rule] - - - -def compile(prefix): - """Compute the grammar.""" - - rules = [] - - # Create rule for typedefs - #rule = Rule() - #rule.type = 'typedef' - #rule.patterns += [re.compile('\s*\}\s*%s_t\s*;' % prefix)] - #rules += [rule] - - # Create rule for constructor - rule = Rule() - rule.type = 'constructor' - rule.patterns += [re.compile('%s_t\s*\*\s*%s_create\s*\(.*?;' % (prefix, prefix), re.DOTALL)] - - rule.head = '\n%%extend %s\n{\n' % prefix - rule.foot = '\n}\n' - - rep = Replace() - rep.src = re.compile('\s*%s_create\s*' % (prefix)) - rep.dst = '%s' % prefix - rule.replacements += [rep] - - rep = Replace() - rep.src = re.compile('\(*\s*%s_t\s*\*\w*\s*\)' % prefix) - rep.dst = '()' - rule.replacements += [rep] - - rep = Replace() - rep.src = re.compile('\(*\s*%s_t\s*\*\w*\s*,\s*' % prefix) - rep.dst = '(' - rule.replacements += [rep] - - rules += [rule] - - # Create rule for destructor - rule = Rule() - rule.type = 'destructor' - rule.patterns += [re.compile('\w*\s*%s_destroy\s*\(.*?;' % (prefix), re.DOTALL)] - - rule.head = '\n%%extend %s\n{\n' % prefix - rule.foot = '\n}\n' - - rep = Replace() - rep.src = re.compile('\w*\s*%s_destroy\s*' % (prefix)) - rep.dst = '~%s' % prefix - rule.replacements += [rep] - - rep = Replace() - rep.src = re.compile('\(*\s*%s_t\s*\*\w*\s*\)' % prefix) - rep.dst = '()' - rule.replacements += [rep] - - rep = Replace() - rep.src = re.compile('\(*\s*%s_t\s*\*\w*\s*,\s*' % prefix) - rep.dst = '(' - rule.replacements += [rep] - - rules += [rule] - - # Create rule for regular functions - rule = Rule() - rule.type = 'method' - rule.patterns += [re.compile('\w*\s*%s_\w*\s*\(.*?;' % prefix, re.DOTALL)] - #rule.patterns += [re.compile('\w*\s*%s_[a-zA-Z0-9]*\s*\(.*?;' % prefix, re.DOTALL)] - rule.patterns += [re.compile('\w*\s*\w*\s*%s_\w*\s*\(.*?;' % prefix, re.DOTALL)] - #rule.patterns += [re.compile('\w*\s*\w*\s*%s_[a-zA-Z0-9]*\s*\(.*?;' % prefix, re.DOTALL)] - rule.patterns += [re.compile('\w*\s*\*%s_\w*\s*\(.*?;' % prefix, re.DOTALL)] - #rule.patterns += [re.compile('\w*\s*\*%s_[a-zA-Z0-9]*\s*\(.*?;' % prefix, re.DOTALL)] - - rule.head = '\n%%extend %s\n{\n' % prefix - rule.foot = '\n}\n' - - rep = Replace() - rep.src = re.compile('%s_*' % prefix) - rep.dst = '' - rule.replacements += [rep] - - rep = Replace() - rep.src = re.compile('\(*\s*%s_t\s*\*\s*\w*\s*\)' % prefix) - rep.dst = '()' - rule.replacements += [rep] - - rep = Replace() - rep.src = re.compile('\(*\s*%s_t\s*\*\s*\w*\s*,\s*' % prefix) - rep.dst = '(' - rule.replacements += [rep] - - rules += [rule] - - return rules - - -def extract_prefixes(instream): - """Extract class prefixes.""" - - # Remove block comments from the file - commentRule = re.compile('/\*.*?\*/', re.DOTALL) - tempstream = commentRule.sub ('', instream) - commentRule = re.compile('//.*') - tempstream = commentRule.sub ('', tempstream) - - src = re.compile('playerc_\w*_create') - constructors = src.findall(tempstream) - - prefixes = [] - for c in constructors: - prefixes += [c[:-7]] - - return prefixes - - -def parse_file(instream, rules): - """Apply replacement rules.""" - - outstream = '' - current_struct = None - - while instream: - - line = instream - m = None - - for rule in rules: - # See if this line matches the rule - for pattern in rule.patterns: - m = pattern.match(line) - if m: - break - if not m: - continue - - func = line[m.start():m.end()] - - # Parse comment blocks - if rule.type == 'comment': - #print instream[m.start():m.end()] - instream = instream[m.end():] - outstream += func - break - - # Parse function name and args - (name, sig) = string.split(func, '(', 1) - sig = '(' + sig - tokens = string.split(name) - (rval, name) = (string.join(tokens[:-1]), tokens[-1]) - if name[0] == '*': - name = name[1:] - rval = rval + ' *' - #print '%s | %s | %s' % (rval, name, sig) - - # Apply replacement rules to return type - if rule.type == 'constructor': - rval = '' - - # Apply replacement rules to name - for rep in rule.replacements: - mm = rep.src.search(name) - if not mm: - continue - name = name[:mm.start()] + rep.dst + name[mm.end():] - - # Apply replacement rules to signature - for rep in rule.replacements: - mm = rep.src.match(sig) - if not mm: - continue - sig = sig[:mm.start()] + rep.dst + sig[mm.end():] - - #print rval, name, sig - - outstream += rule.head - outstream += '%s %s %s' % (rval, name, sig) - outstream += rule.foot - - instream = instream[m.end():] - - break - - # If no rule matches - if not m: - outstream += instream[:1] - instream = instream[1:] - - return outstream - - - - if __name__ == '__main__': + # should always be playerc.h infilename = sys.argv[1] + # should always be 'playerc_wrap' outfilename = sys.argv[2] # Read in the entire file file = open(infilename, 'r') - instream = file.read() + ifaceStream = file.read() + file.close() - # Extract "class prefixes" from the header - prefixes = extract_prefixes(instream) + # Pattern to remove all double-spacing (used later) + blank=re.compile('([ \t\f\v\r]*\n){3,}',re.MULTILINE) - #prefixes = ['playerc_log'] + # Remove all comments (multi- and single-line). + comment=re.compile('((/\*.*?\*/)|(//.*?$))', re.DOTALL|re.MULTILINE) + ifaceStream=comment.sub('',ifaceStream) - # Compute the grammar - rules = [] - rules += compile_comment() - for prefix in prefixes: - print 'prefix: %s' % prefix - rules += compile(prefix) + # Pattern to recognise structure definitions + struct=re.compile(""" + (?P<decl>typedef\s+struct\s*\w*\s*) # Declaration + {(?P<body>.*?)}(?P<footer>\s* # Body + (?P<name>playerc_\w+?)(_t)? # Name + \s*;) + """, re.DOTALL|re.VERBOSE) + + # Match and replace all structure definitions with versions that have + # accessor structures for dynamically allocated arrays using the 'accessorize' + # function above. + ifaceStream=struct.sub(accessorize,ifaceStream) + + # remove all double-spacing (pattern defined above) + ifaceStream=blank.sub('\n\n',ifaceStream) - # Parse the file and appy replacement rules - outstream = parse_file(instream, rules) + # output to new header file. It is necessary to modify the original header file to + # allow for data types of structure members to be changed. Pointers are modified + # to structures containing a pointer, to allow the member to be subscriptable in python. + # see comments on the 'accessorize' function above. + file=open("%s.h" % outfilename,"w") + # write accessor structure definitions for arrays of ints, doubles and floats. + for type in ["int","double","float"]: + file.write(accessor_header.replace("TYPE",type)) + # write the modified header file. + file.write(ifaceStream) + file.close() + + # find the names of all the structures defined in the file, and make + # a list of objects to store information about the structures. + # could be done as part of 'accessorize' but left here for clarity. + am=struct.finditer(ifaceStream) + for m in am: + structures+=[PlayerStruct(m.group('name'))] - # Do some final replacements - for prefix in prefixes: - outstream = string.replace(outstream, '%s_t' % prefix, '%s' % prefix) + # Pattern to match function prototypes that could be changed to 'member functions' + # of structures, allowing object-oriented style calling from Python. + function=re.compile(""" + \s* + ((?P<retval> # Capture the return type: + \w+\s*?( # Type name, is a + \** | # pointer OR + &? | # reference OR + (\[\s*[0-9]*\s*\]) # array. + ) + )\s*)? # Only one (potential) return value. + (?P<name> # Capture function name + playerc_\w+ # Class name and member function name + )\s* + (?P<params>\(.*?\)) # Parameters + \s*; + """, re.DOTALL|re.VERBOSE) - guff = '' - propguff = '' - for prefix in prefixes: - guff += '%%header\n %%{\ntypedef %s_t %s;\n' % (prefix, prefix) - guff += '#define new_%s %s_create\n' % (prefix, prefix) - guff += '#define del_%s %s_destroy\n' % (prefix, prefix) - guff += '%}\n' - - # stuff for properties - if prefix != "playerc_mclient" and prefix != "playerc_client": - propguff += """ -%%extend %(prefix)s -{ -int get_intprop (char * propname) -{ - int ret; - if (playerc_device_get_intprop(&self->info,propname,&ret) == 0) - return ret; - else - return 0; -}; -int set_intprop (char * propname, int value) -{ - return playerc_device_set_intprop(&self->info,propname,value); -}; + # remove the _t from the end of all the struct references. + structNames=re.compile(r"\b(?P<name>playerc_\w+)_t\b") + ifaceStream=structNames.sub(underscore,ifaceStream) -double get_dblprop (char * propname) -{ - double ret; - if (playerc_device_get_dblprop(&self->info,propname,&ret) == 0) - return ret; - else - return 0; -}; -int set_dblprop (char * propname, double value) -{ - return playerc_device_set_dblprop(&self->info,propname,value); -}; + # using the 'memberize' function, find functions that should be struct 'members' and shift them. + ifaceStream=function.sub(memberize,ifaceStream) -char * get_strprop (char * propname) -{ - char * ret; - if (playerc_device_get_strprop(&self->info,propname,&ret) == 0) - return ret; - else - return NULL; -}; -int set_strprop (char * propname, char * value) -{ - return playerc_device_set_strprop(&self->info,propname,value); -}; -} """ % {"prefix": prefix} - + # Using the gathered information about functions and structures, rewrite the structure + # definitions in the interface file to include required extensions (function prototypes), + # typedefs and preprocessor directives. see comments on 'genifacestruct' function above. + ifaceStream=struct.sub(genifacestruct,ifaceStream) - outstream = guff + outstream + propguff - - file = open(outfilename, 'w+') - file.write(outstream) - + # remove all double spacing. + ifaceStream=blank.sub('\n\n',ifaceStream) + + # write the SWIG interface definition file. + file=open("%s.i" % outfilename,"w") + # write interfaces for the accessor structs including subscripting functions. + for type in ["int","double","float"]: + file.write(accessor_interface.replace("TYPE",type)) + file.write(ifaceStream) + file.close() + \ No newline at end of file Modified: code/player/trunk/examples/libplayerc++/example3.cc =================================================================== --- code/player/trunk/examples/libplayerc++/example3.cc 2009-02-19 03:47:45 UTC (rev 7345) +++ code/player/trunk/examples/libplayerc++/example3.cc 2009-02-23 01:34:23 UTC (rev 7346) @@ -2,6 +2,7 @@ #include <iostream> #include <list> #include <algorithm> +#include <functional> int main(int argc, char** argv) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |