本文整理匯總了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