Bugfix: Path to PCANBasic was not correct. Now using a relative path to the sub directory.
This commit is contained in:
parent
dc965eb600
commit
a04155be8c
13 changed files with 685 additions and 647 deletions
17
.project
Normal file
17
.project
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>CANLibrary</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
12
.pydevproject
Normal file
12
.pydevproject
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?>
|
||||
|
||||
<pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/CANLibrary</path>
|
||||
<path>/CANLibrary/PCANBasic</path>
|
||||
<path>/CANLibrary/pycrc</path>
|
||||
</pydev_pathproperty>
|
||||
</pydev_project>
|
||||
6
.settings/org.eclipse.core.resources.prefs
Normal file
6
.settings/org.eclipse.core.resources.prefs
Normal file
|
|
@ -0,0 +1,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/example.py=UTF-8
|
||||
encoding//pycrc/crc_algorithms.py=latin1
|
||||
|
|
@ -1,80 +1,83 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
|
||||
'''
|
||||
Example for creating and sending CAN messages via PCAN using the CanMessage, CanSignal and PCan classes.
|
||||
|
||||
@author: Christian Sültrop
|
||||
'''
|
||||
|
||||
from CanMessage import CanMessage
|
||||
from CanSignal import CanSignal
|
||||
from PCan import PcanAdapter
|
||||
import time
|
||||
|
||||
print '\nCreate a PCAN adapter'
|
||||
pcan = PcanAdapter(PcanAdapter.Baudrate['500k'])
|
||||
pcan.initialize()
|
||||
|
||||
print '\ncreate some messages'
|
||||
mMotor_1 = CanMessage(0x280, 8, 10, 'mMotor_1')
|
||||
pcan.addMessage(mMotor_1)
|
||||
print 'mMotor_1.Data', pcan.Messages['mMotor_1'].Data
|
||||
|
||||
mMotor_2 = CanMessage(0x288, 8, 20, 'mMotor_2')
|
||||
pcan.addMessage(mMotor_2)
|
||||
print 'mMotor_2.Data', pcan.Messages['mMotor_2'].Data
|
||||
|
||||
print '\ncreate some Signals'
|
||||
# for mMotor_1
|
||||
MO1_Leergas = CanSignal(0, 1, 0, 1, 1, 'MO1_Leergas')
|
||||
MO1_Sta_Pedal = CanSignal(1, 1, 0, 1, 1, 'MO1_Sta_Pedal')
|
||||
MO1_Mo_m_ex = CanSignal(8, 8, 0, 1, 0, 'MO1_Mo_m_ex')
|
||||
value = 3000
|
||||
MO1_Drehzahl = CanSignal(16, 16, 0, 0.25, value, 'MO1_Drehzahl') # split into two bytes
|
||||
|
||||
print '\nadd Signals to the Messages'
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Leergas)
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Sta_Pedal)
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Mo_m_ex)
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Drehzahl)
|
||||
print "pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].Data", pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].Data
|
||||
|
||||
|
||||
# for mMotor_2
|
||||
MO2_Kuehlm_T = CanSignal(8, 8, -48, 0.75, 60, 'MO2_Kuehlm_T')
|
||||
pcan.Messages['mMotor_2'].addSignal( MO2_Kuehlm_T )
|
||||
pcan.Messages['mMotor_2'].addSignal( CanSignal(24, 8, 0, 1, 0, 'MO2_GRA_Soll') )
|
||||
pcan.Messages['mMotor_2'].addSignal( CanSignal(0, 6, 0, 1, 44, 'MO2_CAN_Vers') )
|
||||
|
||||
print '\nManipulate Signals'
|
||||
pcan.Messages['mMotor_1'].Signals['MO1_Leergas'].SetData( 0 )
|
||||
|
||||
print '\nSend the messages'
|
||||
pcan.Messages['mMotor_1'].composeData()
|
||||
print 'mMotor_1.Data', pcan.Messages['mMotor_1'].Data
|
||||
pcan.sendMessage(pcan.Messages['mMotor_1'])
|
||||
|
||||
pcan.Messages['mMotor_2'].composeData()
|
||||
print 'mMotor_2.Data', pcan.Messages['mMotor_2'].Data
|
||||
pcan.sendMessage(pcan.Messages['mMotor_2'])
|
||||
|
||||
# receive messages, if the signal MO1_Drehzahl has changed, print the new value
|
||||
while True:
|
||||
pcan.sendMessage(pcan.Messages['mMotor_2'])
|
||||
dataOld = pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].GetData()
|
||||
pcan.receiveMessage()
|
||||
if pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].GetData() != dataOld:
|
||||
print 'mMotor_1.Data', pcan.Messages['mMotor_1'].Data
|
||||
print 'GetData()', pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].GetData()
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
# wait a while to make sure messages can be sent and end
|
||||
time.sleep(1)
|
||||
print 'end of program'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
'''
|
||||
Example for creating and sending CAN messages via PCAN using the CanMessage, CanSignal and PCan classes.
|
||||
|
||||
@author: Christian Sültrop
|
||||
'''
|
||||
|
||||
from CanMessage import CanMessage
|
||||
from CanSignal import CanSignal
|
||||
from PCan import PcanAdapter
|
||||
import time
|
||||
|
||||
print '\nCreate a PCAN adapter'
|
||||
pcan = PcanAdapter(PcanAdapter.Baudrate['500k'])
|
||||
pcan.initialize()
|
||||
|
||||
print '\ncreate some messages'
|
||||
mMotor_1 = CanMessage(0x280, 8, 10, 'mMotor_1')
|
||||
pcan.addMessage(mMotor_1)
|
||||
print 'mMotor_1.Data', pcan.Messages['mMotor_1'].Data
|
||||
|
||||
mMotor_2 = CanMessage(0x288, 8, 20, 'mMotor_2')
|
||||
pcan.addMessage(mMotor_2)
|
||||
print 'mMotor_2.Data', pcan.Messages['mMotor_2'].Data
|
||||
|
||||
print '\ncreate some Signals'
|
||||
# for mMotor_1
|
||||
MO1_Leergas = CanSignal(0, 1, 0, 1, 1, 'MO1_Leergas')
|
||||
MO1_Sta_Pedal = CanSignal(1, 1, 0, 1, 1, 'MO1_Sta_Pedal')
|
||||
MO1_Mo_m_ex = CanSignal(8, 8, 0, 1, 0, 'MO1_Mo_m_ex')
|
||||
value = 3000
|
||||
MO1_Drehzahl = CanSignal(16, 16, 0, 0.25, value, 'MO1_Drehzahl') # split into two bytes
|
||||
|
||||
print '\nadd Signals to the Messages'
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Leergas)
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Sta_Pedal)
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Mo_m_ex)
|
||||
pcan.Messages['mMotor_1'].addSignal(MO1_Drehzahl)
|
||||
print "pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].Data", pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].Data
|
||||
|
||||
|
||||
# for mMotor_2
|
||||
MO2_Kuehlm_T = CanSignal(8, 8, -48, 0.75, 60, 'MO2_Kuehlm_T')
|
||||
pcan.Messages['mMotor_2'].addSignal( MO2_Kuehlm_T )
|
||||
pcan.Messages['mMotor_2'].addSignal( CanSignal(24, 8, 0, 1, 0, 'MO2_GRA_Soll') )
|
||||
pcan.Messages['mMotor_2'].addSignal( CanSignal(0, 6, 0, 1, 44, 'MO2_CAN_Vers') )
|
||||
|
||||
print '\nManipulate Signals'
|
||||
pcan.Messages['mMotor_1'].Signals['MO1_Leergas'].SetData( 0 )
|
||||
|
||||
print '\nSend the messages'
|
||||
pcan.Messages['mMotor_1'].composeData()
|
||||
print 'mMotor_1.Data', pcan.Messages['mMotor_1'].Data
|
||||
pcan.sendMessage(pcan.Messages['mMotor_1'])
|
||||
|
||||
pcan.Messages['mMotor_2'].composeData()
|
||||
print 'mMotor_2.Data', pcan.Messages['mMotor_2'].Data
|
||||
pcan.sendMessage(pcan.Messages['mMotor_2'])
|
||||
|
||||
# receive messages, if the signal MO1_Drehzahl has changed, print the new value
|
||||
while True:
|
||||
#print 'send'
|
||||
pcan.sendMessage(pcan.Messages['mMotor_2'])
|
||||
dataOld = pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].GetData()
|
||||
|
||||
#print 'receive'
|
||||
pcan.receiveMessage()
|
||||
if pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].GetData() != dataOld:
|
||||
print 'mMotor_1.Data', pcan.Messages['mMotor_1'].Data
|
||||
print 'GetData()', pcan.Messages['mMotor_1'].Signals['MO1_Drehzahl'].GetData()
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
# wait a while to make sure messages can be sent and end
|
||||
time.sleep(1)
|
||||
print 'end of program'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
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.
BIN
pycrc/pycrc.pyc
BIN
pycrc/pycrc.pyc
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue