本文整理匯總了Python中transport.Transport.reset方法的典型用法代碼示例。如果您正苦於以下問題:Python Transport.reset方法的具體用法?Python Transport.reset怎麽用?Python Transport.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類transport.Transport
的用法示例。
在下文中一共展示了Transport.reset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MicroNFCBoard
# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import reset [as 別名]
class MicroNFCBoard(object):
@staticmethod
def getBoard(number = 0):
a = INTERFACE[usb_backend].getAllConnectedInterface(VID, PID)
if((a != None) and (len(a) > number)):
return MicroNFCBoard(a[number])
return None
@staticmethod
def getAllBoards():
return [MicroNFCBoard(i) for i in INTERFACE[usb_backend].getAllConnectedInterface(VID, PID)]
def __init__(self, intf):
self._intf = intf
self._transport = Transport()
self._id = None
self._version = None
self._polling = False
self._connected = False
self._ndefMessagePresent = False
self._ndefRecords = None
self._ndefRead = False
def open(self):
self._transport.open(self._intf)
version, revision, self._id = self._transport.info()
self._version = (version, revision)
def close(self):
self._transport.close()
@property
def id(self):
return self._id
@property
def connected(self):
self._updateStatus()
return self._connected
@property
def polling(self):
self._updateStatus()
return self._polling
@property
def ndefMessagePresent(self):
self._updateStatus()
return self._ndefMessagePresent
@property
def ndefRecords(self):
self._updateStatus()
if self._ndefMessagePresent and not self._ndefRead:
self._ndefRecords = self._getNdefMessageRecords()
self._ndefRecordsRead = True
return self._ndefRecords
@property
def version(self):
return self._version
def getNfcInfo(self):
return self._transport.nfcGetInfo()
def reset(self):
self._transport.reset(False)
def startPolling(self):
self._transport.nfcPoll(True)
def stopPolling(self):
self._transport.nfcPoll(True)
def setLeds(self, led1, led2):
self._transport.leds(led1, led2)
def _updateStatus(self):
status = self._transport.status()
self._polling = (status & STATUS_POLLING) != 0
self._connected = (status & STATUS_CONNECTED) != 0
self._ndefMessagePresent = (status & STATUS_NDEF_PRESENT) != 0
if not self._ndefMessagePresent:
self._ndefRecordsRead = False
def _getNdefRecords(self, start, count):
records = []
for recordNumber in range(start, start+count):
#Get records info
recordType, recordInfo = self._transport.nfcGetRecordInfo(recordNumber)
funcs = { 0 : self._parseUnknownRecord,
1 : self._parseURIRecord,
2 : self._parseTextRecord,
3 : self._parseSmartPosterRecord,
4 : self._parseMIMERecord,
}
record = funcs[recordType](recordNumber, recordInfo)
if record != None:
records += [record]
return records
#.........這裏部分代碼省略.........
示例2: MicroNFCBoard
# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import reset [as 別名]
#.........這裏部分代碼省略.........
@property
def ndefBusy(self):
self._updateStatus()
return self._ndefBusy
@property
def ndefSuccess(self):
self._updateStatus()
return self._ndefSuccess
@property
def ndefRecords(self):
self._updateStatus()
if self._ndefPresent and not self._ndefRead:
self._ndefRecords = self._getNdefMessageRecords()
self._ndefRead = True
return self._ndefRecords
@ndefRecords.setter
def ndefRecords(self, records):
self._updateStatus()
self._ndefRecords = records
#Push them to device
self._setNdefRecords(self._ndefRecords)
@property
def version(self):
return self._version
def getNfcInfo(self):
return self._transport.nfcGetInfo()
def reset(self):
self._transport.reset(False)
def startPolling(self, readerWriter, emulator, p2p):
self._transport.nfcPoll(readerWriter, emulator, p2p)
def stopPolling(self):
self._transport.nfcPoll(False, False, False)
def ndefRead(self):
self._transport.nfcOperation(True, False)
def ndefWrite(self):
self._transport.nfcOperation(False, True)
def setLeds(self, led1, led2):
self._transport.leds(led1, led2)
def _updateStatus(self):
status = self._transport.status()
self._polling = (status & STATUS_POLLING) != 0
self._connected = (status & STATUS_CONNECTED) != 0
self._ndefPresent = (status & STATUS_NDEF_PRESENT) != 0
self._ndefReadable = (status & STATUS_NDEF_READABLE) != 0
self._ndefWriteable = (status & STATUS_NDEF_WRITEABLE) != 0
self._ndefBusy = (status & STATUS_NDEF_BUSY) != 0
self._ndefSuccess = (status & STATUS_NDEF_SUCCESS) != 0
self._type2 = (status & STATUS_TYPE_MASK) == STATUS_TYPE2
self._type4 = (status & STATUS_TYPE_MASK) == STATUS_TYPE4
self._p2p = (status & STATUS_TYPE_MASK) == STATUS_P2P
self._initiator = (status & STATUS_INITIATOR) != 0
if not self._ndefPresent: