├── src ├── readme.txt ├── serialport.c ├── error-log.h ├── serialport.h ├── Makefile ├── error-log.c ├── debug-msg.h └── main.c ├── doc ├── image_dir │ ├── com-male.jpg │ ├── com-female.jpg │ ├── minicom����.jpg │ ├── serial-write.jpg │ ├── send_revc_self.jpg │ └── serial-read-minicom.jpg ├── serialport-html │ ├── bc_s.png │ ├── bdwn.png │ ├── nav_f.png │ ├── nav_g.png │ ├── nav_h.png │ ├── open.png │ ├── tab_a.png │ ├── tab_b.png │ ├── tab_h.png │ ├── tab_s.png │ ├── closed.png │ ├── doxygen.png │ ├── ftv2cl.png │ ├── ftv2doc.png │ ├── ftv2mo.png │ ├── ftv2ns.png │ ├── sync_on.png │ ├── com-female.jpg │ ├── com-male.jpg │ ├── ftv2blank.png │ ├── ftv2link.png │ ├── ftv2mnode.png │ ├── ftv2node.png │ ├── ftv2pnode.png │ ├── sync_off.png │ ├── ftv2lastnode.png │ ├── ftv2splitbar.png │ ├── ftv2vertline.png │ ├── serial-write.jpg │ ├── ftv2folderopen.png │ ├── ftv2mlastnode.png │ ├── ftv2plastnode.png │ ├── send_revc_self.jpg │ ├── ftv2folderclosed.png │ ├── serial-read-minicom.jpg │ ├── tabs.css │ ├── index.html │ ├── serialport_8h-source.html │ ├── bug.html │ ├── todo.html │ ├── pages.html │ ├── test.html │ ├── globals_vars.html │ ├── dynsections.js │ ├── globals_defs.html │ ├── globals_func.html │ ├── serialport_8h_source.html │ ├── error-log_8h-source.html │ ├── dir_68267d1309a1af8e8297ef4c3efbcdba.html │ ├── files.html │ ├── globals.html │ ├── debug-msg_8h-source.html │ ├── error-log_8h_source.html │ ├── serialport_8h.html │ ├── serialport_8c.html │ ├── debug-msg_8h_source.html │ ├── main_8c.html │ ├── debug-msg_8h.html │ └── doxygen.css └── Doxyfile └── README /src/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/src/readme.txt -------------------------------------------------------------------------------- /src/serialport.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/src/serialport.c -------------------------------------------------------------------------------- /doc/image_dir/com-male.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/image_dir/com-male.jpg -------------------------------------------------------------------------------- /doc/image_dir/com-female.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/image_dir/com-female.jpg -------------------------------------------------------------------------------- /doc/image_dir/minicom����.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/image_dir/minicom����.jpg -------------------------------------------------------------------------------- /doc/serialport-html/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/bc_s.png -------------------------------------------------------------------------------- /doc/serialport-html/bdwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/bdwn.png -------------------------------------------------------------------------------- /doc/serialport-html/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/nav_f.png -------------------------------------------------------------------------------- /doc/serialport-html/nav_g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/nav_g.png -------------------------------------------------------------------------------- /doc/serialport-html/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/nav_h.png -------------------------------------------------------------------------------- /doc/serialport-html/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/open.png -------------------------------------------------------------------------------- /doc/serialport-html/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/tab_a.png -------------------------------------------------------------------------------- /doc/serialport-html/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/tab_b.png -------------------------------------------------------------------------------- /doc/serialport-html/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/tab_h.png -------------------------------------------------------------------------------- /doc/serialport-html/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/tab_s.png -------------------------------------------------------------------------------- /doc/image_dir/serial-write.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/image_dir/serial-write.jpg -------------------------------------------------------------------------------- /doc/serialport-html/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/closed.png -------------------------------------------------------------------------------- /doc/serialport-html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/doxygen.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2cl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2cl.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2doc.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2mo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2mo.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2ns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2ns.png -------------------------------------------------------------------------------- /doc/serialport-html/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/sync_on.png -------------------------------------------------------------------------------- /doc/image_dir/send_revc_self.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/image_dir/send_revc_self.jpg -------------------------------------------------------------------------------- /doc/serialport-html/com-female.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/com-female.jpg -------------------------------------------------------------------------------- /doc/serialport-html/com-male.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/com-male.jpg -------------------------------------------------------------------------------- /doc/serialport-html/ftv2blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2blank.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2link.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2mnode.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2node.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2pnode.png -------------------------------------------------------------------------------- /doc/serialport-html/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/sync_off.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2lastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2lastnode.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2splitbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2splitbar.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2vertline.png -------------------------------------------------------------------------------- /doc/serialport-html/serial-write.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/serial-write.jpg -------------------------------------------------------------------------------- /doc/image_dir/serial-read-minicom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/image_dir/serial-read-minicom.jpg -------------------------------------------------------------------------------- /doc/serialport-html/ftv2folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2folderopen.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2mlastnode.png -------------------------------------------------------------------------------- /doc/serialport-html/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2plastnode.png -------------------------------------------------------------------------------- /doc/serialport-html/send_revc_self.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/send_revc_self.jpg -------------------------------------------------------------------------------- /doc/serialport-html/ftv2folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/ftv2folderclosed.png -------------------------------------------------------------------------------- /doc/serialport-html/serial-read-minicom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/latelee/serialport_linux/HEAD/doc/serialport-html/serial-read-minicom.jpg -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | serialport_linux 2 | ================ 3 | 4 | An implement of Serialport under linux, writing in C language. 5 | 6 | build & run 7 | ================ 8 | 9 | $ make 10 | $ ./a.out 11 | 12 | current status 13 | ================ 14 | 15 | serial device: "/dev/ttyUSB0", 16 | port attribute: 9600, 8, 'N', 1 17 | 18 | One thread to write, one thread to read, one thread to exit. 19 | 20 | Good luck! 21 | 22 | Late Lee 23 | latelee@163.com 24 | -------------------------------------------------------------------------------- /src/error-log.h: -------------------------------------------------------------------------------- 1 | #ifndef _ERROR_LOG_H 2 | #define _ERROR_LOG_H 3 | 4 | #define MAXLINE 4096 5 | 6 | extern int debug; 7 | 8 | #define DEBUG 9 | #ifdef DEBUG 10 | #define debug_msg(fmt, ...) \ 11 | fprintf(stdout, fmt, ##__VA_ARGS__) 12 | #else 13 | #define debug_msg(fmt,...) 14 | #endif /* DEBUG */ 15 | 16 | #define TRACE 17 | 18 | #ifdef TRACE 19 | #define debug_trace(trace) \ 20 | fprintf(stdout, "%s ===File:%s----- Func:%s -----Line:%d===\n", \ 21 | trace, __FILE__, __func__, __LINE__) 22 | #else 23 | #define debug_trace(trace) 24 | #endif /* TRACE */ 25 | 26 | void error_exit(const char *fmt, ...); 27 | void unix_error_exit(const char *fmt, ...); 28 | void error_dump(const char *fmt, ...); 29 | void error_msg(const char *fmt, ...); 30 | void error_sys(const char *fmt, ...); 31 | 32 | void log_open(const char *ident, int option, int facility); 33 | void log_close(void); 34 | void log_sys(const char *fmt, ...); 35 | void log_msg(const char *fmt, ...); 36 | void log_quit(const char *fmt, ...); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/serialport.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyleft (C) 2010 Late Lee 3 | * This program is tested on LINUX PLATFORM, WITH GCC 4.x. 4 | * The program is distributed in the hope that it will be 5 | * useful, but WITHOUT ANY WARRANTY. Please feel free to 6 | * use the program, and I feel free to ignore the related 7 | * issues. Any questions or suggestions, or bugs, please 8 | * contact me at 9 | * <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d> 10 | * or e-mail to 11 | * <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d> 12 | * if you want to do this. 13 | * 14 | * @file serialport.h 15 | * @author Late Lee 16 | * @date Mon Jan 10 2011 17 | * 18 | * @brief Some utils of the serial port, such as open the port, close 19 | * the port and setup the port. 20 | */ 21 | 22 | #ifndef SERIALPORT_H 23 | #define SERIALPORT_H 24 | 25 | int open_port(const char* device); 26 | int close_port(int fd); 27 | int setup_port(int fd, int speed, int data_bits, int parity, int stop_bits); 28 | 29 | #endif /* SERIALPORT_H */ 30 | -------------------------------------------------------------------------------- /doc/serialport-html/tabs.css: -------------------------------------------------------------------------------- 1 | .tabs, .tabs2, .tabs3 { 2 | background-image: url('tab_b.png'); 3 | width: 100%; 4 | z-index: 101; 5 | font-size: 13px; 6 | font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; 7 | } 8 | 9 | .tabs2 { 10 | font-size: 10px; 11 | } 12 | .tabs3 { 13 | font-size: 9px; 14 | } 15 | 16 | .tablist { 17 | margin: 0; 18 | padding: 0; 19 | display: table; 20 | } 21 | 22 | .tablist li { 23 | float: left; 24 | display: table-cell; 25 | background-image: url('tab_b.png'); 26 | line-height: 36px; 27 | list-style: none; 28 | } 29 | 30 | .tablist a { 31 | display: block; 32 | padding: 0 20px; 33 | font-weight: bold; 34 | background-image:url('tab_s.png'); 35 | background-repeat:no-repeat; 36 | background-position:right; 37 | color: #283A5D; 38 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 39 | text-decoration: none; 40 | outline: none; 41 | } 42 | 43 | .tabs3 .tablist a { 44 | padding: 0 10px; 45 | } 46 | 47 | .tablist a:hover { 48 | background-image: url('tab_h.png'); 49 | background-repeat:repeat-x; 50 | color: #fff; 51 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 52 | text-decoration: none; 53 | } 54 | 55 | .tablist li.current a { 56 | background-image: url('tab_a.png'); 57 | background-repeat:repeat-x; 58 | color: #fff; 59 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 60 | } 61 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # (C) Copyleft 2011 3 | # Late Lee from http://www.latelee.org 4 | # 5 | # A simple Makefile for *ONE* project(c or/and cpp file) in *ONE* directory 6 | # 7 | # note: 8 | # you can put head file(s) in 'include' directory, so it looks 9 | # a little neat. 10 | # 11 | # usage: $ make 12 | # $ make debug=y 13 | ############################################################################### 14 | 15 | # cross compile... 16 | CROSS_COMPILE = 17 | 18 | CC = $(CROSS_COMPILE)gcc 19 | CXX = $(CROSS_COMPILE)g++ 20 | AR = $(CROSS_COMPILE)ar 21 | 22 | ARFLAGS = cr 23 | RM = -rm -rf 24 | MAKE = make 25 | 26 | CFLAGS = -Wall 27 | #debug = y 28 | 29 | ifeq ($(debug), y) 30 | CFLAGS += -g 31 | else 32 | CFLAGS += -O2 -s 33 | endif 34 | 35 | DEFS = 36 | 37 | CFLAGS += $(DEFS) 38 | 39 | LDFLAGS = $(LIBS) 40 | 41 | INCDIRS = ./ 42 | 43 | CFLAGS += -I$(INCDIRS) 44 | 45 | LDFLAGS += -lpthread 46 | 47 | # source file(s), including c file(s) cpp file(s) 48 | # you can also use $(wildcard *.c), etc. 49 | SRC_C := $(wildcard *.c) 50 | SRC_CPP := $(wildcard *.cpp) 51 | 52 | # object file(s) 53 | OBJ_C := $(patsubst %.c,%.o,$(SRC_C)) 54 | OBJ_CPP := $(patsubst %.cpp,%.o,$(SRC_CPP)) 55 | 56 | 57 | # executable file 58 | target = a.out 59 | 60 | ############################################################################### 61 | 62 | all: $(target) 63 | 64 | $(target): $(OBJ_C) $(OBJ_CPP) 65 | @echo "Generating executable file..." $(notdir $(target)) 66 | @$(CXX) $(CFLAGS) $^ -o $(target) $(LDFLAGS) 67 | 68 | # make all .c or .cpp 69 | %.o: %.c 70 | @echo "Compling: " $(addsuffix .c, $(basename $(notdir $@))) 71 | @$(CC) $(CFLAGS) -c $< -o $@ 72 | 73 | %.o: %.cpp 74 | @echo "Compling: " $(addsuffix .cpp, $(basename $(notdir $@))) 75 | @$(CXX) $(CFLAGS) -c $< -o $@ 76 | 77 | clean: 78 | @echo "cleaning..." 79 | @$(RM) $(target) 80 | @$(RM) *.o *.back *~ 81 | 82 | .PHONY: all clean 83 | -------------------------------------------------------------------------------- /doc/serialport-html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: Main Page 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 |
38 |
39 |
40 |
Serial Port Documentation
41 |
42 |
43 |
44 | 45 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /doc/serialport-html/serialport_8h-source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Serial Port: /my_workshop/serialport_linux/src/serialport.h Source File 4 | 5 | 6 | 7 |
Main Page | File List | File Members | Related Pages
8 |

/my_workshop/serialport_linux/src/serialport.h

Go to the documentation of this file.
00001 9 | 00022 #ifndef SERIALPORT_H 10 | 00023 #define SERIALPORT_H 11 | 00024 12 | 00025 int open_port(const char* device); 13 | 00026 int close_port(int fd); 14 | 00027 int setup_port(int fd, int speed, int data_bits, int parity, int stop_bits); 15 | 00028 16 | 00029 #endif /* SERIALPORT_H */ 17 |

Generated on Mon Apr 8 13:29:24 2013 for Serial Port by 18 | 19 | doxygen 1.3.8
20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/serialport-html/bug.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: Bug List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 |
38 |
39 |
40 |
Bug List
41 |
42 |
43 |
44 |
File serialport.c
45 |
This is a bug.
46 |
47 |
48 | 49 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /doc/serialport-html/todo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: Todo List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 |
38 |
39 |
40 |
Todo List
41 |
42 |
43 |
44 |
File serialport.c
45 |
To do something.
46 |
47 |
48 | 49 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /doc/serialport-html/pages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: Related Pages 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 |
38 |
39 |
40 |
Related Pages
41 |
42 |
43 |
Here is a list of all related documentation pages:
44 | 45 | 46 | 47 | 48 |
oTest List
oTodo List
\Bug List
49 |
50 |
51 | 52 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/error-log.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include /* exit */ 5 | #include /* str* */ 6 | #include /* errno */ 7 | #include /* va_* */ 8 | #include /* *log */ 9 | #include "error-log.h" 10 | 11 | static void error_doit(int errno_flag, const char *fmt, va_list ap) 12 | { 13 | int errno_save; 14 | char buf[MAXLINE]; 15 | 16 | errno_save = errno; 17 | vsprintf(buf, fmt, ap); 18 | if (errno_flag) 19 | sprintf(buf + strlen(buf), ": [%d]%s.", errno_save, 20 | strerror(errno_save)); 21 | strcat(buf, "\n"); 22 | fflush(stdout); 23 | fputs(buf, stderr); 24 | fflush(NULL); 25 | return; 26 | } 27 | 28 | void error_exit(const char *fmt, ...) 29 | { 30 | va_list ap; 31 | va_start(ap, fmt); 32 | error_doit(0, fmt, ap); 33 | va_end(ap); 34 | exit(1); 35 | } 36 | 37 | void unix_error_exit(const char *fmt, ...) 38 | { 39 | va_list ap; 40 | va_start(ap, fmt); 41 | error_doit(1, fmt, ap); 42 | va_end(ap); 43 | exit(1); 44 | } 45 | 46 | void error_dump(const char *fmt, ...) 47 | { 48 | va_list ap; 49 | va_start(ap, fmt); 50 | error_doit(1, fmt, ap); 51 | va_end(ap); 52 | abort(); 53 | exit(1); 54 | } 55 | 56 | void error_msg(const char *fmt, ...) 57 | { 58 | va_list ap; 59 | va_start(ap, fmt); 60 | error_doit(0, fmt, ap); 61 | va_end(ap); 62 | return; 63 | } 64 | 65 | void error_sys(const char *fmt, ...) 66 | { 67 | va_list ap; 68 | va_start(ap, fmt); 69 | error_doit(1, fmt, ap); 70 | va_end(ap); 71 | exit(1); 72 | } 73 | 74 | int debug = 1; 75 | /* daemon */ 76 | static void log_doit(int errno_flag, int priority, const char *fmt, va_list ap) 77 | { 78 | int errno_save; 79 | char buf[MAXLINE]; 80 | 81 | errno_save = errno; 82 | vsprintf(buf, fmt, ap); 83 | if (errno_flag) 84 | sprintf(buf+strlen(buf), ": [%d]%s.", errno_save, 85 | strerror(errno_save)); 86 | strcat(buf, "\n"); 87 | if (debug) 88 | { 89 | fflush(stdout); 90 | fputs(buf, stderr); 91 | fflush(stderr); 92 | } 93 | else 94 | syslog(priority, "%s", buf); /* fix gcc warning... */ 95 | return; 96 | } 97 | 98 | void log_open(const char *ident, int option, int facility) 99 | { 100 | if (debug == 0) 101 | open(ident, option, facility); 102 | return; 103 | } 104 | 105 | /* optional */ 106 | void log_close(void) 107 | { 108 | if (debug == 0) 109 | closelog(); 110 | } 111 | void log_sys(const char *fmt, ...) 112 | { 113 | va_list ap; 114 | va_start(ap, fmt); 115 | log_doit(1, LOG_ERR, fmt, ap); 116 | va_end(ap); 117 | exit(2); 118 | } 119 | 120 | void log_msg(const char *fmt, ...) 121 | { 122 | va_list ap; 123 | va_start(ap, fmt); 124 | log_doit(0, LOG_ERR, fmt, ap); 125 | va_end(ap); 126 | return; 127 | } 128 | 129 | void log_quit(const char *fmt, ...) 130 | { 131 | va_list ap; 132 | va_start(ap, fmt); 133 | log_doit(0, LOG_ERR, fmt, ap); 134 | va_end(ap); 135 | exit(2); 136 | } 137 | -------------------------------------------------------------------------------- /doc/serialport-html/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: Test List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 |
38 |
39 |
40 |
Test List
41 |
42 |
43 |
44 |
File debug-msg.h
45 |
I only use this file on linux(with x86 & arm) platform.
46 |
File main.c
47 |
To compile the program, type make , then it will generate the executable binary a.out. To run it, type ./a.out.Make sure you have the permission to open the serial port.
48 | You can start a ternimal and type minicom(also make sure you can open the device). When everything is OK, you can see the data in minicom using the same port if you connect pin 2 & pin 3 of the port (the male connector, see the picture below)(but I don't know the reason, isn't it blocked?).
49 | If you want to stop the program, just use 'Ctrl+c' or 'q'.
50 | In default, the program open the device '/dev/ttyUSB0'.
51 | Here are snapshots of the program:
52 |
53 |
54 | 55 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /doc/serialport-html/globals_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 51 |
52 |
53 |  
    54 |
  • buf 55 | : main.c 56 |
  • 57 |
  • exit_tid 58 | : main.c 59 |
  • 60 |
  • read_tid 61 | : main.c 62 |
  • 63 |
  • tmp 64 | : main.c 65 |
  • 66 |
  • write_tid 67 | : main.c 68 |
  • 69 |
70 |
71 | 72 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /doc/serialport-html/dynsections.js: -------------------------------------------------------------------------------- 1 | function toggleVisibility(linkObj) 2 | { 3 | var base = $(linkObj).attr('id'); 4 | var summary = $('#'+base+'-summary'); 5 | var content = $('#'+base+'-content'); 6 | var trigger = $('#'+base+'-trigger'); 7 | var src=$(trigger).attr('src'); 8 | if (content.is(':visible')===true) { 9 | content.hide(); 10 | summary.show(); 11 | $(linkObj).addClass('closed').removeClass('opened'); 12 | $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); 13 | } else { 14 | content.show(); 15 | summary.hide(); 16 | $(linkObj).removeClass('closed').addClass('opened'); 17 | $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); 18 | } 19 | return false; 20 | } 21 | 22 | function updateStripes() 23 | { 24 | $('table.directory tr'). 25 | removeClass('even').filter(':visible:even').addClass('even'); 26 | } 27 | function toggleLevel(level) 28 | { 29 | $('table.directory tr').each(function(){ 30 | var l = this.id.split('_').length-1; 31 | var i = $('#img'+this.id.substring(3)); 32 | var a = $('#arr'+this.id.substring(3)); 33 | if (l 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 51 |
52 |
53 |   82 |
83 | 84 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /doc/serialport-html/globals_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 51 |
52 |
53 |   82 |
83 | 84 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /doc/serialport-html/serialport_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/serialport.h Source File 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 |
serialport.h
51 |
52 |
53 | Go to the documentation of this file.
1 
54 |
22 #ifndef SERIALPORT_H
55 |
23 #define SERIALPORT_H
56 |
24 
57 |
25 int open_port(const char* device);
58 |
26 int close_port(int fd);
59 |
27 int setup_port(int fd, int speed, int data_bits, int parity, int stop_bits);
60 |
28 
61 |
29 #endif /* SERIALPORT_H */
62 |
63 | 64 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /doc/serialport-html/error-log_8h-source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Serial Port: /my_workshop/serialport_linux/src/error-log.h Source File 4 | 5 | 6 | 7 | 8 |

/my_workshop/serialport_linux/src/error-log.h

00001 #ifndef _ERROR_LOG_H 9 | 00002 #define _ERROR_LOG_H 10 | 00003 11 | 00004 #define MAXLINE 4096 12 | 00005 13 | 00006 extern int debug; 14 | 00007 15 | 00008 #define DEBUG 16 | 00009 #ifdef DEBUG 17 | 00010 #define debug_msg(fmt, ...) \ 18 | 00011 fprintf(stdout, fmt, ##__VA_ARGS__) 19 | 00012 #else 20 | 00013 #define debug_msg(fmt,...) 21 | 00014 #endif /* DEBUG */ 22 | 00015 23 | 00016 #define TRACE 24 | 00017 25 | 00018 #ifdef TRACE 26 | 00019 #define debug_trace(trace) \ 27 | 00020 fprintf(stdout, "%s ===File:%s----- Func:%s -----Line:%d===\n", \ 28 | 00021 trace, __FILE__, __func__, __LINE__) 29 | 00022 #else 30 | 00023 #define debug_trace(trace) 31 | 00024 #endif /* TRACE */ 32 | 00025 33 | 00026 void error_exit(const char *fmt, ...); 34 | 00027 void unix_error_exit(const char *fmt, ...); 35 | 00028 void error_dump(const char *fmt, ...); 36 | 00029 void error_msg(const char *fmt, ...); 37 | 00030 void error_sys(const char *fmt, ...); 38 | 00031 39 | 00032 void log_open(const char *ident, int option, int facility); 40 | 00033 void log_close(void); 41 | 00034 void log_sys(const char *fmt, ...); 42 | 00035 void log_msg(const char *fmt, ...); 43 | 00036 void log_quit(const char *fmt, ...); 44 | 00037 45 | 00038 #endif 46 |

Generated on Mon Apr 8 13:29:24 2013 for Serial Port by 47 | 48 | doxygen 1.3.8
49 | 50 | 51 | -------------------------------------------------------------------------------- /doc/serialport-html/dir_68267d1309a1af8e8297ef4c3efbcdba.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src Directory Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 41 |
42 |
43 |
44 |
src Directory Reference
45 |
46 |
47 | 48 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |

49 | Files

file  debug-msg.h [code]
 Some macros(debug, error handle) usually used in my programs.
 
file  error-log.c
 
file  error-log.h [code]
 
file  main.c
 A simple test of serial port writing data to the port.
 
file  serialport.c
 Some utils of the serial port, such as open the port, close the port and setup the port.
 
file  serialport.h [code]
 Some utils of the serial port, such as open the port, close the port and setup the port.
 
67 |
68 | 69 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /doc/serialport-html/files.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: File List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 |
44 |
45 |
46 |
File List
47 |
48 |
49 |
Here is a list of all documented files with brief descriptions:
50 |
[detail level 12]
51 | 52 | 53 | 54 | 55 | 56 | 57 |
\-src
 o*debug-msg.hSome macros(debug, error handle) usually used in my programs
 o*error-log.h
 o*main.cA simple test of serial port writing data to the port
 o*serialport.cSome utils of the serial port, such as open the port, close the port and setup the port
 \*serialport.hSome utils of the serial port, such as open the port, close the port and setup the port
58 |
59 |
60 | 61 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/debug-msg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * _/_/ _/_/_/_/ _/_/_/_/_/ 3 | * _/ _/ _/ _/ 4 | * _/ _/ _/ 5 | * _/ _/_/ _/ 6 | * _/ _/ _/ 7 | * _/ _/ _/ _/ _/ 8 | * _/_/_/ _/_/_/_/ _/_/_/ 9 | * Copyleft (C) 2010 Late Lee 10 | * This program is tested on LINUX PLATFORM, WITH GCC 4.x. 11 | * The program is distributed in the hope that it will be 12 | * useful, but WITHOUT ANY WARRANTY. Please feel free to 13 | * use the program, and I feel free to ignore the related 14 | * issues. Any questions or suggestions, or bugs, please 15 | * contact me at 16 | * <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d> 17 | * or e-mail to 18 | * <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d> 19 | * if you want to do this. 20 | * 21 | * @file debug-msg.h 22 | * @author Late Lee 23 | * @date 2010 24 | * @brief Some macros(debug, error handle) usually used in my programs. 25 | * 26 | * @test I only use this file on linux(with x86 & arm) platform. 27 | */ 28 | 29 | #ifndef _DEBUG_MSG_H 30 | #define _DEBUG_MSG_H 31 | 32 | #include /* perror() */ 33 | #include /* strerror() */ 34 | #include /* errno */ 35 | 36 | /*** 37 | * Print the error msg is one thing 38 | * but print the msg is another!! 39 | */ 40 | 41 | /** 42 | * @def error_exit 43 | * @brief A macro that prints the @a error msg and exit. 44 | */ 45 | 46 | #define error_exit(error) \ 47 | do{ \ 48 | fprintf(stderr, "%s\n", error); \ 49 | exit(0); \ 50 | } while(0) 51 | 52 | /** 53 | * @def error_ret 54 | * @brief A macro that prints the @a error msg and return -1. 55 | */ 56 | #define error_ret(error) \ 57 | do{ \ 58 | fprintf(stderr, "%s\n", error); \ 59 | return -1; \ 60 | } while(0) 61 | 62 | /** 63 | * @def unix_error_exit 64 | * @brief A macro that prints the @a error msg(with errno) and then exit. 65 | * I put 'unix' before the 'function' name because I am using 'errno'. 66 | */ 67 | #define unix_error_exit(error) \ 68 | do{ \ 69 | fprintf(stderr, "%s Info[%d]:%s\n", \ 70 | error, errno, strerror(errno)); \ 71 | exit(1); \ 72 | } while(0) 73 | 74 | /** 75 | * @def unix_error_ret 76 | * @brief A macro that prints the @a error msg(with errno) and then return -1. 77 | * I put 'unix' before the 'function' name because I am using 'errno'. 78 | */ 79 | #define unix_error_ret(error) \ 80 | do{ \ 81 | fprintf(stderr, "%s Info[%d]:%s\n", \ 82 | error, errno, strerror(errno)); \ 83 | return -1; \ 84 | } while(0) 85 | 86 | /* error handle ,detail version */ 87 | /* it can show the file,function and the line */ 88 | /** 89 | * @def unix_print_error 90 | * @brief A macro that prints the @a error msg(with errno) and then exit. 91 | * I put 'unix' before the 'function' name because I am using 'errno'.@n 92 | * This error handle(detail version) can show the @p file, @p function 93 | * and @p line where the @a error happens. 94 | * @note I do not often use this 'function' in my program. 95 | */ 96 | #define unix_print_error(error) \ 97 | do { \ 98 | fprintf(stderr, "Oh God!\nFile:%s Line:%d Function:%s:\n", \ 99 | __FILE__, __LINE__, __func__); \ 100 | perror(error); \ 101 | exit(0); \ 102 | } while(0) 103 | 104 | /* DEBUG=0 will show nothing */ 105 | #ifndef DEBUG 106 | #define DEBUG 1 /**< we debug all the time */ 107 | #endif 108 | 109 | /** 110 | * @def debug_msg 111 | * @brief A macro that prints the debug msg, as the same with @a printf. 112 | * 113 | */ 114 | #ifdef DEBUG 115 | #define debug_msg(fmt, ...) \ 116 | fprintf(stdout, fmt, ##__VA_ARGS__) 117 | #else 118 | #define debug_msg(fmt,...) 119 | #endif /* DEBUG */ 120 | 121 | #ifndef TRACE 122 | #define TRACE 1 /**< we trace all the time */ 123 | #endif 124 | 125 | /** 126 | * @def debug_trace 127 | * @brief A macro that traces the @p file, @p function and @p line. 128 | * 129 | */ 130 | #ifdef TRACE 131 | #define debug_trace(trace) \ 132 | fprintf(stdout, "%s File:%s Line:%d Func:%s.\n", \ 133 | trace, __FILE__, __LINE__, __func__) 134 | #else 135 | #define debug_trace(trace) 136 | #endif 137 | 138 | #endif /* _DEBUG_MSG_H */ 139 | -------------------------------------------------------------------------------- /doc/serialport-html/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 51 |
52 |
53 |
Here is a list of all documented file members with links to the documentation:
124 |
125 | 126 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyleft (C) 2010 Late Lee 3 | * This program is tested on LINUX PLATFORM, WITH GCC 4.x. 4 | * The program is distributed in the hope that it will be 5 | * useful, but WITHOUT ANY WARRANTY. Please feel free to 6 | * use the program, and I feel free to ignore the related 7 | * issues. Any questions or suggestions, or bugs, please 8 | * contact me at 9 | * <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d> 10 | * or e-mail to 11 | * <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d> 12 | * if you want to do this. 13 | * 14 | * @file main.c 15 | * @author Late Lee 16 | * @date Mon Jan 10 2011 17 | * 18 | * @brief A simple test of serial port writing data to the port. 19 | * @test To compile the program, type make , 20 | * then it will generate the executable binary @p a.out. 21 | * To run it, type ./a.out.Make sure you have the permission 22 | * to open the serial port.@n 23 | * You can start a ternimal and type @p minicom(also make sure you can 24 | * open the device). When everything is OK, you can see the data in 25 | * minicom using the same port if you connect pin 2 & pin 3 of the port 26 | * (the male connector, see the picture below)(but I don't know the 27 | * reason, isn't it blocked?).@n 28 | * If you want to stop the program, just use 'Ctrl+c' or 'q'. @n 29 | * In default, the program open the device '/dev/ttyUSB0'.@n 30 | * Here are snapshots of the program: 31 | * @image html serial-write.jpg "Writing to the port..." 32 | * @image html serial-read-minicom.jpg "Reading the data in minicom..." 33 | * @image html send_revc_self.jpg "One thread send, one thread read." 34 | * @n And here comes the serial port connector: 35 | * @image html com-male.jpg "A 9-pin male D-Sub connector(*)" 36 | * @image html com-female.jpg "A 9-pin female D-Sub connector" 37 | * (*)We use this connector in the test. 38 | * 39 | */ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | //#include "debug-msg.h" 48 | #include "serialport.h" 49 | #include "error-log.h" 50 | 51 | pthread_t write_tid; /**< write thread */ 52 | pthread_t read_tid; /**< read thread */ 53 | pthread_t exit_tid; /**< exit thread */ 54 | 55 | /** The data we write to the port. */ 56 | //char *buf = "Are you going to die?\r\n"; 57 | char *buf = "Are you going to die? To be or not to be, that is the question.\r\n"; 58 | /** data we receive */ 59 | char tmp[512]; 60 | 61 | /** 62 | * write_port_thread - A thread that writes data to the port 63 | * 64 | * @param argc : Here means the port(specified by the fd). 65 | * 66 | * @note 67 | * This is only a test, not the @e real one. 68 | */ 69 | void *write_port_thread(void *argc) 70 | { 71 | int ret; 72 | int fd; 73 | static int cnt = 1; 74 | char send_buf[512] = {0}; 75 | 76 | fd = (int)argc; 77 | 78 | while (1) 79 | { 80 | sprintf(send_buf, "%d %s", cnt, buf); 81 | debug_msg("writing time %d... ", cnt++); 82 | 83 | ret = write(fd, send_buf, strlen(send_buf)); 84 | 85 | if (ret < 0) 86 | pthread_exit(NULL); 87 | debug_msg("write num---: %d\n", ret); 88 | sleep(2); 89 | } 90 | pthread_exit(NULL); 91 | } 92 | 93 | /** 94 | * read_port_thread - Thread that reads data from the port 95 | * 96 | * @param argc : Here means the port(specified by the fd). 97 | * 98 | */ 99 | void *read_port_thread(void *argc) 100 | { 101 | int num; 102 | int fd; 103 | 104 | fd = (int)argc; 105 | while (1) 106 | { 107 | while ((num = read(fd, tmp, 512)) > 0) 108 | { 109 | debug_msg("read num: %d\n", num); 110 | tmp[num+1] = '\0'; 111 | printf("%s\n", tmp); 112 | } 113 | sleep(1); 114 | if (num < 0) 115 | pthread_exit(NULL); 116 | } 117 | pthread_exit(NULL); 118 | } 119 | 120 | /** 121 | * sig_handle - Handle the INT signal. 122 | * 123 | * @param sig_num : The signal. 124 | * @note 125 | * This function is not used. 126 | */ 127 | void sig_handle(int sig_num) 128 | { 129 | debug_msg("catch signal %d\n", sig_num); 130 | exit(0); 131 | } 132 | 133 | /** 134 | * exit_thread - Thread that exit the program when 'q' pressed 135 | * 136 | * @param argc : Here means the port(specified by the fd). 137 | * 138 | */ 139 | void* exit_thread(void* argc) 140 | { 141 | while (1) 142 | { 143 | int c = getchar(); 144 | if ('q' == c) 145 | { 146 | printf("You exit, not myself.\n"); 147 | exit(0); 148 | } 149 | sleep(1); 150 | } 151 | pthread_exit(NULL); 152 | } 153 | 154 | /** 155 | * main - main function 156 | * 157 | */ 158 | int main(int argc, char* argv[]) 159 | { 160 | int fd; 161 | int ret; 162 | char dev_name[32] = {0}; 163 | 164 | strcpy(dev_name, "/dev/ttyS0"); 165 | if (argc == 2) 166 | { 167 | sprintf(dev_name,"%s",argv[1]); 168 | } 169 | 170 | //signal(SIGINT, sig_handle); 171 | fd = open_port(dev_name); /* open the port */ 172 | if (fd < 0) 173 | { 174 | printf("open %s err\n",dev_name); 175 | exit(0); 176 | } 177 | 178 | ret = setup_port(fd, 115200, 8, 'N', 1); /* setup the port */ 179 | if (ret<0) 180 | exit(0); 181 | 182 | ret = pthread_create(&write_tid, NULL, write_port_thread, (void*)fd); 183 | if (ret < 0) 184 | unix_error_exit("Create write thread error."); 185 | 186 | ret = pthread_create(&read_tid, NULL, read_port_thread, (void*)fd); 187 | if (ret < 0) 188 | unix_error_exit("Create read thread error."); 189 | 190 | ret = pthread_create(&exit_tid, NULL, exit_thread, NULL); 191 | if (ret < 0) 192 | unix_error_exit("Create exit thread error."); 193 | 194 | pthread_join(write_tid, NULL); 195 | pthread_join(read_tid, NULL); 196 | pthread_join(exit_tid, NULL); 197 | 198 | close_port(fd); 199 | 200 | return 0; 201 | } 202 | -------------------------------------------------------------------------------- /doc/serialport-html/debug-msg_8h-source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Serial Port: /my_workshop/serialport_linux/src/debug-msg.h Source File 4 | 5 | 6 | 7 | 8 |

/my_workshop/serialport_linux/src/debug-msg.h

Go to the documentation of this file.
00001 9 | 00029 #ifndef _DEBUG_MSG_H 10 | 00030 #define _DEBUG_MSG_H 11 | 00031 12 | 00032 #include <stdio.h> /* perror() */ 13 | 00033 #include <string.h> /* strerror() */ 14 | 00034 #include <errno.h> /* errno */ 15 | 00035 16 | 00036 /*** 17 | 00037 * Print the error msg is one thing 18 | 00038 * but print the msg is another!! 19 | 00039 */ 20 | 00040 21 | 00046 #define error_exit(error) \ 22 | 00047 do{ \ 23 | 00048 fprintf(stderr, "%s\n", error); \ 24 | 00049 exit(0); \ 25 | 00050 } while(0) 26 | 00051 27 | 00056 #define error_ret(error) \ 28 | 00057 do{ \ 29 | 00058 fprintf(stderr, "%s\n", error); \ 30 | 00059 return -1; \ 31 | 00060 } while(0) 32 | 00061 33 | 00067 #define unix_error_exit(error) \ 34 | 00068 do{ \ 35 | 00069 fprintf(stderr, "%s Info[%d]:%s\n", \ 36 | 00070 error, errno, strerror(errno)); \ 37 | 00071 exit(1); \ 38 | 00072 } while(0) 39 | 00073 40 | 00079 #define unix_error_ret(error) \ 41 | 00080 do{ \ 42 | 00081 fprintf(stderr, "%s Info[%d]:%s\n", \ 43 | 00082 error, errno, strerror(errno)); \ 44 | 00083 return -1; \ 45 | 00084 } while(0) 46 | 00085 47 | 00086 /* error handle ,detail version */ 48 | 00087 /* it can show the file,function and the line */ 49 | 00096 #define unix_print_error(error) \ 50 | 00097 do { \ 51 | 00098 fprintf(stderr, "Oh God!\nFile:%s Line:%d Function:%s:\n", \ 52 | 00099 __FILE__, __LINE__, __func__); \ 53 | 00100 perror(error); \ 54 | 00101 exit(0); \ 55 | 00102 } while(0) 56 | 00103 57 | 00104 /* DEBUG=0 will show nothing */ 58 | 00105 #ifndef DEBUG 59 | 00106 #define DEBUG 1 60 | 00107 #endif 61 | 00108 62 | 00114 #ifdef DEBUG 63 | 00115 #define debug_msg(fmt, ...) \ 64 | 00116 fprintf(stdout, fmt, ##__VA_ARGS__) 65 | 00117 #else 66 | 00118 #define debug_msg(fmt,...) 67 | 00119 #endif /* DEBUG */ 68 | 00120 69 | 00121 #ifndef TRACE 70 | 00122 #define TRACE 1 71 | 00123 #endif 72 | 00124 73 | 00130 #ifdef TRACE 74 | 00131 #define debug_trace(trace) \ 75 | 00132 fprintf(stdout, "%s File:%s Line:%d Func:%s.\n", \ 76 | 00133 trace, __FILE__, __LINE__, __func__) 77 | 00134 #else 78 | 00135 #define debug_trace(trace) 79 | 00136 #endif 80 | 00137 81 | 00138 #endif /* _DEBUG_MSG_H */ 82 |

Generated on Mon Apr 8 13:29:24 2013 for Serial Port by 83 | 84 | doxygen 1.3.8
85 | 86 | 87 | -------------------------------------------------------------------------------- /doc/serialport-html/error-log_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/error-log.h Source File 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 |
error-log.h
51 |
52 |
53 |
1 #ifndef _ERROR_LOG_H
54 |
2 #define _ERROR_LOG_H
55 |
3 
56 |
4 #define MAXLINE 4096
57 |
5 
58 |
6 extern int debug;
59 |
7 
60 |
8 #define DEBUG
61 |
9 #ifdef DEBUG
62 |
10 #define debug_msg(fmt, ...) \
63 |
11  fprintf(stdout, fmt, ##__VA_ARGS__)
64 |
12 #else
65 |
13 #define debug_msg(fmt,...)
66 |
14 #endif /* DEBUG */
67 |
15 
68 |
16 #define TRACE
69 |
17 
70 |
18 #ifdef TRACE
71 |
19 #define debug_trace(trace) \
72 |
20  fprintf(stdout, "%s ===File:%s----- Func:%s -----Line:%d===\n", \
73 |
21  trace, __FILE__, __func__, __LINE__)
74 |
22 #else
75 |
23 #define debug_trace(trace)
76 |
24 #endif /* TRACE */
77 |
25 
78 |
26 void error_exit(const char *fmt, ...);
79 |
27 void unix_error_exit(const char *fmt, ...);
80 |
28 void error_dump(const char *fmt, ...);
81 |
29 void error_msg(const char *fmt, ...);
82 |
30 void error_sys(const char *fmt, ...);
83 |
31 
84 |
32 void log_open(const char *ident, int option, int facility);
85 |
33 void log_close(void);
86 |
34 void log_sys(const char *fmt, ...);
87 |
35 void log_msg(const char *fmt, ...);
88 |
36 void log_quit(const char *fmt, ...);
89 |
37 
90 |
38 #endif
91 |
92 | 93 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /doc/Doxyfile: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.5.9 2 | 3 | #--------------------------------------------------------------------------- 4 | # Project related configuration options 5 | #--------------------------------------------------------------------------- 6 | DOXYFILE_ENCODING = UTF-8 7 | PROJECT_NAME = "Serial Port" 8 | PROJECT_NUMBER = "1.1 beta" 9 | OUTPUT_DIRECTORY = serialport-html 10 | CREATE_SUBDIRS = NO 11 | OUTPUT_LANGUAGE = English 12 | BRIEF_MEMBER_DESC = YES 13 | REPEAT_BRIEF = YES 14 | ABBREVIATE_BRIEF = 15 | ALWAYS_DETAILED_SEC = NO 16 | INLINE_INHERITED_MEMB = NO 17 | FULL_PATH_NAMES = YES 18 | STRIP_FROM_PATH = 19 | STRIP_FROM_INC_PATH = 20 | SHORT_NAMES = NO 21 | JAVADOC_AUTOBRIEF = NO 22 | QT_AUTOBRIEF = NO 23 | MULTILINE_CPP_IS_BRIEF = NO 24 | INHERIT_DOCS = YES 25 | SEPARATE_MEMBER_PAGES = NO 26 | TAB_SIZE = 8 27 | ALIASES = 28 | OPTIMIZE_OUTPUT_FOR_C = NO 29 | OPTIMIZE_OUTPUT_JAVA = NO 30 | OPTIMIZE_FOR_FORTRAN = NO 31 | OPTIMIZE_OUTPUT_VHDL = NO 32 | EXTENSION_MAPPING = 33 | BUILTIN_STL_SUPPORT = NO 34 | CPP_CLI_SUPPORT = NO 35 | SIP_SUPPORT = NO 36 | IDL_PROPERTY_SUPPORT = YES 37 | DISTRIBUTE_GROUP_DOC = NO 38 | SUBGROUPING = YES 39 | TYPEDEF_HIDES_STRUCT = NO 40 | SYMBOL_CACHE_SIZE = 0 41 | #--------------------------------------------------------------------------- 42 | # Build related configuration options 43 | #--------------------------------------------------------------------------- 44 | EXTRACT_ALL = NO 45 | EXTRACT_PRIVATE = NO 46 | EXTRACT_STATIC = NO 47 | EXTRACT_LOCAL_CLASSES = YES 48 | EXTRACT_LOCAL_METHODS = NO 49 | EXTRACT_ANON_NSPACES = NO 50 | HIDE_UNDOC_MEMBERS = NO 51 | HIDE_UNDOC_CLASSES = NO 52 | HIDE_FRIEND_COMPOUNDS = NO 53 | HIDE_IN_BODY_DOCS = NO 54 | INTERNAL_DOCS = NO 55 | CASE_SENSE_NAMES = YES 56 | HIDE_SCOPE_NAMES = NO 57 | SHOW_INCLUDE_FILES = YES 58 | INLINE_INFO = YES 59 | SORT_MEMBER_DOCS = YES 60 | SORT_BRIEF_DOCS = NO 61 | SORT_GROUP_NAMES = NO 62 | SORT_BY_SCOPE_NAME = NO 63 | GENERATE_TODOLIST = YES 64 | GENERATE_TESTLIST = YES 65 | GENERATE_BUGLIST = YES 66 | GENERATE_DEPRECATEDLIST= YES 67 | ENABLED_SECTIONS = 68 | MAX_INITIALIZER_LINES = 30 69 | SHOW_USED_FILES = YES 70 | SHOW_DIRECTORIES = NO 71 | SHOW_FILES = YES 72 | SHOW_NAMESPACES = YES 73 | FILE_VERSION_FILTER = 74 | LAYOUT_FILE = 75 | #--------------------------------------------------------------------------- 76 | # configuration options related to warning and progress messages 77 | #--------------------------------------------------------------------------- 78 | QUIET = NO 79 | WARNINGS = YES 80 | WARN_IF_UNDOCUMENTED = YES 81 | WARN_IF_DOC_ERROR = YES 82 | WARN_NO_PARAMDOC = NO 83 | WARN_FORMAT = "$file:$line: $text" 84 | WARN_LOGFILE = 85 | #--------------------------------------------------------------------------- 86 | # configuration options related to the input files 87 | #--------------------------------------------------------------------------- 88 | INPUT = ../src 89 | INPUT_ENCODING = UTF-8 90 | FILE_PATTERNS = *.c *.h 91 | RECURSIVE = NO 92 | EXCLUDE = 93 | EXCLUDE_SYMLINKS = NO 94 | EXCLUDE_PATTERNS = 95 | EXCLUDE_SYMBOLS = 96 | EXAMPLE_PATH = 97 | EXAMPLE_PATTERNS = 98 | EXAMPLE_RECURSIVE = NO 99 | IMAGE_PATH = image_dir 100 | INPUT_FILTER = 101 | FILTER_PATTERNS = 102 | FILTER_SOURCE_FILES = NO 103 | #--------------------------------------------------------------------------- 104 | # configuration options related to source browsing 105 | #--------------------------------------------------------------------------- 106 | SOURCE_BROWSER = NO 107 | INLINE_SOURCES = NO 108 | STRIP_CODE_COMMENTS = YES 109 | REFERENCED_BY_RELATION = NO 110 | REFERENCES_RELATION = NO 111 | REFERENCES_LINK_SOURCE = YES 112 | USE_HTAGS = NO 113 | VERBATIM_HEADERS = YES 114 | #--------------------------------------------------------------------------- 115 | # configuration options related to the alphabetical class index 116 | #--------------------------------------------------------------------------- 117 | ALPHABETICAL_INDEX = NO 118 | COLS_IN_ALPHA_INDEX = 5 119 | IGNORE_PREFIX = 120 | #--------------------------------------------------------------------------- 121 | # configuration options related to the HTML output 122 | #--------------------------------------------------------------------------- 123 | GENERATE_HTML = YES 124 | HTML_OUTPUT = . 125 | HTML_FILE_EXTENSION = .html 126 | HTML_HEADER = 127 | HTML_FOOTER = 128 | HTML_STYLESHEET = 129 | HTML_ALIGN_MEMBERS = YES 130 | HTML_DYNAMIC_SECTIONS = NO 131 | GENERATE_DOCSET = NO 132 | DOCSET_FEEDNAME = "Doxygen generated docs" 133 | DOCSET_BUNDLE_ID = org.doxygen.Project 134 | GENERATE_HTMLHELP = NO 135 | CHM_FILE = 136 | HHC_LOCATION = 137 | GENERATE_CHI = NO 138 | CHM_INDEX_ENCODING = 139 | BINARY_TOC = NO 140 | TOC_EXPAND = NO 141 | GENERATE_QHP = NO 142 | QCH_FILE = 143 | QHP_NAMESPACE = 144 | QHP_VIRTUAL_FOLDER = doc 145 | QHP_CUST_FILTER_NAME = 146 | QHP_CUST_FILTER_ATTRS = 147 | QHP_SECT_FILTER_ATTRS = 148 | QHG_LOCATION = 149 | DISABLE_INDEX = NO 150 | ENUM_VALUES_PER_LINE = 4 151 | GENERATE_TREEVIEW = NONE 152 | TREEVIEW_WIDTH = 250 153 | FORMULA_FONTSIZE = 10 154 | #--------------------------------------------------------------------------- 155 | # configuration options related to the LaTeX output 156 | #--------------------------------------------------------------------------- 157 | GENERATE_LATEX = NO 158 | LATEX_OUTPUT = latex 159 | LATEX_CMD_NAME = latex 160 | MAKEINDEX_CMD_NAME = makeindex 161 | COMPACT_LATEX = NO 162 | PAPER_TYPE = a4wide 163 | EXTRA_PACKAGES = 164 | LATEX_HEADER = 165 | PDF_HYPERLINKS = YES 166 | USE_PDFLATEX = YES 167 | LATEX_BATCHMODE = NO 168 | LATEX_HIDE_INDICES = NO 169 | LATEX_SOURCE_CODE = NO 170 | #--------------------------------------------------------------------------- 171 | # configuration options related to the RTF output 172 | #--------------------------------------------------------------------------- 173 | GENERATE_RTF = NO 174 | RTF_OUTPUT = rtf 175 | COMPACT_RTF = NO 176 | RTF_HYPERLINKS = NO 177 | RTF_STYLESHEET_FILE = 178 | RTF_EXTENSIONS_FILE = 179 | #--------------------------------------------------------------------------- 180 | # configuration options related to the man page output 181 | #--------------------------------------------------------------------------- 182 | GENERATE_MAN = NO 183 | MAN_OUTPUT = man 184 | MAN_EXTENSION = .3 185 | MAN_LINKS = NO 186 | #--------------------------------------------------------------------------- 187 | # configuration options related to the XML output 188 | #--------------------------------------------------------------------------- 189 | GENERATE_XML = NO 190 | XML_OUTPUT = xml 191 | XML_SCHEMA = 192 | XML_DTD = 193 | XML_PROGRAMLISTING = YES 194 | #--------------------------------------------------------------------------- 195 | # configuration options for the AutoGen Definitions output 196 | #--------------------------------------------------------------------------- 197 | GENERATE_AUTOGEN_DEF = NO 198 | #--------------------------------------------------------------------------- 199 | # configuration options related to the Perl module output 200 | #--------------------------------------------------------------------------- 201 | GENERATE_PERLMOD = NO 202 | PERLMOD_LATEX = NO 203 | PERLMOD_PRETTY = YES 204 | PERLMOD_MAKEVAR_PREFIX = 205 | #--------------------------------------------------------------------------- 206 | # Configuration options related to the preprocessor 207 | #--------------------------------------------------------------------------- 208 | ENABLE_PREPROCESSING = YES 209 | MACRO_EXPANSION = NO 210 | EXPAND_ONLY_PREDEF = NO 211 | SEARCH_INCLUDES = YES 212 | INCLUDE_PATH = 213 | INCLUDE_FILE_PATTERNS = 214 | PREDEFINED = 215 | EXPAND_AS_DEFINED = 216 | SKIP_FUNCTION_MACROS = YES 217 | #--------------------------------------------------------------------------- 218 | # Configuration::additions related to external references 219 | #--------------------------------------------------------------------------- 220 | TAGFILES = 221 | GENERATE_TAGFILE = 222 | ALLEXTERNALS = NO 223 | EXTERNAL_GROUPS = YES 224 | PERL_PATH = /usr/bin/perl 225 | #--------------------------------------------------------------------------- 226 | # Configuration options related to the dot tool 227 | #--------------------------------------------------------------------------- 228 | CLASS_DIAGRAMS = YES 229 | MSCGEN_PATH = 230 | HIDE_UNDOC_RELATIONS = YES 231 | HAVE_DOT = NO 232 | DOT_FONTNAME = FreeSans 233 | DOT_FONTSIZE = 10 234 | DOT_FONTPATH = 235 | CLASS_GRAPH = YES 236 | COLLABORATION_GRAPH = YES 237 | GROUP_GRAPHS = YES 238 | UML_LOOK = NO 239 | TEMPLATE_RELATIONS = NO 240 | INCLUDE_GRAPH = YES 241 | INCLUDED_BY_GRAPH = YES 242 | CALL_GRAPH = NO 243 | CALLER_GRAPH = NO 244 | GRAPHICAL_HIERARCHY = YES 245 | DIRECTORY_GRAPH = YES 246 | DOT_IMAGE_FORMAT = png 247 | DOT_PATH = 248 | DOTFILE_DIRS = 249 | DOT_GRAPH_MAX_NODES = 50 250 | MAX_DOT_GRAPH_DEPTH = 0 251 | DOT_TRANSPARENT = NO 252 | DOT_MULTI_TARGETS = NO 253 | GENERATE_LEGEND = YES 254 | DOT_CLEANUP = YES 255 | #--------------------------------------------------------------------------- 256 | # Options related to the search engine 257 | #--------------------------------------------------------------------------- 258 | SEARCHENGINE = NO 259 | -------------------------------------------------------------------------------- /doc/serialport-html/serialport_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/serialport.h File Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 | Functions
51 |
52 |
serialport.h File Reference
53 |
54 |
55 | 56 |

Some utils of the serial port, such as open the port, close the port and setup the port. 57 | More...

58 | 59 |

Go to the source code of this file.

60 | 61 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |

62 | Functions

int open_port (const char *device)
 
int close_port (int fd)
 
int setup_port (int fd, int speed, int data_bits, int parity, int stop_bits)
 
70 |

Detailed Description

71 |

Some utils of the serial port, such as open the port, close the port and setup the port.

72 |
                 Copyleft (C) 2010  Late Lee
 73 |    This program is tested on LINUX PLATFORM, WITH GCC 4.x.
 74 |    The program is distributed in the hope that it will be
 75 |    useful, but WITHOUT ANY WARRANTY. Please feel free to 
 76 |    use the program, and I feel free to ignore the related
 77 |    issues. Any questions or suggestions, or bugs, please 
 78 |    contact me at
 79 |    <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d>
 80 |    or e-mail to 
 81 |    <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d>
 82 |    if you want to do this.
 83 | 
Author
Late Lee
84 |
Date
Mon Jan 10 2011
85 |

Function Documentation

86 | 87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
int close_port (int fd)
98 |
99 |

close_port - Close the port

100 |
Parameters
101 | 102 | 103 |
fd: The file description returned by open_port().
104 |
105 |
106 |
Returns
Return 0 if success, return -1 with some msg if error happens.
107 | 108 |
109 |
110 | 111 |
112 |
113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 |
int open_port (const char * device)
122 |
123 |

open_port - Open a serial port

124 |
Parameters
125 | 126 | 127 |
device[in] : The serial port device name, eg, /dev/ttyS0
128 |
129 |
130 |
Returns
Return fd if success, otherwise will return -1 with some msg.
131 |
Note
Each serial port on a UNIX system has one or more device files (files in the /dev directory) associated with it:
132 |
System         Port 1      Port 2
133 | IRIX          /dev/ttyf1   /dev/ttyf2
134 | HP-UX         /dev/tty1p0  /dev/tty2p0
135 | Solaris/SunOS /dev/ttya    /dev/ttyb
136 | Linux         /dev/ttyS0   /dev/ttyS1
137 | Linux         /dev/ttyUSB0 /dev/ttyUSB1 (usb-serial converter)
138 | Digital UNIX  /dev/tty01   /dev/tty02
139 | (Windows       COM1        COM2)
140 | 

We open the port specified by device name, for instance, if you want to open port 1, you just call the function like this: open_port("/dev/ttyS0").

141 | 142 |
143 |
144 | 145 |
146 |
147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 |
int setup_port (int fd,
int speed,
int data_bits,
int parity,
int stop_bits 
)
184 |
185 |

setup_port - Configure the port, eg. baud rate, data bits,etc.

186 |
Parameters
187 | 188 | 189 | 190 | 191 | 192 | 193 |
fd: The serial port
speed: The baud rate
data_bits: The data bits
parity: The parity bits
stop_bits: The stop bits
194 |
195 |
196 |
Returns
Return 0 if everything is OK, otherwise -1 with some error msg.
197 |
Note
Here are termios structure members:
198 |
Member      Description 
199 | c_cflag     Control options 
200 | c_lflag     Line options 
201 | c_iflag     Input options 
202 | c_oflag     Output options 
203 | c_cc        Control characters 
204 | c_ispeed    Input baud (new interface) 
205 | c_ospeed    Output baud (new interface) 

The c_cflag member controls the baud rate, number of data bits, parity, stop bits, and hardware flow control. There are constants for all of the supported configurations. Constant Description

206 |
CBAUD   Bit mask for baud rate 
207 | B0      0 baud (drop DTR) 
208 | B50     50 baud 
209 | B75     75 baud 
210 | B110    110 baud 
211 | B134    134.5 baud 
212 | B150    150 baud 
213 | B200    200 baud 
214 | B300    300 baud 
215 | B600    600 baud 
216 | B1200   1200 baud 
217 | B1800   1800 baud 
218 | B2400   2400 baud 
219 | B4800   4800 baud 
220 | B9600   9600 baud 
221 | B19200  19200 baud 
222 | B38400  38400 baud 
223 | B57600  57,600 baud 
224 | B76800  76,800 baud 
225 | B115200 115,200 baud 
226 | EXTA    External rate clock 
227 | EXTB    External rate clock 
228 | CSIZE   Bit mask for data bits 
229 | CS5 5   data bits 
230 | CS6 6   data bits 
231 | CS7 7   data bits 
232 | CS8 8   data bits 
233 | CSTOPB  2 stop bits (1 otherwise) 
234 | CREAD   Enable receiver 
235 | PARENB  Enable parity bit 
236 | PARODD  Use odd parity instead of even 
237 | HUPCL   Hangup (drop DTR) on last close 
238 | CLOCAL  Local line - do not change "owner" of port 
239 | LOBLK   Block job control output 
240 | CNEW_RTSCTS CRTSCTS     Enable hardware flow control (not supported on all 
241 |                         platforms) 

The input modes member c_iflag controls any input processing that is done to characters received on the port. Like the c_cflag field, the final value stored in c_iflag is the bitwise OR of the desired options.

242 |
Constant        Description 
243 | INPCK   Enable parity check 
244 | IGNPAR  Ignore parity errors 
245 | PARMRK  Mark parity errors 
246 | ISTRIP  Strip parity bits 
247 | IXON    Enable software flow control (outgoing) 
248 | IXOFF   Enable software flow control (incoming) 
249 | IXANY   Allow any character to start flow again 
250 | IGNBRK  Ignore break condition 
251 | BRKINT  Send a SIGINT when a break condition is detected 
252 | INLCR   Map NL to CR 
253 | IGNCR   Ignore CR 
254 | ICRNL   Map CR to NL 
255 | IUCLC   Map uppercase to lowercase 
256 | IMAXBEL Echo BEL on input line too long 
257 | 

Here are some examples of setting parity checking:
258 |

259 |

No parity (8N1):

260 |
options.c_cflag &= ~PARENB
261 | options.c_cflag &= ~CSTOPB
262 | options.c_cflag &= ~CSIZE;
263 | options.c_cflag |= CS8;
264 | 

Even parity (7E1):

265 |
options.c_cflag |= PARENB
266 | options.c_cflag &= ~PARODD
267 | options.c_cflag &= ~CSTOPB
268 | options.c_cflag &= ~CSIZE;
269 | options.c_cflag |= CS7;
270 | 

Odd parity (7O1):

271 |
options.c_cflag |= PARENB
272 | options.c_cflag |= PARODD
273 | options.c_cflag &= ~CSTOPB
274 | options.c_cflag &= ~CSIZE;
275 | options.c_cflag |= CS7;
276 | 
277 |
278 |
279 |
280 | 281 | 286 | 287 | 288 | -------------------------------------------------------------------------------- /doc/serialport-html/serialport_8c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/serialport.c File Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 | Functions
51 |
52 |
serialport.c File Reference
53 |
54 |
55 | 56 |

Some utils of the serial port, such as open the port, close the port and setup the port. 57 | More...

58 |
#include <stdio.h>
59 | #include <stdlib.h>
60 | #include <string.h>
61 | #include <unistd.h>
62 | #include <fcntl.h>
63 | #include <termios.h>
64 | #include "error-log.h"
65 |
66 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |

67 | Functions

int open_port (const char *device)
 
int close_port (int fd)
 
int setup_port (int fd, int speed, int data_bits, int parity, int stop_bits)
 
75 |

Detailed Description

76 |

Some utils of the serial port, such as open the port, close the port and setup the port.

77 |
                 Copyleft (C) 2010  Late Lee
 78 |    This program is tested on LINUX PLATFORM, WITH GCC 4.x.
 79 |    The program is distributed in the hope that it will be
 80 |    useful, but WITHOUT ANY WARRANTY. Please feel free to 
 81 |    use the program, and I feel free to ignore the related
 82 |    issues. Any questions or suggestions, or bugs, please 
 83 |    contact me at
 84 |    <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d>
 85 |    or e-mail to 
 86 |    <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d>
 87 |    if you want to do this.
 88 | 
Author
Late Lee
89 |
Date
Mon Jan 10 2011
90 |
Note
This is a note.
91 |
Warning
This is a warning.
92 |
Bug:
This is a bug.
93 |
Todo:
To do something.
94 |

Function Documentation

95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 |
int close_port (int fd)
107 |
108 |

close_port - Close the port

109 |
Parameters
110 | 111 | 112 |
fd: The file description returned by open_port().
113 |
114 |
115 |
Returns
Return 0 if success, return -1 with some msg if error happens.
116 | 117 |
118 |
119 | 120 |
121 |
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 |
int open_port (const char * device)
131 |
132 |

open_port - Open a serial port

133 |
Parameters
134 | 135 | 136 |
device[in] : The serial port device name, eg, /dev/ttyS0
137 |
138 |
139 |
Returns
Return fd if success, otherwise will return -1 with some msg.
140 |
Note
Each serial port on a UNIX system has one or more device files (files in the /dev directory) associated with it:
141 |
System         Port 1      Port 2
142 | IRIX          /dev/ttyf1   /dev/ttyf2
143 | HP-UX         /dev/tty1p0  /dev/tty2p0
144 | Solaris/SunOS /dev/ttya    /dev/ttyb
145 | Linux         /dev/ttyS0   /dev/ttyS1
146 | Linux         /dev/ttyUSB0 /dev/ttyUSB1 (usb-serial converter)
147 | Digital UNIX  /dev/tty01   /dev/tty02
148 | (Windows       COM1        COM2)
149 | 

We open the port specified by device name, for instance, if you want to open port 1, you just call the function like this: open_port("/dev/ttyS0").

150 | 151 |
152 |
153 | 154 |
155 |
156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 |
int setup_port (int fd,
int speed,
int data_bits,
int parity,
int stop_bits 
)
193 |
194 |

setup_port - Configure the port, eg. baud rate, data bits,etc.

195 |
Parameters
196 | 197 | 198 | 199 | 200 | 201 | 202 |
fd: The serial port
speed: The baud rate
data_bits: The data bits
parity: The parity bits
stop_bits: The stop bits
203 |
204 |
205 |
Returns
Return 0 if everything is OK, otherwise -1 with some error msg.
206 |
Note
Here are termios structure members:
207 |
Member      Description 
208 | c_cflag     Control options 
209 | c_lflag     Line options 
210 | c_iflag     Input options 
211 | c_oflag     Output options 
212 | c_cc        Control characters 
213 | c_ispeed    Input baud (new interface) 
214 | c_ospeed    Output baud (new interface) 

The c_cflag member controls the baud rate, number of data bits, parity, stop bits, and hardware flow control. There are constants for all of the supported configurations. Constant Description

215 |
CBAUD   Bit mask for baud rate 
216 | B0      0 baud (drop DTR) 
217 | B50     50 baud 
218 | B75     75 baud 
219 | B110    110 baud 
220 | B134    134.5 baud 
221 | B150    150 baud 
222 | B200    200 baud 
223 | B300    300 baud 
224 | B600    600 baud 
225 | B1200   1200 baud 
226 | B1800   1800 baud 
227 | B2400   2400 baud 
228 | B4800   4800 baud 
229 | B9600   9600 baud 
230 | B19200  19200 baud 
231 | B38400  38400 baud 
232 | B57600  57,600 baud 
233 | B76800  76,800 baud 
234 | B115200 115,200 baud 
235 | EXTA    External rate clock 
236 | EXTB    External rate clock 
237 | CSIZE   Bit mask for data bits 
238 | CS5 5   data bits 
239 | CS6 6   data bits 
240 | CS7 7   data bits 
241 | CS8 8   data bits 
242 | CSTOPB  2 stop bits (1 otherwise) 
243 | CREAD   Enable receiver 
244 | PARENB  Enable parity bit 
245 | PARODD  Use odd parity instead of even 
246 | HUPCL   Hangup (drop DTR) on last close 
247 | CLOCAL  Local line - do not change "owner" of port 
248 | LOBLK   Block job control output 
249 | CNEW_RTSCTS CRTSCTS     Enable hardware flow control (not supported on all 
250 |                         platforms) 

The input modes member c_iflag controls any input processing that is done to characters received on the port. Like the c_cflag field, the final value stored in c_iflag is the bitwise OR of the desired options.

251 |
Constant        Description 
252 | INPCK   Enable parity check 
253 | IGNPAR  Ignore parity errors 
254 | PARMRK  Mark parity errors 
255 | ISTRIP  Strip parity bits 
256 | IXON    Enable software flow control (outgoing) 
257 | IXOFF   Enable software flow control (incoming) 
258 | IXANY   Allow any character to start flow again 
259 | IGNBRK  Ignore break condition 
260 | BRKINT  Send a SIGINT when a break condition is detected 
261 | INLCR   Map NL to CR 
262 | IGNCR   Ignore CR 
263 | ICRNL   Map CR to NL 
264 | IUCLC   Map uppercase to lowercase 
265 | IMAXBEL Echo BEL on input line too long 
266 | 

Here are some examples of setting parity checking:
267 |

268 |

No parity (8N1):

269 |
options.c_cflag &= ~PARENB
270 | options.c_cflag &= ~CSTOPB
271 | options.c_cflag &= ~CSIZE;
272 | options.c_cflag |= CS8;
273 | 

Even parity (7E1):

274 |
options.c_cflag |= PARENB
275 | options.c_cflag &= ~PARODD
276 | options.c_cflag &= ~CSTOPB
277 | options.c_cflag &= ~CSIZE;
278 | options.c_cflag |= CS7;
279 | 

Odd parity (7O1):

280 |
options.c_cflag |= PARENB
281 | options.c_cflag |= PARODD
282 | options.c_cflag &= ~CSTOPB
283 | options.c_cflag &= ~CSIZE;
284 | options.c_cflag |= CS7;
285 | 
286 |
287 |
288 |
289 | 290 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /doc/serialport-html/debug-msg_8h_source.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/debug-msg.h Source File 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 |
debug-msg.h
51 |
52 |
53 | Go to the documentation of this file.
1 
54 |
29 #ifndef _DEBUG_MSG_H
55 |
30 #define _DEBUG_MSG_H
56 |
31 
57 |
32 #include <stdio.h> /* perror() */
58 |
33 #include <string.h> /* strerror() */
59 |
34 #include <errno.h> /* errno */
60 |
35 
61 |
36 /***
62 |
37  * Print the error msg is one thing
63 |
38  * but print the msg is another!!
64 |
39  */
65 |
40 
66 |
46 #define error_exit(error) \
67 |
47  do{ \
68 |
48  fprintf(stderr, "%s\n", error); \
69 |
49  exit(0); \
70 |
50  } while(0)
71 |
51 
72 |
56 #define error_ret(error) \
73 |
57  do{ \
74 |
58  fprintf(stderr, "%s\n", error); \
75 |
59  return -1; \
76 |
60  } while(0)
77 |
61 
78 |
67 #define unix_error_exit(error) \
79 |
68  do{ \
80 |
69  fprintf(stderr, "%s Info[%d]:%s\n", \
81 |
70  error, errno, strerror(errno)); \
82 |
71  exit(1); \
83 |
72  } while(0)
84 |
73 
85 |
79 #define unix_error_ret(error) \
86 |
80  do{ \
87 |
81  fprintf(stderr, "%s Info[%d]:%s\n", \
88 |
82  error, errno, strerror(errno)); \
89 |
83  return -1; \
90 |
84  } while(0)
91 |
85 
92 |
86 /* error handle ,detail version */
93 |
87 /* it can show the file,function and the line */
94 |
96 #define unix_print_error(error) \
95 |
97  do { \
96 |
98  fprintf(stderr, "Oh God!\nFile:%s Line:%d Function:%s:\n", \
97 |
99  __FILE__, __LINE__, __func__); \
98 |
100  perror(error); \
99 |
101  exit(0); \
100 |
102  } while(0)
101 |
103 
102 |
104 /* DEBUG=0 will show nothing */
103 |
105 #ifndef DEBUG
104 |
106 #define DEBUG 1
105 |
107 #endif
106 |
108 
107 |
114 #ifdef DEBUG
108 |
115 #define debug_msg(fmt, ...) \
109 |
116  fprintf(stdout, fmt, ##__VA_ARGS__)
110 |
117 #else
111 |
118 #define debug_msg(fmt,...)
112 |
119 #endif /* DEBUG */
113 |
120 
114 |
121 #ifndef TRACE
115 |
122 #define TRACE 1
116 |
123 #endif
117 |
124 
118 |
130 #ifdef TRACE
119 |
131 #define debug_trace(trace) \
120 |
132  fprintf(stdout, "%s File:%s Line:%d Func:%s.\n", \
121 |
133  trace, __FILE__, __LINE__, __func__)
122 |
134 #else
123 |
135 #define debug_trace(trace)
124 |
136 #endif
125 |
137 
126 |
138 #endif /* _DEBUG_MSG_H */
127 |
128 | 129 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /doc/serialport-html/main_8c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/main.c File Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 | Functions | 51 | Variables
52 |
53 |
main.c File Reference
54 |
55 |
56 | 57 |

A simple test of serial port writing data to the port. 58 | More...

59 |
#include <stdio.h>
60 | #include <stdlib.h>
61 | #include <string.h>
62 | #include <unistd.h>
63 | #include <pthread.h>
64 | #include <signal.h>
65 | #include "serialport.h"
66 | #include "error-log.h"
67 |
68 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |

69 | Functions

void * write_port_thread (void *argc)
 
void * read_port_thread (void *argc)
 
void sig_handle (int sig_num)
 
void * exit_thread (void *argc)
 
int main (void)
 
81 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |

82 | Variables

pthread_t write_tid
 
pthread_t read_tid
 
pthread_t exit_tid
 
char * buf = "Are you going to die? To be or not to be, that is the question.\r\n"
 
char tmp [512]
 
94 |

Detailed Description

95 |

A simple test of serial port writing data to the port.

96 |
                 Copyleft (C) 2010  Late Lee
 97 |    This program is tested on LINUX PLATFORM, WITH GCC 4.x.
 98 |    The program is distributed in the hope that it will be
 99 |    useful, but WITHOUT ANY WARRANTY. Please feel free to 
100 |    use the program, and I feel free to ignore the related
101 |    issues. Any questions or suggestions, or bugs, please 
102 |    contact me at
103 |    <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d>
104 |    or e-mail to 
105 |    <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d>
106 |    if you want to do this.
107 | 
Author
Late Lee
108 |
Date
Mon Jan 10 2011
109 |
Test:
To compile the program, type make , then it will generate the executable binary a.out. To run it, type ./a.out.Make sure you have the permission to open the serial port.
110 | You can start a ternimal and type minicom(also make sure you can open the device). When everything is OK, you can see the data in minicom using the same port if you connect pin 2 & pin 3 of the port (the male connector, see the picture below)(but I don't know the reason, isn't it blocked?).
111 | If you want to stop the program, just use 'Ctrl+c' or 'q'.
112 | In default, the program open the device '/dev/ttyUSB0'.
113 | Here are snapshots of the program:
114 |
115 | serial-write.jpg 116 |
117 | Writing to the port...
118 |
119 | serial-read-minicom.jpg 120 |
121 | Reading the data in minicom...
122 |
123 | send_revc_self.jpg 124 |
125 | One thread send, one thread read.
126 |


127 | And here comes the serial port connector:

128 |
129 | com-male.jpg 130 |
131 | A 9-pin male D-Sub connector(*)
132 |
133 | com-female.jpg 134 |
135 | A 9-pin female D-Sub connector
136 |

(*)We use this connector in the test.

137 |

Function Documentation

138 | 139 |
140 |
141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
void* exit_thread (void * argc)
150 |
151 |

exit_thread - Thread that exit the program when 'q' pressed

152 |
Parameters
153 | 154 | 155 |
argc: Here means the port(specified by the fd).
156 |
157 |
158 | 159 |
160 |
161 | 162 |
163 |
164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 |
int main (void )
173 |
174 |

main - main function

175 | 176 |
177 |
178 | 179 |
180 |
181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 |
void* read_port_thread (void * argc)
190 |
191 |

read_port_thread - Thread that reads data from the port

192 |
Parameters
193 | 194 | 195 |
argc: Here means the port(specified by the fd).
196 |
197 |
198 | 199 |
200 |
201 | 202 |
203 |
204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 |
void sig_handle (int sig_num)
213 |
214 |

sig_handle - Handle the INT signal.

215 |
Parameters
216 | 217 | 218 |
sig_num: The signal.
219 |
220 |
221 |
Note
This function is not used.
222 | 223 |
224 |
225 | 226 |
227 |
228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 |
void* write_port_thread (void * argc)
237 |
238 |

write_port_thread - A thread that writes data to the port

239 |
Parameters
240 | 241 | 242 |
argc: Here means the port(specified by the fd).
243 |
244 |
245 |
Note
This is only a test, not the real one.
246 | 247 |
248 |
249 |

Variable Documentation

250 | 251 |
252 |
253 | 254 | 255 | 256 | 257 |
char* buf = "Are you going to die? To be or not to be, that is the question.\r\n"
258 |
259 |

The data we write to the port.

260 | 261 |
262 |
263 | 264 |
265 |
266 | 267 | 268 | 269 | 270 |
pthread_t exit_tid
271 |
272 |

exit thread

273 | 274 |
275 |
276 | 277 |
278 |
279 | 280 | 281 | 282 | 283 |
pthread_t read_tid
284 |
285 |

read thread

286 | 287 |
288 |
289 | 290 |
291 |
292 | 293 | 294 | 295 | 296 |
char tmp[512]
297 |
298 |

data we receive

299 | 300 |
301 |
302 | 303 |
304 |
305 | 306 | 307 | 308 | 309 |
pthread_t write_tid
310 |
311 |

write thread

312 | 313 |
314 |
315 |
316 | 317 | 322 | 323 | 324 | -------------------------------------------------------------------------------- /doc/serialport-html/debug-msg_8h.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serial Port: X:/serialport_linux/src/debug-msg.h File Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 24 | 25 | 26 |
20 |
Serial Port 21 |  1.1 beta 22 |
23 |
27 |
28 | 29 | 30 | 37 | 43 | 47 |
48 |
49 |
50 | Macros
51 |
52 |
debug-msg.h File Reference
53 |
54 |
55 | 56 |

Some macros(debug, error handle) usually used in my programs. 57 | More...

58 |
#include <stdio.h>
59 | #include <string.h>
60 | #include <errno.h>
61 |
62 |

Go to the source code of this file.

63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 81 | 82 | 83 | 84 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |

65 | Macros

#define error_exit(error)
 A macro that prints the error msg and exit. More...
 
#define error_ret(error)
 A macro that prints the error msg and return -1. More...
 
#define unix_error_exit(error)
 A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'. More...
 
#define unix_error_ret(error)
 A macro that prints the error msg(with errno) and then return -1. I put 'unix' before the 'function' name because I am using 'errno'. More...
 
#define unix_print_error(error)
 A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'.
80 | This error handle(detail version) can show the file, function and line where the error happens. More...
 
#define DEBUG   1
 
85 | #define debug_msg(fmt,...)   fprintf(stdout, fmt, ##__VA_ARGS__)
 A macro that prints the debug msg, as the same with printf.
 
#define TRACE   1
 
#define debug_trace(trace)
 A macro that traces the file, function and line. More...
 
94 |

Detailed Description

95 |

Some macros(debug, error handle) usually used in my programs.

96 |
                      _/_/     _/_/_/_/   _/_/_/_/_/
 97 |                    _/    _/  _/              _/
 98 |                   _/         _/             _/
 99 |                  _/            _/_/        _/
100 |                 _/                 _/     _/
101 |                 _/    _/    _/     _/    _/
102 |                 _/_/_/      _/_/_/_/  _/_/_/
103 |                  Copyleft (C) 2010  Late Lee
104 |    This program is tested on LINUX PLATFORM, WITH GCC 4.x.
105 |    The program is distributed in the hope that it will be
106 |    useful, but WITHOUT ANY WARRANTY. Please feel free to 
107 |    use the program, and I feel free to ignore the related
108 |    issues. Any questions or suggestions, or bugs, please 
109 |    contact me at
110 |    <$ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d>
111 |    or e-mail to 
112 |    <$ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d>
113 |    if you want to do this.
114 | 
Author
Late Lee
115 |
Date
2010
116 |
Test:
I only use this file on linux(with x86 & arm) platform.
117 |

Macro Definition Documentation

118 | 119 |
120 |
121 | 122 | 123 | 124 | 125 |
#define DEBUG   1
126 |
127 |

we debug all the time

128 | 129 |
130 |
131 | 132 |
133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 |
#define debug_trace( trace)
143 |
144 | Value:
fprintf(stdout, "%s File:%s Line:%d Func:%s.\n", \
145 |
trace, __FILE__, __LINE__, __func__)
146 |
147 |

A macro that traces the file, function and line.

148 | 149 |
150 |
151 | 152 |
153 |
154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 |
#define error_exit( error)
163 |
164 | Value:
do{ \
165 |
fprintf(stderr, "%s\n", error); \
166 |
exit(0); \
167 |
} while(0)
168 |
169 |

A macro that prints the error msg and exit.

170 | 171 |
172 |
173 | 174 |
175 |
176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 |
#define error_ret( error)
185 |
186 | Value:
do{ \
187 |
fprintf(stderr, "%s\n", error); \
188 |
return -1; \
189 |
} while(0)
190 |
191 |

A macro that prints the error msg and return -1.

192 | 193 |
194 |
195 | 196 |
197 |
198 | 199 | 200 | 201 | 202 |
#define TRACE   1
203 |
204 |

we trace all the time

205 | 206 |
207 |
208 | 209 |
210 |
211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 |
#define unix_error_exit( error)
220 |
221 | Value:
do{ \
222 |
fprintf(stderr, "%s Info[%d]:%s\n", \
223 |
error, errno, strerror(errno)); \
224 |
exit(1); \
225 |
} while(0)
226 |
227 |

A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'.

228 | 229 |
230 |
231 | 232 |
233 |
234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 |
#define unix_error_ret( error)
243 |
244 | Value:
do{ \
245 |
fprintf(stderr, "%s Info[%d]:%s\n", \
246 |
error, errno, strerror(errno)); \
247 |
return -1; \
248 |
} while(0)
249 |
250 |

A macro that prints the error msg(with errno) and then return -1. I put 'unix' before the 'function' name because I am using 'errno'.

251 | 252 |
253 |
254 | 255 |
256 |
257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 |
#define unix_print_error( error)
266 |
267 | Value:
do { \
268 |
fprintf(stderr, "Oh God!\nFile:%s Line:%d Function:%s:\n", \
269 |
__FILE__, __LINE__, __func__); \
270 |
perror(error); \
271 |
exit(0); \
272 |
} while(0)
273 |
274 |

A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'.
275 | This error handle(detail version) can show the file, function and line where the error happens.

276 |
Note
I do not often use this 'function' in my program.
277 | 278 |
279 |
280 |
281 | 282 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /doc/serialport-html/doxygen.css: -------------------------------------------------------------------------------- 1 | /* The standard CSS for doxygen 1.8.3.1 */ 2 | 3 | body, table, div, p, dl { 4 | font: 400 14px/19px Roboto,sans-serif; 5 | } 6 | 7 | /* @group Heading Levels */ 8 | 9 | h1.groupheader { 10 | font-size: 150%; 11 | } 12 | 13 | .title { 14 | font-size: 150%; 15 | font-weight: bold; 16 | margin: 10px 2px; 17 | } 18 | 19 | h2.groupheader { 20 | border-bottom: 1px solid #879ECB; 21 | color: #354C7B; 22 | font-size: 150%; 23 | font-weight: normal; 24 | margin-top: 1.75em; 25 | padding-top: 8px; 26 | padding-bottom: 4px; 27 | width: 100%; 28 | } 29 | 30 | h3.groupheader { 31 | font-size: 100%; 32 | } 33 | 34 | h1, h2, h3, h4, h5, h6 { 35 | -webkit-transition: text-shadow 0.5s linear; 36 | -moz-transition: text-shadow 0.5s linear; 37 | -ms-transition: text-shadow 0.5s linear; 38 | -o-transition: text-shadow 0.5s linear; 39 | transition: text-shadow 0.5s linear; 40 | margin-right: 15px; 41 | } 42 | 43 | h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { 44 | text-shadow: 0 0 15px cyan; 45 | } 46 | 47 | dt { 48 | font-weight: bold; 49 | } 50 | 51 | div.multicol { 52 | -moz-column-gap: 1em; 53 | -webkit-column-gap: 1em; 54 | -moz-column-count: 3; 55 | -webkit-column-count: 3; 56 | } 57 | 58 | p.startli, p.startdd, p.starttd { 59 | margin-top: 2px; 60 | } 61 | 62 | p.endli { 63 | margin-bottom: 0px; 64 | } 65 | 66 | p.enddd { 67 | margin-bottom: 4px; 68 | } 69 | 70 | p.endtd { 71 | margin-bottom: 2px; 72 | } 73 | 74 | /* @end */ 75 | 76 | caption { 77 | font-weight: bold; 78 | } 79 | 80 | span.legend { 81 | font-size: 70%; 82 | text-align: center; 83 | } 84 | 85 | h3.version { 86 | font-size: 90%; 87 | text-align: center; 88 | } 89 | 90 | div.qindex, div.navtab{ 91 | background-color: #EBEFF6; 92 | border: 1px solid #A3B4D7; 93 | text-align: center; 94 | } 95 | 96 | div.qindex, div.navpath { 97 | width: 100%; 98 | line-height: 140%; 99 | } 100 | 101 | div.navtab { 102 | margin-right: 15px; 103 | } 104 | 105 | /* @group Link Styling */ 106 | 107 | a { 108 | color: #3D578C; 109 | font-weight: normal; 110 | text-decoration: none; 111 | } 112 | 113 | .contents a:visited { 114 | color: #4665A2; 115 | } 116 | 117 | a:hover { 118 | text-decoration: underline; 119 | } 120 | 121 | a.qindex { 122 | font-weight: bold; 123 | } 124 | 125 | a.qindexHL { 126 | font-weight: bold; 127 | background-color: #9CAFD4; 128 | color: #ffffff; 129 | border: 1px double #869DCA; 130 | } 131 | 132 | .contents a.qindexHL:visited { 133 | color: #ffffff; 134 | } 135 | 136 | a.el { 137 | font-weight: bold; 138 | } 139 | 140 | a.elRef { 141 | } 142 | 143 | a.code, a.code:visited { 144 | color: #4665A2; 145 | } 146 | 147 | a.codeRef, a.codeRef:visited { 148 | color: #4665A2; 149 | } 150 | 151 | /* @end */ 152 | 153 | dl.el { 154 | margin-left: -1cm; 155 | } 156 | 157 | pre.fragment { 158 | border: 1px solid #C4CFE5; 159 | background-color: #FBFCFD; 160 | padding: 4px 6px; 161 | margin: 4px 8px 4px 2px; 162 | overflow: auto; 163 | word-wrap: break-word; 164 | font-size: 9pt; 165 | line-height: 125%; 166 | font-family: monospace, fixed; 167 | font-size: 105%; 168 | } 169 | 170 | div.fragment { 171 | padding: 4px; 172 | margin: 4px; 173 | background-color: #FBFCFD; 174 | border: 1px solid #C4CFE5; 175 | } 176 | 177 | div.line { 178 | font-family: monospace, fixed; 179 | font-size: 13px; 180 | min-height: 13px; 181 | line-height: 1.0; 182 | text-wrap: unrestricted; 183 | white-space: -moz-pre-wrap; /* Moz */ 184 | white-space: -pre-wrap; /* Opera 4-6 */ 185 | white-space: -o-pre-wrap; /* Opera 7 */ 186 | white-space: pre-wrap; /* CSS3 */ 187 | word-wrap: break-word; /* IE 5.5+ */ 188 | text-indent: -53px; 189 | padding-left: 53px; 190 | padding-bottom: 0px; 191 | margin: 0px; 192 | -webkit-transition-property: background-color, box-shadow; 193 | -webkit-transition-duration: 0.5s; 194 | -moz-transition-property: background-color, box-shadow; 195 | -moz-transition-duration: 0.5s; 196 | -ms-transition-property: background-color, box-shadow; 197 | -ms-transition-duration: 0.5s; 198 | -o-transition-property: background-color, box-shadow; 199 | -o-transition-duration: 0.5s; 200 | transition-property: background-color, box-shadow; 201 | transition-duration: 0.5s; 202 | } 203 | 204 | div.line.glow { 205 | background-color: cyan; 206 | box-shadow: 0 0 10px cyan; 207 | } 208 | 209 | 210 | span.lineno { 211 | padding-right: 4px; 212 | text-align: right; 213 | border-right: 2px solid #0F0; 214 | background-color: #E8E8E8; 215 | white-space: pre; 216 | } 217 | span.lineno a { 218 | background-color: #D8D8D8; 219 | } 220 | 221 | span.lineno a:hover { 222 | background-color: #C8C8C8; 223 | } 224 | 225 | div.ah { 226 | background-color: black; 227 | font-weight: bold; 228 | color: #ffffff; 229 | margin-bottom: 3px; 230 | margin-top: 3px; 231 | padding: 0.2em; 232 | border: solid thin #333; 233 | border-radius: 0.5em; 234 | -webkit-border-radius: .5em; 235 | -moz-border-radius: .5em; 236 | box-shadow: 2px 2px 3px #999; 237 | -webkit-box-shadow: 2px 2px 3px #999; 238 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; 239 | background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); 240 | background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); 241 | } 242 | 243 | div.groupHeader { 244 | margin-left: 16px; 245 | margin-top: 12px; 246 | font-weight: bold; 247 | } 248 | 249 | div.groupText { 250 | margin-left: 16px; 251 | font-style: italic; 252 | } 253 | 254 | body { 255 | background-color: white; 256 | color: black; 257 | margin: 0; 258 | } 259 | 260 | div.contents { 261 | margin-top: 10px; 262 | margin-left: 12px; 263 | margin-right: 8px; 264 | } 265 | 266 | td.indexkey { 267 | background-color: #EBEFF6; 268 | font-weight: bold; 269 | border: 1px solid #C4CFE5; 270 | margin: 2px 0px 2px 0; 271 | padding: 2px 10px; 272 | white-space: nowrap; 273 | vertical-align: top; 274 | } 275 | 276 | td.indexvalue { 277 | background-color: #EBEFF6; 278 | border: 1px solid #C4CFE5; 279 | padding: 2px 10px; 280 | margin: 2px 0px; 281 | } 282 | 283 | tr.memlist { 284 | background-color: #EEF1F7; 285 | } 286 | 287 | p.formulaDsp { 288 | text-align: center; 289 | } 290 | 291 | img.formulaDsp { 292 | 293 | } 294 | 295 | img.formulaInl { 296 | vertical-align: middle; 297 | } 298 | 299 | div.center { 300 | text-align: center; 301 | margin-top: 0px; 302 | margin-bottom: 0px; 303 | padding: 0px; 304 | } 305 | 306 | div.center img { 307 | border: 0px; 308 | } 309 | 310 | address.footer { 311 | text-align: right; 312 | padding-right: 12px; 313 | } 314 | 315 | img.footer { 316 | border: 0px; 317 | vertical-align: middle; 318 | } 319 | 320 | /* @group Code Colorization */ 321 | 322 | span.keyword { 323 | color: #008000 324 | } 325 | 326 | span.keywordtype { 327 | color: #604020 328 | } 329 | 330 | span.keywordflow { 331 | color: #e08000 332 | } 333 | 334 | span.comment { 335 | color: #800000 336 | } 337 | 338 | span.preprocessor { 339 | color: #806020 340 | } 341 | 342 | span.stringliteral { 343 | color: #002080 344 | } 345 | 346 | span.charliteral { 347 | color: #008080 348 | } 349 | 350 | span.vhdldigit { 351 | color: #ff00ff 352 | } 353 | 354 | span.vhdlchar { 355 | color: #000000 356 | } 357 | 358 | span.vhdlkeyword { 359 | color: #700070 360 | } 361 | 362 | span.vhdllogic { 363 | color: #ff0000 364 | } 365 | 366 | blockquote { 367 | background-color: #F7F8FB; 368 | border-left: 2px solid #9CAFD4; 369 | margin: 0 24px 0 4px; 370 | padding: 0 12px 0 16px; 371 | } 372 | 373 | /* @end */ 374 | 375 | /* 376 | .search { 377 | color: #003399; 378 | font-weight: bold; 379 | } 380 | 381 | form.search { 382 | margin-bottom: 0px; 383 | margin-top: 0px; 384 | } 385 | 386 | input.search { 387 | font-size: 75%; 388 | color: #000080; 389 | font-weight: normal; 390 | background-color: #e8eef2; 391 | } 392 | */ 393 | 394 | td.tiny { 395 | font-size: 75%; 396 | } 397 | 398 | .dirtab { 399 | padding: 4px; 400 | border-collapse: collapse; 401 | border: 1px solid #A3B4D7; 402 | } 403 | 404 | th.dirtab { 405 | background: #EBEFF6; 406 | font-weight: bold; 407 | } 408 | 409 | hr { 410 | height: 0px; 411 | border: none; 412 | border-top: 1px solid #4A6AAA; 413 | } 414 | 415 | hr.footer { 416 | height: 1px; 417 | } 418 | 419 | /* @group Member Descriptions */ 420 | 421 | table.memberdecls { 422 | border-spacing: 0px; 423 | padding: 0px; 424 | } 425 | 426 | .memberdecls td, .fieldtable tr { 427 | -webkit-transition-property: background-color, box-shadow; 428 | -webkit-transition-duration: 0.5s; 429 | -moz-transition-property: background-color, box-shadow; 430 | -moz-transition-duration: 0.5s; 431 | -ms-transition-property: background-color, box-shadow; 432 | -ms-transition-duration: 0.5s; 433 | -o-transition-property: background-color, box-shadow; 434 | -o-transition-duration: 0.5s; 435 | transition-property: background-color, box-shadow; 436 | transition-duration: 0.5s; 437 | } 438 | 439 | .memberdecls td.glow, .fieldtable tr.glow { 440 | background-color: cyan; 441 | box-shadow: 0 0 15px cyan; 442 | } 443 | 444 | .mdescLeft, .mdescRight, 445 | .memItemLeft, .memItemRight, 446 | .memTemplItemLeft, .memTemplItemRight, .memTemplParams { 447 | background-color: #F9FAFC; 448 | border: none; 449 | margin: 4px; 450 | padding: 1px 0 0 8px; 451 | } 452 | 453 | .mdescLeft, .mdescRight { 454 | padding: 0px 8px 4px 8px; 455 | color: #555; 456 | } 457 | 458 | .memSeparator { 459 | border-bottom: 1px solid #DEE4F0; 460 | line-height: 1px; 461 | margin: 0px; 462 | padding: 0px; 463 | } 464 | 465 | .memItemLeft, .memTemplItemLeft { 466 | white-space: nowrap; 467 | } 468 | 469 | .memItemRight { 470 | width: 100%; 471 | } 472 | 473 | .memTemplParams { 474 | color: #4665A2; 475 | white-space: nowrap; 476 | font-size: 80%; 477 | } 478 | 479 | /* @end */ 480 | 481 | /* @group Member Details */ 482 | 483 | /* Styles for detailed member documentation */ 484 | 485 | .memtemplate { 486 | font-size: 80%; 487 | color: #4665A2; 488 | font-weight: normal; 489 | margin-left: 9px; 490 | } 491 | 492 | .memnav { 493 | background-color: #EBEFF6; 494 | border: 1px solid #A3B4D7; 495 | text-align: center; 496 | margin: 2px; 497 | margin-right: 15px; 498 | padding: 2px; 499 | } 500 | 501 | .mempage { 502 | width: 100%; 503 | } 504 | 505 | .memitem { 506 | padding: 0; 507 | margin-bottom: 10px; 508 | margin-right: 5px; 509 | -webkit-transition: box-shadow 0.5s linear; 510 | -moz-transition: box-shadow 0.5s linear; 511 | -ms-transition: box-shadow 0.5s linear; 512 | -o-transition: box-shadow 0.5s linear; 513 | transition: box-shadow 0.5s linear; 514 | display: table !important; 515 | width: 100%; 516 | } 517 | 518 | .memitem.glow { 519 | box-shadow: 0 0 15px cyan; 520 | } 521 | 522 | .memname { 523 | font-weight: bold; 524 | margin-left: 6px; 525 | } 526 | 527 | .memname td { 528 | vertical-align: bottom; 529 | } 530 | 531 | .memproto, dl.reflist dt { 532 | border-top: 1px solid #A8B8D9; 533 | border-left: 1px solid #A8B8D9; 534 | border-right: 1px solid #A8B8D9; 535 | padding: 6px 0px 6px 0px; 536 | color: #253555; 537 | font-weight: bold; 538 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 539 | background-image:url('nav_f.png'); 540 | background-repeat:repeat-x; 541 | background-color: #E2E8F2; 542 | /* opera specific markup */ 543 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 544 | border-top-right-radius: 4px; 545 | border-top-left-radius: 4px; 546 | /* firefox specific markup */ 547 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; 548 | -moz-border-radius-topright: 4px; 549 | -moz-border-radius-topleft: 4px; 550 | /* webkit specific markup */ 551 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 552 | -webkit-border-top-right-radius: 4px; 553 | -webkit-border-top-left-radius: 4px; 554 | 555 | } 556 | 557 | .memdoc, dl.reflist dd { 558 | border-bottom: 1px solid #A8B8D9; 559 | border-left: 1px solid #A8B8D9; 560 | border-right: 1px solid #A8B8D9; 561 | padding: 6px 10px 2px 10px; 562 | background-color: #FBFCFD; 563 | border-top-width: 0; 564 | background-image:url('nav_g.png'); 565 | background-repeat:repeat-x; 566 | background-color: #FFFFFF; 567 | /* opera specific markup */ 568 | border-bottom-left-radius: 4px; 569 | border-bottom-right-radius: 4px; 570 | box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 571 | /* firefox specific markup */ 572 | -moz-border-radius-bottomleft: 4px; 573 | -moz-border-radius-bottomright: 4px; 574 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; 575 | /* webkit specific markup */ 576 | -webkit-border-bottom-left-radius: 4px; 577 | -webkit-border-bottom-right-radius: 4px; 578 | -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); 579 | } 580 | 581 | dl.reflist dt { 582 | padding: 5px; 583 | } 584 | 585 | dl.reflist dd { 586 | margin: 0px 0px 10px 0px; 587 | padding: 5px; 588 | } 589 | 590 | .paramkey { 591 | text-align: right; 592 | } 593 | 594 | .paramtype { 595 | white-space: nowrap; 596 | } 597 | 598 | .paramname { 599 | color: #602020; 600 | white-space: nowrap; 601 | } 602 | .paramname em { 603 | font-style: normal; 604 | } 605 | .paramname code { 606 | line-height: 14px; 607 | } 608 | 609 | .params, .retval, .exception, .tparams { 610 | margin-left: 0px; 611 | padding-left: 0px; 612 | } 613 | 614 | .params .paramname, .retval .paramname { 615 | font-weight: bold; 616 | vertical-align: top; 617 | } 618 | 619 | .params .paramtype { 620 | font-style: italic; 621 | vertical-align: top; 622 | } 623 | 624 | .params .paramdir { 625 | font-family: "courier new",courier,monospace; 626 | vertical-align: top; 627 | } 628 | 629 | table.mlabels { 630 | border-spacing: 0px; 631 | } 632 | 633 | td.mlabels-left { 634 | width: 100%; 635 | padding: 0px; 636 | } 637 | 638 | td.mlabels-right { 639 | vertical-align: bottom; 640 | padding: 0px; 641 | white-space: nowrap; 642 | } 643 | 644 | span.mlabels { 645 | margin-left: 8px; 646 | } 647 | 648 | span.mlabel { 649 | background-color: #728DC1; 650 | border-top:1px solid #5373B4; 651 | border-left:1px solid #5373B4; 652 | border-right:1px solid #C4CFE5; 653 | border-bottom:1px solid #C4CFE5; 654 | text-shadow: none; 655 | color: white; 656 | margin-right: 4px; 657 | padding: 2px 3px; 658 | border-radius: 3px; 659 | font-size: 7pt; 660 | white-space: nowrap; 661 | vertical-align: middle; 662 | } 663 | 664 | 665 | 666 | /* @end */ 667 | 668 | /* these are for tree view when not used as main index */ 669 | 670 | div.directory { 671 | margin: 10px 0px; 672 | border-top: 1px solid #A8B8D9; 673 | border-bottom: 1px solid #A8B8D9; 674 | width: 100%; 675 | } 676 | 677 | .directory table { 678 | border-collapse:collapse; 679 | } 680 | 681 | .directory td { 682 | margin: 0px; 683 | padding: 0px; 684 | vertical-align: top; 685 | } 686 | 687 | .directory td.entry { 688 | white-space: nowrap; 689 | padding-right: 6px; 690 | } 691 | 692 | .directory td.entry a { 693 | outline:none; 694 | } 695 | 696 | .directory td.entry a img { 697 | border: none; 698 | } 699 | 700 | .directory td.desc { 701 | width: 100%; 702 | padding-left: 6px; 703 | padding-right: 6px; 704 | padding-top: 3px; 705 | border-left: 1px solid rgba(0,0,0,0.05); 706 | } 707 | 708 | .directory tr.even { 709 | padding-left: 6px; 710 | background-color: #F7F8FB; 711 | } 712 | 713 | .directory img { 714 | vertical-align: -30%; 715 | } 716 | 717 | .directory .levels { 718 | white-space: nowrap; 719 | width: 100%; 720 | text-align: right; 721 | font-size: 9pt; 722 | } 723 | 724 | .directory .levels span { 725 | cursor: pointer; 726 | padding-left: 2px; 727 | padding-right: 2px; 728 | color: #3D578C; 729 | } 730 | 731 | div.dynheader { 732 | margin-top: 8px; 733 | -webkit-touch-callout: none; 734 | -webkit-user-select: none; 735 | -khtml-user-select: none; 736 | -moz-user-select: none; 737 | -ms-user-select: none; 738 | user-select: none; 739 | } 740 | 741 | address { 742 | font-style: normal; 743 | color: #2A3D61; 744 | } 745 | 746 | table.doxtable { 747 | border-collapse:collapse; 748 | margin-top: 4px; 749 | margin-bottom: 4px; 750 | } 751 | 752 | table.doxtable td, table.doxtable th { 753 | border: 1px solid #2D4068; 754 | padding: 3px 7px 2px; 755 | } 756 | 757 | table.doxtable th { 758 | background-color: #374F7F; 759 | color: #FFFFFF; 760 | font-size: 110%; 761 | padding-bottom: 4px; 762 | padding-top: 5px; 763 | } 764 | 765 | table.fieldtable { 766 | /*width: 100%;*/ 767 | margin-bottom: 10px; 768 | border: 1px solid #A8B8D9; 769 | border-spacing: 0px; 770 | -moz-border-radius: 4px; 771 | -webkit-border-radius: 4px; 772 | border-radius: 4px; 773 | -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; 774 | -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); 775 | box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); 776 | } 777 | 778 | .fieldtable td, .fieldtable th { 779 | padding: 3px 7px 2px; 780 | } 781 | 782 | .fieldtable td.fieldtype, .fieldtable td.fieldname { 783 | white-space: nowrap; 784 | border-right: 1px solid #A8B8D9; 785 | border-bottom: 1px solid #A8B8D9; 786 | vertical-align: top; 787 | } 788 | 789 | .fieldtable td.fieldname { 790 | padding-top: 5px; 791 | } 792 | 793 | .fieldtable td.fielddoc { 794 | border-bottom: 1px solid #A8B8D9; 795 | /*width: 100%;*/ 796 | } 797 | 798 | .fieldtable td.fielddoc p:first-child { 799 | margin-top: 2px; 800 | } 801 | 802 | .fieldtable td.fielddoc p:last-child { 803 | margin-bottom: 2px; 804 | } 805 | 806 | .fieldtable tr:last-child td { 807 | border-bottom: none; 808 | } 809 | 810 | .fieldtable th { 811 | background-image:url('nav_f.png'); 812 | background-repeat:repeat-x; 813 | background-color: #E2E8F2; 814 | font-size: 90%; 815 | color: #253555; 816 | padding-bottom: 4px; 817 | padding-top: 5px; 818 | text-align:left; 819 | -moz-border-radius-topleft: 4px; 820 | -moz-border-radius-topright: 4px; 821 | -webkit-border-top-left-radius: 4px; 822 | -webkit-border-top-right-radius: 4px; 823 | border-top-left-radius: 4px; 824 | border-top-right-radius: 4px; 825 | border-bottom: 1px solid #A8B8D9; 826 | } 827 | 828 | 829 | .tabsearch { 830 | top: 0px; 831 | left: 10px; 832 | height: 36px; 833 | background-image: url('tab_b.png'); 834 | z-index: 101; 835 | overflow: hidden; 836 | font-size: 13px; 837 | } 838 | 839 | .navpath ul 840 | { 841 | font-size: 11px; 842 | background-image:url('tab_b.png'); 843 | background-repeat:repeat-x; 844 | background-position: 0 -5px; 845 | height:30px; 846 | line-height:30px; 847 | color:#8AA0CC; 848 | border:solid 1px #C2CDE4; 849 | overflow:hidden; 850 | margin:0px; 851 | padding:0px; 852 | } 853 | 854 | .navpath li 855 | { 856 | list-style-type:none; 857 | float:left; 858 | padding-left:10px; 859 | padding-right:15px; 860 | background-image:url('bc_s.png'); 861 | background-repeat:no-repeat; 862 | background-position:right; 863 | color:#364D7C; 864 | } 865 | 866 | .navpath li.navelem a 867 | { 868 | height:32px; 869 | display:block; 870 | text-decoration: none; 871 | outline: none; 872 | color: #283A5D; 873 | font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; 874 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 875 | text-decoration: none; 876 | } 877 | 878 | .navpath li.navelem a:hover 879 | { 880 | color:#6884BD; 881 | } 882 | 883 | .navpath li.footer 884 | { 885 | list-style-type:none; 886 | float:right; 887 | padding-left:10px; 888 | padding-right:15px; 889 | background-image:none; 890 | background-repeat:no-repeat; 891 | background-position:right; 892 | color:#364D7C; 893 | font-size: 8pt; 894 | } 895 | 896 | 897 | div.summary 898 | { 899 | float: right; 900 | font-size: 8pt; 901 | padding-right: 5px; 902 | width: 50%; 903 | text-align: right; 904 | } 905 | 906 | div.summary a 907 | { 908 | white-space: nowrap; 909 | } 910 | 911 | div.ingroups 912 | { 913 | font-size: 8pt; 914 | width: 50%; 915 | text-align: left; 916 | } 917 | 918 | div.ingroups a 919 | { 920 | white-space: nowrap; 921 | } 922 | 923 | div.header 924 | { 925 | background-image:url('nav_h.png'); 926 | background-repeat:repeat-x; 927 | background-color: #F9FAFC; 928 | margin: 0px; 929 | border-bottom: 1px solid #C4CFE5; 930 | } 931 | 932 | div.headertitle 933 | { 934 | padding: 5px 5px 5px 10px; 935 | } 936 | 937 | dl 938 | { 939 | padding: 0 0 0 10px; 940 | } 941 | 942 | /* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ 943 | dl.section 944 | { 945 | margin-left: 0px; 946 | padding-left: 0px; 947 | } 948 | 949 | dl.note 950 | { 951 | margin-left:-7px; 952 | padding-left: 3px; 953 | border-left:4px solid; 954 | border-color: #D0C000; 955 | } 956 | 957 | dl.warning, dl.attention 958 | { 959 | margin-left:-7px; 960 | padding-left: 3px; 961 | border-left:4px solid; 962 | border-color: #FF0000; 963 | } 964 | 965 | dl.pre, dl.post, dl.invariant 966 | { 967 | margin-left:-7px; 968 | padding-left: 3px; 969 | border-left:4px solid; 970 | border-color: #00D000; 971 | } 972 | 973 | dl.deprecated 974 | { 975 | margin-left:-7px; 976 | padding-left: 3px; 977 | border-left:4px solid; 978 | border-color: #505050; 979 | } 980 | 981 | dl.todo 982 | { 983 | margin-left:-7px; 984 | padding-left: 3px; 985 | border-left:4px solid; 986 | border-color: #00C0E0; 987 | } 988 | 989 | dl.test 990 | { 991 | margin-left:-7px; 992 | padding-left: 3px; 993 | border-left:4px solid; 994 | border-color: #3030E0; 995 | } 996 | 997 | dl.bug 998 | { 999 | margin-left:-7px; 1000 | padding-left: 3px; 1001 | border-left:4px solid; 1002 | border-color: #C08050; 1003 | } 1004 | 1005 | dl.section dd { 1006 | margin-bottom: 6px; 1007 | } 1008 | 1009 | 1010 | #projectlogo 1011 | { 1012 | text-align: center; 1013 | vertical-align: bottom; 1014 | border-collapse: separate; 1015 | } 1016 | 1017 | #projectlogo img 1018 | { 1019 | border: 0px none; 1020 | } 1021 | 1022 | #projectname 1023 | { 1024 | font: 300% Tahoma, Arial,sans-serif; 1025 | margin: 0px; 1026 | padding: 2px 0px; 1027 | } 1028 | 1029 | #projectbrief 1030 | { 1031 | font: 120% Tahoma, Arial,sans-serif; 1032 | margin: 0px; 1033 | padding: 0px; 1034 | } 1035 | 1036 | #projectnumber 1037 | { 1038 | font: 50% Tahoma, Arial,sans-serif; 1039 | margin: 0px; 1040 | padding: 0px; 1041 | } 1042 | 1043 | #titlearea 1044 | { 1045 | padding: 0px; 1046 | margin: 0px; 1047 | width: 100%; 1048 | border-bottom: 1px solid #5373B4; 1049 | } 1050 | 1051 | .image 1052 | { 1053 | text-align: center; 1054 | } 1055 | 1056 | .dotgraph 1057 | { 1058 | text-align: center; 1059 | } 1060 | 1061 | .mscgraph 1062 | { 1063 | text-align: center; 1064 | } 1065 | 1066 | .caption 1067 | { 1068 | font-weight: bold; 1069 | } 1070 | 1071 | div.zoom 1072 | { 1073 | border: 1px solid #90A5CE; 1074 | } 1075 | 1076 | dl.citelist { 1077 | margin-bottom:50px; 1078 | } 1079 | 1080 | dl.citelist dt { 1081 | color:#334975; 1082 | float:left; 1083 | font-weight:bold; 1084 | margin-right:10px; 1085 | padding:5px; 1086 | } 1087 | 1088 | dl.citelist dd { 1089 | margin:2px 0; 1090 | padding:5px 0; 1091 | } 1092 | 1093 | div.toc { 1094 | padding: 14px 25px; 1095 | background-color: #F4F6FA; 1096 | border: 1px solid #D8DFEE; 1097 | border-radius: 7px 7px 7px 7px; 1098 | float: right; 1099 | height: auto; 1100 | margin: 0 20px 10px 10px; 1101 | width: 200px; 1102 | } 1103 | 1104 | div.toc li { 1105 | background: url("bdwn.png") no-repeat scroll 0 5px transparent; 1106 | font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; 1107 | margin-top: 5px; 1108 | padding-left: 10px; 1109 | padding-top: 2px; 1110 | } 1111 | 1112 | div.toc h3 { 1113 | font: bold 12px/1.2 Arial,FreeSans,sans-serif; 1114 | color: #4665A2; 1115 | border-bottom: 0 none; 1116 | margin: 0; 1117 | } 1118 | 1119 | div.toc ul { 1120 | list-style: none outside none; 1121 | border: medium none; 1122 | padding: 0px; 1123 | } 1124 | 1125 | div.toc li.level1 { 1126 | margin-left: 0px; 1127 | } 1128 | 1129 | div.toc li.level2 { 1130 | margin-left: 15px; 1131 | } 1132 | 1133 | div.toc li.level3 { 1134 | margin-left: 30px; 1135 | } 1136 | 1137 | div.toc li.level4 { 1138 | margin-left: 45px; 1139 | } 1140 | 1141 | .inherit_header { 1142 | font-weight: bold; 1143 | color: gray; 1144 | cursor: pointer; 1145 | -webkit-touch-callout: none; 1146 | -webkit-user-select: none; 1147 | -khtml-user-select: none; 1148 | -moz-user-select: none; 1149 | -ms-user-select: none; 1150 | user-select: none; 1151 | } 1152 | 1153 | .inherit_header td { 1154 | padding: 6px 0px 2px 5px; 1155 | } 1156 | 1157 | .inherit { 1158 | display: none; 1159 | } 1160 | 1161 | tr.heading h2 { 1162 | margin-top: 12px; 1163 | margin-bottom: 4px; 1164 | } 1165 | 1166 | @media print 1167 | { 1168 | #top { display: none; } 1169 | #side-nav { display: none; } 1170 | #nav-path { display: none; } 1171 | body { overflow:visible; } 1172 | h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } 1173 | .summary { display: none; } 1174 | .memitem { page-break-inside: avoid; } 1175 | #doc-content 1176 | { 1177 | margin-left:0 !important; 1178 | height:auto !important; 1179 | width:auto !important; 1180 | overflow:inherit; 1181 | display:inline; 1182 | } 1183 | } 1184 | 1185 | --------------------------------------------------------------------------------