Main Page | Data Structures | File List | Data Fields | Globals

src/emul.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Lonnie Mendez * 00003 * lmendez19@austin.rr.com * 00004 * * 00005 * earthmateusb_userland: Portable user land library providing access to * 00006 * earthmate usb device via libusb. * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 ***************************************************************************/ 00023 00024 #ifndef EMUL_H 00025 #define EMUL_H 00026 00033 /* TODO: add functions to read uart status data - pointless really, but oh well. */ 00034 #define UART_DSR 0x20 /* data set ready - flow control - device to host */ 00035 #define UART_CTS 0x10 /* clear to send - flow control - device to host */ 00036 #define UART_RI 0x10 /* ring indicator - modem - device to host */ 00037 #define UART_CD 0x40 /* carrier detect - modem - device to host */ 00038 #define PARITY_ERROR 0x08 /* received from input report - device to host */ 00039 00040 00041 /* The header file is heavily doxygenated... please have a look at html/index.html if 00042 * you find reading this header is starting to give you a headache. 00043 */ 00044 00050 #define NORMAL 0x0 00051 00057 #define EMATE 0x1 00058 00063 void em_devtype(int type); 00068 int em_isemate(void); 00073 int em_isactive(void); 00081 int em_open(void); 00086 void em_close(void); 00094 int em_replug(void); 00102 #define CONTROL_DTR 0x20 /* data terminal ready - flow control - host to device */ 00103 00110 #define CONTROL_RTS 0x10 /* request to send - flow control - host to device */ 00111 00117 #define CONTROL_RESET 0x08 /* sent with output report (unknown affect) - host to device */ 00118 00123 #define CONTROL_DROP 0x00 /* drop all lines */ 00124 00129 void em_linecontrol(u_int8_t lines); 00134 #define PAR_ODD 0x30 00135 00139 #define PAR_EVEN 0x10 00140 00144 #define PAR_NONE 0x00 00145 00149 struct serconfig { 00154 long baudrate; 00159 short databits; 00164 short stopbits; /* 1, 2 stop bits */ 00169 short parity; /* 0 - none, 1 - odd, 2 - even parity */ 00170 }; 00176 int em_serconfig_set(struct serconfig *sconfig); 00181 int em_serconfig_get(struct serconfig *sconfig); 00182 00187 #define EM_MAX_READ 4096 00188 00192 #define EM_MAX_WRITE 4096 00193 00199 int em_read(u_int8_t buffer[], int count); 00206 int em_write(const u_int8_t *buffer, int count); 00207 00212 int em_flush(int queue_selector); 00213 00218 int em_read_data_avail(void); 00223 int em_write_data_avail(void); 00224 00233 int em_datawait(struct timeval *tv, int jumpout); 00234 00245 /* counterpart to select 00246 */ 00247 int em_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 00248 00251 void em_writewait(void); 00252 00257 void em_debuglevel(int mode); 00258 00264 #define EMT_ACTIVE 1 00265 00270 #define EMT_IDLING 0 00271 void em_change_state(int state); 00272 00280 ssize_t READ(int fd, void *buf, size_t count); 00287 ssize_t WRITE(int fd, const void *buf, size_t count); 00288 00293 unsigned int em_getbaudmask(unsigned int rate); 00298 long em_getbaudrate(void); 00299 00300 /* usb devid/vendid */ 00303 #define VENDOR_ID_DELORME 0x1163 00304 00306 #define PRODUCT_ID_EARTHMATEUSB 0x0100 00307 00308 00316 #define MAX_READ_WRITE 30 00317 00318 /* TODO: consider removing the below two functions from public api view */ 00324 int em_raw_read(u_int8_t buffer[]); 00330 int em_raw_write(u_int8_t *buffer, int size); 00331 00332 #endif /* ifndef EMUL_H */

Generated on Sat Apr 2 14:58:13 2005 for EarthMate Userland Library by doxygen 1.3.7