串口通信comport.h
时间:2010-06-07 来源:长江货郎
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/signal.h>
#include <sys/types.h>
#define BUF_32 32
#define BUF_64 62
typedef struct __COM_PORT
{
unsigned char databit, parity, stopbit, flowctrl, is_connted;
long baudrate;
char dev_name[BUF_64];
int fd_com;
int frag_size;
}COM_PORT;
//#define DEBUG #ifdef DEBUG
#define dbg_print(format,args...) printf(format, ##args)
#else
#define dbg_print(format,args...) do{} while(0);
#endif
void init_comport(COM_PORT *comport);
void set_setting(char *set, COM_PORT *comport);
void disp_setting(COM_PORT *comport);
void nonblock ();
int kbhit ();
unsigned char comport_recv ( COM_PORT *comport, unsigned char *buf, int buf_size,
int *recv_bytes, unsigned long timeout);
unsigned char comport_send (COM_PORT *comport, unsigned char *buf, int send_bytes);
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/signal.h>
#include <sys/types.h>
#define BUF_32 32
#define BUF_64 62
typedef struct __COM_PORT
{
unsigned char databit, parity, stopbit, flowctrl, is_connted;
long baudrate;
char dev_name[BUF_64];
int fd_com;
int frag_size;
}COM_PORT;
//#define DEBUG #ifdef DEBUG
#define dbg_print(format,args...) printf(format, ##args)
#else
#define dbg_print(format,args...) do{} while(0);
#endif
void init_comport(COM_PORT *comport);
void set_setting(char *set, COM_PORT *comport);
void disp_setting(COM_PORT *comport);
void nonblock ();
int kbhit ();
unsigned char comport_recv ( COM_PORT *comport, unsigned char *buf, int buf_size,
int *recv_bytes, unsigned long timeout);
unsigned char comport_send (COM_PORT *comport, unsigned char *buf, int send_bytes);
相关阅读 更多 +