00001 #include <stdio.h> 00002 #include <termios.h> 00003 #include <sys/ioctl.h> 00004 #include <unistd.h> 00005 #include <fcntl.h> 00006 #include <sys/types.h> 00007 #include <sys/stat.h> 00008 #include <limits.h> 00009 #include <iostream> 00010 #include <string> 00011 #include <cstring> 00012 #include <linux/serial.h> 00013 00014 #define MAX_LENGTH 128 00015 00016 namespace milvus 00017 { 00018 class SerialComm 00019 { 00020 public: 00022 SerialComm(); 00024 ~SerialComm(); 00025 00026 int open_port(std::string port_name, int baudrate, std::string mode_s); 00027 int close_port(); 00028 int poll_comport(unsigned char *, int); 00029 int send_byte(unsigned char); 00030 int send_buf(unsigned char *, int); 00031 void cputs(const char *); 00032 int is_dcd_enabled(); 00033 int is_cts_enabled(); 00034 int is_dsr_enabled(); 00035 void enable_dtr(); 00036 void disable_dtr(); 00037 void enable_rts(); 00038 void disable_rts(); 00039 00040 00041 private: 00043 int fd_; 00045 int baud_; 00046 std::string port_name_; 00047 struct termios new_port_settings, old_port_settings; 00048 int error; 00049 }; 00050 00051 }