本文整理汇总了Python中serial.VERSION属性的典型用法代码示例。如果您正苦于以下问题:Python serial.VERSION属性的具体用法?Python serial.VERSION怎么用?Python serial.VERSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类serial
的用法示例。
在下文中一共展示了serial.VERSION属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __intro
# 需要导入模块: import serial [as 别名]
# 或者: from serial import VERSION [as 别名]
def __intro(self):
if self.color:
self.intro = (
"\n"
+ colorama.Fore.GREEN
+ "** Micropython File Shell v%s, sw@kaltpost.de ** " % version.FULL
+ colorama.Fore.RESET
+ "\n"
)
else:
self.intro = (
"\n** Micropython File Shell v%s, sw@kaltpost.de **\n" % version.FULL
)
self.intro += "-- Running on Python %d.%d using PySerial %s --\n" % (
sys.version_info[0],
sys.version_info[1],
serial.VERSION,
)
示例2: number_to_device
# 需要导入模块: import serial [as 别名]
# 或者: from serial import VERSION [as 别名]
def number_to_device(self, port_number):
sys.stderr.write("""\
don't know how to number ttys on this system.
! Use an explicit path (eg /dev/ttyS1) or send this information to
! the author of this module:
sys.platform = %r
os.name = %r
serialposix.py version = %s
also add the device name of the serial port and where the
counting starts for the first serial port.
e.g. 'first serial port: /dev/ttyS0'
and with a bit luck you can get this module running...
""" % (sys.platform, os.name, serial.VERSION))
raise NotImplementedError('no number-to-device mapping defined on this platform')
示例3: get_low_level_info
# 需要导入模块: import serial [as 别名]
# 或者: from serial import VERSION [as 别名]
def get_low_level_info(cls):
try:
ver = serial.VERSION
except AttributeError:
ver = "N/A"
return "via PySerial (%s)" % ver
示例4: __init__
# 需要导入模块: import serial [as 别名]
# 或者: from serial import VERSION [as 别名]
def __init__(self, device, baudrate=115200, user='micro', password='python', wait=0, rts='', dtr=''):
if device and device[0].isdigit() and device[-1].isdigit() and device.count('.') == 3:
# device looks like an IP address
self.serial = TelnetToSerial(device, user, password, read_timeout=10)
else:
import serial
delayed = False
if serial.VERSION == '3.0':
self.serial = serial.Serial(baudrate=baudrate, inter_byte_timeout=1)
else:
self.serial = serial.Serial(baudrate=baudrate, interCharTimeout=1)
if rts != '':
self.serial.rts = parse_bool(rts)
if dtr != '':
self.serial.dtr = parse_bool(dtr)
self.serial.port = device
for attempt in range(wait + 1):
try:
# Assigning the port attribute will attempt to open the port
self.serial.open()
break
except (OSError, IOError): # Py2 and Py3 have different errors
if wait == 0:
continue
if attempt == 0:
sys.stdout.write('Waiting {} seconds for pyboard '.format(wait))
delayed = True
time.sleep(1)
sys.stdout.write('.')
sys.stdout.flush()
else:
if delayed:
print('')
raise PyboardError('failed to access ' + device)
if delayed:
print('')
示例5: _get_diagnostic_string
# 需要导入模块: import serial [as 别名]
# 或者: from serial import VERSION [as 别名]
def _get_diagnostic_string():
"""Generate a diagnostic string, showing the module version, the platform etc.
Returns:
A descriptive string.
"""
text = "\n## Diagnostic output from minimalmodbus ## \n\n"
text += "Minimalmodbus version: " + __version__ + "\n"
text += "Minimalmodbus status: " + __status__ + "\n"
text += "File name (with relative path): " + __file__ + "\n"
text += "Full file path: " + os.path.abspath(__file__) + "\n\n"
text += "pySerial version: " + serial.VERSION + "\n"
text += "pySerial full file path: " + os.path.abspath(serial.__file__) + "\n\n"
text += "Platform: " + sys.platform + "\n"
text += "Filesystem encoding: " + repr(sys.getfilesystemencoding()) + "\n"
text += "Byteorder: " + sys.byteorder + "\n"
text += "Python version: " + sys.version + "\n"
text += "Python version info: " + repr(sys.version_info) + "\n"
text += "Python flags: " + repr(sys.flags) + "\n"
text += "Python argv: " + repr(sys.argv) + "\n"
text += "Python prefix: " + repr(sys.prefix) + "\n"
text += "Python exec prefix: " + repr(sys.exec_prefix) + "\n"
text += "Python executable: " + repr(sys.executable) + "\n"
try:
text += "Long info: " + repr(sys.long_info) + "\n"
except Exception:
text += "Long info: (none)\n" # For Python3 compatibility
try:
text += "Float repr style: " + repr(sys.float_repr_style) + "\n\n"
except Exception:
text += "Float repr style: (none) \n\n" # For Python 2.6 compatibility
text += "Variable __name__: " + __name__ + "\n"
text += "Current directory: " + os.getcwd() + "\n\n"
text += "Python path: \n"
text += "\n".join(sys.path) + "\n"
text += "\n## End of diagnostic output ## \n"
return text
# For backward compatibility