Changeset 128

Show
Ignore:
Timestamp:
06/18/07 19:28:49 (2 years ago)
Author:
dsmith
Message:

revised error messages and doc strings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r127 r128  
     12007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
     2        wminput 
     3        * revised error messages 
     4 
     5        python 
     6        * revised error messages and doc strings 
     7 
    182007-06-14 L. Donnie Smith <cwiid@abstrakraft.org> 
    29        libcwiid 
  • trunk/python/Wiimote.c

    r125 r128  
    2020 * 
    2121 * ChangeLog: 
     22 * 2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
     23 * * revised error messages and doc strings 
     24 * 
    2225 * 2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 
    2326 * * removed Wiimote_FromC function 
     
    97100{ 
    98101        {"close", (PyCFunction)Wiimote_close, METH_NOARGS, 
    99          "close wiimote connection"}, 
     102         "close()\n\nClose the Wiimote connection"}, 
    100103        {"enable", (PyCFunction)Wiimote_enable, METH_VARARGS | METH_KEYWORDS, 
    101          "enable flags on wiimote"}, 
     104         "enable(flags)\n\nenable Wiimote connection flags"}, 
    102105        {"disable", (PyCFunction)Wiimote_disable, METH_VARARGS | METH_KEYWORDS, 
    103          "disable flags on wiimote"}, 
     106         "disable(flags)\n\ndisable Wiimote connection flags"}, 
    104107        {"get_mesg", (PyCFunction)Wiimote_get_mesg, METH_NOARGS, 
    105          "blocking call to get messages"}, 
     108         "get_mesg() -> message list\n\nretrieve message list from queue"}, 
    106109        {"get_acc_cal", (PyCFunction)Wiimote_get_acc_cal, 
    107          METH_VARARGS | METH_KEYWORDS, "get accelerometer calibration"}, 
     110         METH_VARARGS | METH_KEYWORDS, 
     111         "get_acc_cal(extension) -> calibration tuple\n\n" 
     112         "retrieve calibration information"}, 
    108113        {"request_status", (PyCFunction)Wiimote_request_status, METH_NOARGS, 
    109          "request status message"}, 
     114         "request_status()\n\nrequest status message"}, 
    110115        {"read", (PyCFunction)Wiimote_read, METH_VARARGS | METH_KEYWORDS, 
    111          "read from wiimote"}, 
     116         "read(flags,offset,len) -> buffer\n\nread data from Wiimote"}, 
    112117        {"write", (PyCFunction)Wiimote_write, METH_VARARGS | METH_KEYWORDS, 
    113          "write to wiimote"}, 
     118         "write(flags,offset,buffer)\n\nwrite data to Wiimote"}, 
    114119        {NULL, NULL, 0, NULL} 
    115120}; 
     
    148153        0,                                              /* tp_as_buffer */ 
    149154        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,       /* tp_flags */ 
    150         "cwiid c-python interface",   /* tp_doc */ 
     155        "CWiid Wiimote connection object",    /* tp_doc */ 
    151156        0,                                              /* tp_traverse */ 
    152157        0,                                              /* tp_clear */ 
     
    194199} 
    195200 
    196 static int cwiid_start(Wiimote *self, int flags) 
    197 { 
    198         cwiid_wiimote_t *wiimote; 
    199  
    200         /* Set up wiimote */ 
    201  
    202         /* keep pyobject with wiimote */ 
    203         cwiid_set_data(wiimote,self); 
    204         /* keep wiimote with pyobject */ 
    205         self->wiimote = wiimote; 
    206         return 0; 
    207 } 
    208  
    209201static int Wiimote_init(Wiimote* self, PyObject* args, PyObject *kwds) 
    210202{ 
     
    234226                if (str_bdaddr) { 
    235227                        if (str2ba(str_bdaddr, &bdaddr)) { 
    236                                 PyErr_SetString(PyExc_IOError, "bad bdaddr"); 
     228                                PyErr_SetString(PyExc_ValueError, "bad bdaddr"); 
    237229                                return -1; 
    238230                        } 
     
    243235 
    244236                if (!(wiimote = cwiid_open(&bdaddr, flags))) { 
    245                         PyErr_SetString(PyExc_IOError, "Could not open wiimote"); 
     237                        PyErr_SetString(PyExc_RuntimeError, 
     238                                        "Error opening wiimote connection"); 
    246239                        return -1; 
    247240                } 
     
    259252{ 
    260253        if (cwiid_close(self->wiimote)) { 
    261                 PyErr_SetString(PyExc_IOError, "Wiimote close error"); 
     254                PyErr_SetString(PyExc_RuntimeError, 
     255                                "Error closing wiimote connection"); 
    262256                self->wiimote = NULL; 
    263257                return NULL; 
     
    279273 
    280274        if (cwiid_enable(self->wiimote, flags)) { 
    281                 PyErr_SetString(PyExc_IOError, "cwiid_enable error"); 
     275                PyErr_SetString(PyExc_RuntimeError, "Error enabling wiimote flags"); 
    282276                return NULL; 
    283277        } 
     
    297291 
    298292        if (cwiid_disable(self->wiimote, flags)) { 
    299                 PyErr_SetString(PyExc_IOError, "cwiid_disable error"); 
     293                PyErr_SetString(PyExc_RuntimeError, "Error disabling wiimote flags"); 
    300294                return NULL; 
    301295        } 
     
    317311        if ((OldCallback == Py_None) && (NewCallback != Py_None)) { 
    318312                if (cwiid_set_mesg_callback(self->wiimote, CallbackBridge)) { 
    319                         PyErr_SetString(PyExc_IOError, "set callback error"); 
     313                        PyErr_SetString(PyExc_AttributeError, 
     314                                        "Error setting wiimote callback"); 
    320315                        return -1; 
    321316                } 
     
    323318        else if ((OldCallback != Py_None) && (NewCallback == Py_None)) { 
    324319                if (cwiid_set_mesg_callback(self->wiimote, NULL)) { 
    325                         PyErr_SetString(PyExc_IOError, "set callback error"); 
     320                        PyErr_SetString(PyExc_AttributeError, 
     321                                        "Error clearing wiimote callback"); 
    326322                        return -1; 
    327323                } 
     
    347343                } 
    348344                else { 
    349                         PyErr_SetString(PyExc_IOError, "get_mesg error"); 
     345                        PyErr_SetString(PyExc_RuntimeError, 
     346                                        "Error getting wiimote message list"); 
    350347                        return NULL; 
    351348                } 
     
    541538 
    542539        if (cwiid_get_acc_cal(self->wiimote, ext_type, &acc_cal)) { 
    543                 PyErr_SetString(PyExc_IOError, "Wiimote get acc cal error"); 
     540                PyErr_SetString(PyExc_RuntimeError, 
     541                                "Error getting wiimote acc calibration"); 
    544542                return NULL; 
    545543        } 
     
    558556{ 
    559557        if (cwiid_request_status(self->wiimote)) { 
    560                 PyErr_SetString(PyExc_IOError, "Wiimote request status error"); 
     558                PyErr_SetString(PyExc_RuntimeError, "Error requesting wiimote status"); 
    561559                return NULL; 
    562560        } 
     
    574572 
    575573        if (cwiid_set_led(self->wiimote, (uint8_t)led)) { 
    576                 PyErr_SetString(PyExc_IOError, "Wiimote set led error"); 
     574                PyErr_SetString(PyExc_AttributeError, 
     575                                "Error setting wiimote led state"); 
    577576                return -1; 
    578577        } 
     
    591590 
    592591        if (cwiid_set_rumble(self->wiimote, (uint8_t)rumble)) { 
    593                 PyErr_SetString(PyExc_IOError, "Wiimote set rumble error"); 
     592                PyErr_SetString(PyExc_AttributeError, 
     593                                "Error setting wiimote rumble state"); 
    594594                return -1; 
    595595        } 
     
    608608 
    609609        if (cwiid_set_rpt_mode(self->wiimote, (uint8_t)rpt_mode)) { 
    610                 PyErr_SetString(PyExc_IOError, "Wiimote set rpt_mode error"); 
     610                PyErr_SetString(PyExc_AttributeError, 
     611                                "Error setting wiimote report mode"); 
    611612                return -1; 
    612613        } 
     
    653654        } 
    654655        if (cwiid_read(self->wiimote,flags,offset,len,buf)) { 
    655                 PyErr_SetString(PyExc_IOError, "Wiimote read error"); 
     656                PyErr_SetString(PyExc_RuntimeError, "Error reading wiimote data"); 
    656657                Py_DECREF(pyRetBuf); 
    657658                return NULL; 
     
    675676 
    676677        if (cwiid_write(self->wiimote, flags, offset, len, buf)) { 
    677                 PyErr_SetString(PyExc_IOError, "Wiimote write error"); 
     678                PyErr_SetString(PyExc_RuntimeError, "Error writing wiimote data"); 
    678679                return NULL; 
    679680        } 
  • trunk/wminput/conf.c

    r125 r128  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * revised error messages 
     20 * 
    1821 *  2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * refactored to isolate plugin logic 
     
    7174        if (yyparse()) { 
    7275                if (fclose(yyin)) { 
    73                         wminput_err("error closing configuration file"); 
     76                        wminput_err("Error closing configuration file"); 
    7477                } 
    7578                conf_unload(cur_conf); 
     
    488491 
    489492        if (conf->stack_index+1 >= CONF_MAX_INCLUDE_DEPTH) { 
    490                 wminput_err("maximum include depth exceeded: %s", filename); 
     493                wminput_err("Maximum include depth exceeded: %s", filename); 
    491494                return NULL; 
    492495        } 
     
    512515 
    513516        if (!file) { 
    514                 wminput_err("file not found: %s", filename); 
     517                wminput_err("File not found: %s", filename); 
    515518                return NULL; 
    516519        } 
     
    519522        if ((conf->config_filename_stack[conf->stack_index] = 
    520523          malloc(strlen(stackname) + 1)) == NULL) { 
    521                 wminput_err("out of memory"); 
     524                wminput_err("Error allocating pathname"); 
    522525                conf->stack_index--; 
    523526                return NULL; 
     
    581584 
    582585        if (i == CONF_MAX_PLUGINS) { 
    583                 wminput_err("maximum number of plugins exceeded"); 
     586                wminput_err("Maximum number of plugins exceeded"); 
    584587                return NULL; 
    585588        } 
     
    600603 
    601604        if (!plugin_found) { 
    602                 wminput_err("plugin not found: %s", name); 
     605                wminput_err("Plugin not found: %s", name); 
    603606                free(plugin->name); 
    604607                plugin->name = NULL; 
  • trunk/wminput/main.c

    r125 r128  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * revised error messages 
     20 * 
    1821 *  2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * refactored to isolate plugin logic 
     
    165168        /* Setup search directory arrays */ 
    166169        if ((tmp = getenv("HOME")) == NULL) { 
    167                 wminput_err("unable to find home directory"); 
     170                wminput_err("Unable to find home directory"); 
    168171                config_search_dirs[0] = WMINPUT_CONFIG_DIR; 
    169172                plugin_search_dirs[0] = CWIID_PLUGINS_DIR; 
     
    294297 
    295298        if (pthread_cancel(uinput_listen_thread)) { 
    296                 wminput_err("error canceling uinput listen thread"); 
     299                wminput_err("Error canceling uinput listen thread"); 
    297300                ret = -1; 
    298301        } 
    299302        else if (pthread_join(uinput_listen_thread, NULL)) { 
    300                 wminput_err("error joing uinput listen thread"); 
     303                wminput_err("Error joining uinput listen thread"); 
    301304                ret = -1; 
    302305        } 
     
    304307        /* disconnect */ 
    305308        if (cwiid_close(wiimote)) { 
    306                 wminput_err("error on disconnect"); 
     309                wminput_err("Error on wiimote disconnect"); 
    307310                ret = -1; 
    308311        } 
     
    329332 
    330333        if (cwiid_set_rpt_mode(wiimote, rpt_mode_flags)) { 
    331                 wminput_err("error setting report mode"); 
     334                wminput_err("Error setting report mode"); 
    332335                return -1; 
    333336        } 
     
    365368                case CWIID_MESG_ERROR: 
    366369                        if (kill(getpid(),SIGINT)) { 
    367                                 wminput_err("error sending SIGINT"); 
     370                                wminput_err("Error sending SIGINT"); 
    368371                        } 
    369372                        break; 
  • trunk/wminput/py_plugin.c

    r125 r128  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-06-18 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * revised error messages 
     20 * 
    1821 *  2007-06-05 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * relocated all python plugin logic here 
     
    7578{ 
    7679        {"set_rpt_mode", (PyCFunction)set_rpt_mode, METH_VARARGS | METH_KEYWORDS, 
    77          "set plugin report mode"}, 
     80         "set_rpt_mode(id, rpt_mode)\n\nset the plugin report mode"}, 
    7881        {NULL, NULL, 0, NULL} 
    7982}; 
     
    111114        /* note: PyWmPluginModule is a borrowed reference - do not decref */ 
    112115        if (!(PyWmPluginModule = Py_InitModule3("wmplugin", Module_Methods, 
    113                                                "plugin interface for wminput"))) { 
     116                                                "wminput plugin interface"))) { 
    114117                PyErr_Print(); 
    115118                goto ERR_HND; 
     
    124127                } 
    125128        } 
    126  
    127         PyRun_SimpleString("import sys; sys.path.append('.')"); 
    128129 
    129130        return 0; 
     
    227228 
    228229        if (!(plugin->p = malloc(sizeof(struct py_plugin)))) { 
    229                 wminput_err("malloc error"); 
     230                wminput_err("Error allocating py_plugin"); 
    230231                return -1; 
    231232        } 
     
    238239 
    239240        if (!(plugin->info = malloc(sizeof *plugin->info))) { 
    240                 wminput_err("malloc error"); 
     241                wminput_err("Error allocating plugin info"); 
    241242                goto ERR_HND; 
    242243        } 
    243244        if (!(plugin->data = malloc(sizeof *plugin->data))) { 
    244                 wminput_err("malloc error"); 
     245                wminput_err("Error allocating plugin data"); 
    245246                goto ERR_HND; 
    246247        } 
     
    273274        } 
    274275        if (py_plugin_info(plugin, info)) { 
    275                 wminput_err("python_info error"); 
     276                wminput_err("Error on python_info"); 
    276277                Py_DECREF((PyObject *)info); 
    277278                goto ERR_HND; 
     
    334335        if (!(PySequence_Check(PyButtonInfo) && PySequence_Check(PyAxisInfo) && 
    335336              PySequence_Check(PyParamInfo))) { 
    336                 wminput_err("info not sequences"); 
     337                wminput_err("Type error in wminput_info: info not sequences"); 
    337338                goto ERR_HND; 
    338339        } 
     
    463464 
    464465        if (!(PySequence_Check(PyButtonData) && PySequence_Check(PyAxisData))) { 
    465                 wminput_err("exec not sequences"); 
     466                wminput_err("Type error on wminput_exec: exec not sequences"); 
    466467                Py_DECREF(PyData); 
    467468                return -1; 
     
    469470 
    470471        if (PySequence_Size(PyButtonData) != plugin->info->button_count) { 
    471                 wminput_err("exec bad button sequence"); 
     472                wminput_err("Type error on wminput_exec: bad button sequence"); 
    472473                Py_DECREF(PyData); 
    473474                return -1; 
     
    485486                } 
    486487                else if (PyObj != Py_False) { 
    487                         wminput_err("exec bad button value"); 
     488                        wminput_err("Type error on wminput_exec: bad button value"); 
    488489                        Py_DECREF(PyObj); 
    489490                        Py_DECREF(PyData); 
     
    495496 
    496497        if (PySequence_Size(PyAxisData) != plugin->info->axis_count) { 
    497                 wminput_err("exec bad axis sequence"); 
     498                wminput_err("Error on wminput_exec: bad axis sequence"); 
    498499                Py_DECREF(PyData); 
    499500                return -1; 
     
    510511                } 
    511512                else if (!PyInt_Check(PyObj)) { 
    512                         wminput_err("exec bad axis value"); 
     513                        wminput_err("Type error on wminput_exec: bad axis value"); 
    513514                        Py_DECREF(PyObj); 
    514515                        Py_DECREF(PyData);