00001 /* 00002 * rcx_comm.h 00003 * 00004 * RCX communication routines. 00005 * 00006 * The contents of this file are subject to the Mozilla Public License 00007 * Version 1.0 (the "License"); you may not use this file except in 00008 * compliance with the License. You may obtain a copy of the License at 00009 * http://www.mozilla.org/MPL/ 00010 * 00011 * Software distributed under the License is distributed on an "AS IS" 00012 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 00013 * License for the specific language governing rights and limitations 00014 * under the License. 00015 * 00016 * The Original Code is Firmdl code, released October 3, 1998. 00017 * 00018 * The Initial Developer of the Original Code is Kekoa Proudfoot. 00019 * Portions created by Kekoa Proudfoot are Copyright (C) 1998, 1999 00020 * Kekoa Proudfoot. All Rights Reserved. 00021 * 00022 * Contributor(s): Kekoa Proudfoot <kekoa@graphics.stanford.edu> 00023 */ 00024 00025 #ifndef RCX_COMM_H_INCLUDED 00026 #define RCX_COMM_H_INCLUDED 00027 00028 #define RCX_OK 0 00029 #define RCX_NO_TOWER -1 00030 #define RCX_BAD_LINK -2 00031 #define RCX_BAD_ECHO -3 00032 #define RCX_NO_RESPONSE -4 00033 #define RCX_BAD_RESPONSE -5 00034 00035 #if defined(_WIN32) 00036 #define FILEDESCR HANDLE 00037 #define BADFILE NULL 00038 #else 00039 #define FILEDESCR int 00040 #define BADFILE -1 00041 #endif 00042 00043 00044 /* Get a file descriptor for the named tty, exits with message on error */ 00045 extern FILEDESCR rcx_init (char *tty, int is_fast); 00046 00047 /* Close a file descriptor allocated by rcx_init */ 00048 extern void rcx_close (FILEDESCR fd); 00049 00050 /* Try to wakeup the tower for timeout ms, returns error code */ 00051 extern int rcx_wakeup_tower (FILEDESCR fd, int timeout); 00052 00053 /* Try to send a message, returns error code */ 00054 /* Set use_comp=1 to send complements, use_comp=0 to suppress them */ 00055 extern int rcx_send (FILEDESCR fd, void *buf, int len, int use_comp); 00056 00057 /* Try to receive a message, returns error code */ 00058 /* Set use_comp=1 to expect complements */ 00059 /* Waits for timeout ms before detecting end of response */ 00060 extern int rcx_recv (FILEDESCR fd, void *buf, int maxlen, int timeout, int use_comp); 00061 00062 /* Try to send a message and receive its response, returns error code */ 00063 /* Set use_comp=1 to send and receive complements, use_comp=0 otherwise */ 00064 /* Waits for timeout ms before detecting end of response */ 00065 extern int rcx_sendrecv (FILEDESCR fd, void *send, int slen, void *recv, int rlen, int timeout, int retries, int use_comp); 00066 00067 /* Test whether or not the rcx is alive, returns 1=yes, 0=no */ 00068 /* Set use_comp=1 to send complements, use_comp=0 to suppress them */ 00069 extern int rcx_is_alive (FILEDESCR fd, int use_comp); 00070 00071 /* Convert an error code to a string */ 00072 extern char *rcx_strerror(int error); 00073 00074 /* Hexdump routine */ 00075 extern void hexdump(char *prefix, void *buf, int len); 00076 00077 00078 #endif /* RCX_COMM_H_INCLUDED */ 00079