remove compiled files

This commit is contained in:
Philipp Rauch 2013-12-13 12:23:53 +01:00
parent d960680e2e
commit effafdbb56
12 changed files with 82 additions and 30 deletions

46
.gitignore vendored Normal file
View file

@ -0,0 +1,46 @@
# Ignore-Datei selbst ausschließen
#.gitignore
.gitmodules
Thumbs.db
# Bestimmte Dateien ausschließen
cache.dat
# Es können Wildcards (*,?) verwendet werden:
*.exe
*.dll
*.dsbackup
*.avrsln
*.avrsuo
*.avrgccproj
*.aps
*.atsln
*.atsuo
*.cproj
*.aws
*.xml
*.xslt
*.aux
*.dvi
*.lof
*.log
*.lot
*.out
*.synctex.gz
*.toc
*.pyc
*.patch
*.csv
.project
.pydevproject
tmp?.dat
# Auch Verzeichnisse kann man ausschießen:
*default/
*Debug/
*bin/
*ADC/
*CAN/
*UART/
.*/
CANLibrary/

View file

@ -2,5 +2,6 @@ eclipse.preferences.version=1
encoding//CANLibrary/CanMessage.py=UTF-8 encoding//CANLibrary/CanMessage.py=UTF-8
encoding//CANLibrary/CanSignal.py=UTF-8 encoding//CANLibrary/CanSignal.py=UTF-8
encoding//CANLibrary/PCan.py=UTF-8 encoding//CANLibrary/PCan.py=UTF-8
encoding//CANLibrary/Sym2Lib.py=UTF-8
encoding//CANLibrary/example.py=UTF-8 encoding//CANLibrary/example.py=UTF-8
encoding//pycrc/crc_algorithms.py=latin1 encoding//pycrc/crc_algorithms.py=latin1

View file

@ -15,7 +15,7 @@ class PcanAdapter(object):
''' '''
A class for controlling a PEAK PCan adapter. Based on the PCANBasic library. A class for controlling a PEAK PCan adapter. Based on the PCANBasic library.
''' '''
# Class variables: # Class variables:
Baudrate = { '100k' : PCANBasic.PCAN_BAUD_100K, Baudrate = { '100k' : PCANBasic.PCAN_BAUD_100K,
'125k' : PCANBasic.PCAN_BAUD_125K, '125k' : PCANBasic.PCAN_BAUD_125K,
@ -23,20 +23,21 @@ class PcanAdapter(object):
'500k' : PCANBasic.PCAN_BAUD_500K, '500k' : PCANBasic.PCAN_BAUD_500K,
'1000k': PCANBasic.PCAN_BAUD_1M '1000k': PCANBasic.PCAN_BAUD_1M
} }
def __init__(self, Baudrate): def __init__(self, Baudrate, debug = True):
''' '''
Constructor. Constructor.
@param Baudrate: Baud rate from the PcanAdapter. Baud rate dictionary @param Baudrate: Baud rate from the PcanAdapter. Baud rate dictionary
''' '''
# Instance variables: # Instance variables:
self.Messages = {} self.debug = debug
self.Messages = {}
self.Channel = PCANBasic.PCAN_USBBUS1 self.Channel = PCANBasic.PCAN_USBBUS1
self.Pcan = PCANBasic.PCANBasic() self.Pcan = PCANBasic.PCANBasic()
self.Baudrate = Baudrate # Baud rate from PCANBasic self.Baudrate = Baudrate # Baud rate from PCANBasic
self.isInitialised = False self.isInitialised = False
def __del__(self): def __del__(self):
''' '''
Destructor. Destructor.
@ -44,26 +45,26 @@ class PcanAdapter(object):
''' '''
print '\nDestructor:' print '\nDestructor:'
self.uninitialize() self.uninitialize()
def addMessage(self, CanMessage): def addMessage(self, CanMessage):
''' '''
Add a Message of type CanMessage to the list of messages. Add a Message of type CanMessage to the list of messages.
@param CanMessage: The message to add to the list of messages. @param CanMessage: The message to add to the list of messages.
''' '''
self.Messages.update({CanMessage.Label: CanMessage}) self.Messages.update({CanMessage.Label: CanMessage})
def removeMessage(self, CanMessageLabel): def removeMessage(self, CanMessageLabel):
try: try:
self.Messages.pop(CanMessageLabel) self.Messages.pop(CanMessageLabel)
except: except:
pass pass
def clearMessages(self): def clearMessages(self):
self.Messages = {} self.Messages = {}
def initialize(self): def initialize(self):
''' '''
Initializes the PCAN adapter. Initializes the PCAN adapter.
@ -71,15 +72,17 @@ class PcanAdapter(object):
self.Pcan.Uninitialize(PCANBasic.PCAN_NONEBUS) self.Pcan.Uninitialize(PCANBasic.PCAN_NONEBUS)
status = self.Pcan.Initialize(self.Channel, self.Baudrate) status = self.Pcan.Initialize(self.Channel, self.Baudrate)
if status != PCANBasic.PCAN_ERROR_OK: if status != PCANBasic.PCAN_ERROR_OK:
print 'Error: ', self.Pcan.GetErrorText(status, 0)[1] if self.debug:
print 'Error: ', self.Pcan.GetErrorText(status, 0)[1]
sys.exit("PCAN initialisation error") sys.exit("PCAN initialisation error")
if self.debug:
print("PCAN initialised") print("PCAN initialised")
self.isInitialised = True self.isInitialised = True
channel, hwId = self.Pcan.GetValue( self.Channel, PCANBasic.PCAN_DEVICE_NUMBER ) channel, hwId = self.Pcan.GetValue( self.Channel, PCANBasic.PCAN_DEVICE_NUMBER )
print 'DeviceNumber: ', hwId if self.debug:
print 'DeviceNumber: ', hwId
def uninitialize(self): def uninitialize(self):
''' '''
Unitialize the PCAN adapter. Unitialize the PCAN adapter.
@ -87,19 +90,20 @@ class PcanAdapter(object):
if self.isInitialised: if self.isInitialised:
status = self.Pcan.Uninitialize(self.Channel) status = self.Pcan.Uninitialize(self.Channel)
if status != PCANBasic.PCAN_ERROR_OK: if status != PCANBasic.PCAN_ERROR_OK:
print 'Error: ', self.Pcan.GetErrorText(status, 0)[1] if self.debug:
print 'Error: ', self.Pcan.GetErrorText(status, 0)[1]
sys.exit("PCAN deinitialisation error") sys.exit("PCAN deinitialisation error")
if self.debug:
print("PCAN deinitialised") print("PCAN deinitialised")
def sendMessage(self, Message, rtr = False): def sendMessage(self, Message, rtr = False):
''' '''
Sends the CanMessage object Message onto the CAN bus. Sends the CanMessage object Message onto the CAN bus.
@param Messge: The CanMessage object that is to be sent. @param Messge: The CanMessage object that is to be sent.
''' '''
Message.composeData() # compose message data array from the signals in Message.Signals. Message.composeData() # compose message data array from the signals in Message.Signals.
msg = PCANBasic.TPCANMsg() # create a new PCAN message object msg = PCANBasic.TPCANMsg() # create a new PCAN message object
msg.ID = Message.Id # copy the ID msg.ID = Message.Id # copy the ID
if rtr: if rtr:
@ -108,10 +112,10 @@ class PcanAdapter(object):
msg.MSGTYPE = PCANBasic.PCAN_MESSAGE_STANDARD # Message type is standard (not extended) msg.MSGTYPE = PCANBasic.PCAN_MESSAGE_STANDARD # Message type is standard (not extended)
msg.LEN = Message.Length # copy the length msg.LEN = Message.Length # copy the length
msg.DATA[0:Message.Length] = Message.Data # copy the message data into the PCAN message object msg.DATA[0:Message.Length] = Message.Data # copy the message data into the PCAN message object
self.Pcan.Write(self.Channel, msg) # write it onto the Bus self.Pcan.Write(self.Channel, msg) # write it onto the Bus
#print ('Message ' + Message.Label + ' written.') #print ('Message ' + Message.Label + ' written.')
def receiveMessage(self, block = False): def receiveMessage(self, block = False):
''' '''
Tries to receive a CAN message and puts its data into the according CanMessage object's Data field. Tries to receive a CAN message and puts its data into the according CanMessage object's Data field.
@ -120,7 +124,7 @@ class PcanAdapter(object):
while True: # do this while messages are read from the bus while True: # do this while messages are read from the bus
result, msg, timestamp = self.Pcan.Read(self.Channel) result, msg, timestamp = self.Pcan.Read(self.Channel)
if result == PCANBasic.PCAN_ERROR_OK: if result == PCANBasic.PCAN_ERROR_OK:
# loop through the messages and look for one that matches the received message: # loop through the messages and look for one that matches the received message:
for msgKey in self.Messages: for msgKey in self.Messages:

View file

@ -9,6 +9,7 @@ Example for creating and sending CAN messages via PCAN using the CanMessage, Can
from CanMessage import CanMessage from CanMessage import CanMessage
from CanSignal import CanSignal from CanSignal import CanSignal
from PCan import PcanAdapter from PCan import PcanAdapter
from Sym2Lib import addtoPCAN, printCode
import time import time
print '\nCreate a PCAN adapter' print '\nCreate a PCAN adapter'

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.