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

📄 port.h

📁 网络端口的服务程序
💻 H
字号:
/*
    Portserver - Use RTERM protocol to serve serial ports over a network
    Copyright (C) 1998 Kenn Humborg

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef PORT_H
#define PORT_H

#include <termios.h>   /* for struct termios */

#include "buffer.h"
#include "connection.h"
#include "status.h"

#define PORT_BUFFER_SIZE 512

#define TEMPLATE_PORT_NAME "** Template **"

enum parity_types { 
   none, odd, even, mark, space 
}; 

struct Port {
   struct Port *next;
   struct Port *prev;

   int flags;
   struct Connection *connection;  /* Points to the connection currently using this port */
   char *port_name;
   char *device_name;
   char *description;
   int fd;
   struct Buffer *write_buffer;          /* Data waiting to be written to the port */
   struct Buffer *read_buffer;          /* Data waiting to be written to the port */
   char *lock_file;
   int speed;
   int data_bits;
   int stop_bits;
   enum parity_types parity;
   struct termios old_settings;
};

/* Bits in Port.flags */
#define PORT_USELOCKFILE 1
#define PORT_TEMPLATE 2             /* This port structure is a template */


void AddPort(struct Port *port);
void DumpPortList(void);
struct Port *FindPort(char *port_name);
STATUS CreatePort(char *port_name, struct Port **new_port);
STATUS SetPortDevice(struct Port *port, char *dev_name);
STATUS SetPortDescription(struct Port *port, char *description);
STATUS OpenPort(struct Port *port);
void ClosePort(struct Port *port);
int PortSendData(struct Port *port, char *data, int data_len);
void PortReady(struct Port *port);
void PortDataReceived(struct Port *port);
void HandlePortData(struct Port *port);
STATUS PortSetSpeed(struct Port *port, int speed);

extern struct Port port_list;


#endif /* PORT_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -