phycom.h
来自「linux 环境下的 RS232通信源代码」· C头文件 代码 · 共 77 行
H
77 行
#ifndef PHYCOM_H
#define PHYCOM_H
#if (ACTUAL_OS == OS_LINUX) || (ACTUAL_OS == OS_UCLINUX) || (ACTUAL_OS == OS_UNIX)
#include "esctype.h"
#include "const.h"
#include "phys.h"
//#include "esclist.h"
//for windows platform
//for linux
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<termios.h>
#include<errno.h>
//#include<iostream.h>
/////////////////////////////////////////////////////////////////////
struct PhyChnlConfig
{
EscInt speed;
EscInt databits;
EscInt stopbits;
EscInt parity;
EscInt timeout;
EscChar* dev;
};
class PhysicalCom:public PhysicalLayer
{
private:
EscInt fd;
EscBool initialized;
PhyChnlConfig* phyConfig;
private:
void setSpeed(EscInt fd, EscInt speed);
EscInt setParity(EscInt fd,EscInt databits,EscInt stopbits,EscInt parity, EscInt timeout);
void setRawIo(EscInt fd );
EscInt InitDev(EscInt fd, EscInt speed, EscInt databits, EscInt stopbits, EscInt parity, EscInt timeout);
public:
EscInt recv(EscChar *buf,EscInt length,EscInt maxTimeOut,EscBool* timeoutOccur);
EscBool send(EscChar *buf,EscInt length);
public:
PhysicalCom(PhyChnlConfig* pConfig,EscInt poolSize);
EscBool openChannel();
void closeChannel();
~PhysicalCom();
};
#endif
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?