add option block on receiveMessage
added the option block to the receiveMessage Method *default False for no compatibility issues
This commit is contained in:
parent
ec5cd45b4d
commit
d960680e2e
1 changed files with 5 additions and 3 deletions
|
|
@ -8,9 +8,10 @@ Created on 06.07.2012
|
|||
|
||||
import PCANBasic # PCANBasic wrapper library provided by PEAK
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
|
||||
class PcanAdapter (object):
|
||||
class PcanAdapter(object):
|
||||
'''
|
||||
A class for controlling a PEAK PCan adapter. Based on the PCANBasic library.
|
||||
'''
|
||||
|
|
@ -111,7 +112,7 @@ class PcanAdapter (object):
|
|||
self.Pcan.Write(self.Channel, msg) # write it onto the Bus
|
||||
#print ('Message ' + Message.Label + ' written.')
|
||||
|
||||
def receiveMessage(self):
|
||||
def receiveMessage(self, block = False):
|
||||
'''
|
||||
Tries to receive a CAN message and puts its data into the according CanMessage object's Data field.
|
||||
This method should be called frequently.
|
||||
|
|
@ -135,5 +136,6 @@ class PcanAdapter (object):
|
|||
self.Messages[msgKey].decomposeData()
|
||||
self.Messages[msgKey].timestamp = timestamp.micros + 1000 * timestamp.millis + 0xFFFFFFFF * 1000 * timestamp.millis_overflow
|
||||
return msg.ID
|
||||
elif result == PCANBasic.PCAN_ERROR_QRCVEMPTY:
|
||||
elif result == PCANBasic.PCAN_ERROR_QRCVEMPTY and block == False:
|
||||
return None
|
||||
sleep(0.01)
|
||||
Loading…
Add table
Add a link
Reference in a new issue