⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phycom.h

📁 linux 环境下的 RS232通信源代码
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -