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

📄 serialposix.py

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 PY
字号:
#!/usr/bin/env python#module for serial IO for POSIX compatible systems, like Linux#see __init__.py##(C) 2001-2002 Chris Liechti <cliechti@gmx.net># this is distributed under a free software license, see license.txt##parts based on code from Grant B. Edwards  <grante@visi.com>:#  ftp://ftp.visi.com/users/grante/python/PosixSerial.py# references: http://www.easysw.com/~mike/serial/serial.htmlimport sys, os, fcntl, termios, struct, string, selectimport serialutilVERSION = string.split("$Revision: 1.1 $")[1]     #extract CVS versionPARITY_NONE, PARITY_EVEN, PARITY_ODD = range(3)STOPBITS_ONE, STOPBITS_TWO = (1, 2)FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS = (5,6,7,8)#Do check the Python version as some constants have moved.if (sys.hexversion < 0x020100f0):    import TERMIOSelse:    TERMIOS = termiosif (sys.hexversion < 0x020200f0):    import FCNTLelse:    FCNTL = fcntl#try to detect the os so that a device can be selected...plat = string.lower(sys.platform)if   plat[:5] == 'linux':    #Linux (confirmed)    def device(port):        return '/dev/ttyS%d' % portelif plat == 'cygwin':       #cywin/win32 (confirmed)    def device(port):        return '/dev/com%d' % (port + 1)elif plat     == 'openbsd3': #BSD (confirmed)    def device(port):        return '/dev/ttyp%d' % portelif plat[:3] == 'bsd' or  \     plat[:6] == 'netbsd' or \     plat[:7] == 'freebsd' or \     plat[:7] == 'openbsd' or \     plat[:6] == 'darwin':   #BSD (confirmed for freebsd4: cuaa%d)    def device(port):        return '/dev/cuaa%d' % portelif plat[:4] == 'irix':     #IRIX

⌨️ 快捷键说明

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