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/CanSignal.py=UTF-8
encoding//CANLibrary/PCan.py=UTF-8
encoding//CANLibrary/Sym2Lib.py=UTF-8
encoding//CANLibrary/example.py=UTF-8
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.
'''
# Class variables:
Baudrate = { '100k' : PCANBasic.PCAN_BAUD_100K,
'125k' : PCANBasic.PCAN_BAUD_125K,
@ -23,20 +23,21 @@ class PcanAdapter(object):
'500k' : PCANBasic.PCAN_BAUD_500K,
'1000k': PCANBasic.PCAN_BAUD_1M
}
def __init__(self, Baudrate):
def __init__(self, Baudrate, debug = True):
'''
Constructor.
@param Baudrate: Baud rate from the PcanAdapter. Baud rate dictionary
'''
# Instance variables:
self.Messages = {}
# Instance variables:
self.debug = debug
self.Messages = {}
self.Channel = PCANBasic.PCAN_USBBUS1
self.Pcan = PCANBasic.PCANBasic()
self.Baudrate = Baudrate # Baud rate from PCANBasic
self.isInitialised = False
def __del__(self):
'''
Destructor.
@ -44,26 +45,26 @@ class PcanAdapter(object):
'''
print '\nDestructor:'
self.uninitialize()
def addMessage(self, CanMessage):
'''
Add a Message of type CanMessage to the list of messages.
@param CanMessage: The message to add to the list of messages.
'''
self.Messages.update({CanMessage.Label: CanMessage})
def removeMessage(self, CanMessageLabel):
try:
self.Messages.pop(CanMessageLabel)
except:
pass
def clearMessages(self):
self.Messages = {}
def initialize(self):
'''
Initializes the PCAN adapter.
@ -71,15 +72,17 @@ class PcanAdapter(object):
self.Pcan.Uninitialize(PCANBasic.PCAN_NONEBUS)
status = self.Pcan.Initialize(self.Channel, self.Baudrate)
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")
print("PCAN initialised")
if self.debug:
print("PCAN initialised")
self.isInitialised = True
channel, hwId = self.Pcan.GetValue( self.Channel, PCANBasic.PCAN_DEVICE_NUMBER )
print 'DeviceNumber: ', hwId
if self.debug:
print 'DeviceNumber: ', hwId
def uninitialize(self):
'''
Unitialize the PCAN adapter.
@ -87,19 +90,20 @@ class PcanAdapter(object):
if self.isInitialised:
status = self.Pcan.Uninitialize(self.Channel)
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")
print("PCAN deinitialised")
if self.debug:
print("PCAN deinitialised")
def sendMessage(self, Message, rtr = False):
'''
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.
msg = PCANBasic.TPCANMsg() # create a new PCAN message object
msg.ID = Message.Id # copy the ID
if rtr:
@ -108,10 +112,10 @@ class PcanAdapter(object):
msg.MSGTYPE = PCANBasic.PCAN_MESSAGE_STANDARD # Message type is standard (not extended)
msg.LEN = Message.Length # copy the length
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
#print ('Message ' + Message.Label + ' written.')
def receiveMessage(self, block = False):
'''
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
result, msg, timestamp = self.Pcan.Read(self.Channel)
if result == PCANBasic.PCAN_ERROR_OK:
# loop through the messages and look for one that matches the received message:
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 CanSignal import CanSignal
from PCan import PcanAdapter
from Sym2Lib import addtoPCAN, printCode
import time
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.