Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, callback, filter, bus):
self.__bus = bus
listener = can.Listener()
listener.on_message_received = callback
self.__notifier = can.Notifier(self.__bus, [listener], 0)
self.__notifier = can.Notifier(self.__bus, [listener])
self.__listeners = [listener]
self.addFilter(filter)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import can
from can.interfaces import pcan, vector
from can.interfaces import pcan, vector, kvaser
from uds.uds_configuration.Config import Config
from os import path
from platform import system
Expand All @@ -9,6 +9,8 @@
# used to conditionally import socketcan for linux to avoid error messages
if system() == "Linux":
from can.interfaces import socketcan
else:
from can.interfaces import ics_neovi

class CanConnectionFactory(object):

Expand Down Expand Up @@ -76,6 +78,20 @@ def __call__(callback=None, filter=None, configPath=None, **kwargs):
else:
raise Exception("SocketCAN on Pythoncan currently only supported in Linux")

elif connectionType == 'neovi':
channel = int(CanConnectionFactory.config['neovi']['channel'])
baudrate = int(CanConnectionFactory.config['can']['baudrate'])
CanConnectionFactory.connections[channel] = CanConnection(callback, filter,
ics_neovi.NeoViBus(channel,
bitrate=baudrate))
return CanConnectionFactory.connections[channel]
elif connectionType == 'kvaser':
channel = int(CanConnectionFactory.config['kvaser']['channel'])
baudrate = int(CanConnectionFactory.config['can']['baudrate'])
CanConnectionFactory.connections[channel] = CanConnection(callback, filter,
kvaser.canlib.KvaserBus(channel,
bitrate=baudrate))
return CanConnectionFactory.connections[channel]
@staticmethod
def loadConfiguration(configPath=None):

Expand Down Expand Up @@ -107,4 +123,6 @@ def checkKwargs(**kwargs):

if 'channel' in kwargs:
CanConnectionFactory.config['vector']['channel'] = kwargs['channel']
CanConnectionFactory.config['kvaser']['channel'] = kwargs['channel']
CanConnectionFactory.config['neovi']['channel'] = kwargs['channel']

9 changes: 4 additions & 5 deletions uds/uds_communications/TransportProtocols/Can/CanTp.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def __checkKwargs(self, **kwargs):
##
# @brief send method
# @param [in] payload the payload to be sent
def send(self, payload, functionalReq=False):

def send(self, payload, functionalReq=False,nodelay=False):
payloadLength = len(payload)
payloadPtr = 0

Expand Down Expand Up @@ -278,15 +277,15 @@ def send(self, payload, functionalReq=False):
# timer / exit condition checks
if(timeoutTimer.isExpired()):
raise Exception("Timeout waiting for message")

sleep(0.001)
if state != CanTpState.SEND_CONSECUTIVE_FRAME or nodelay==False:
sleep(.001)

##
# @brief recv method
# @param [in] timeout_ms The timeout to wait before exiting
# @return a list
def recv(self, timeout_s):

#print("timeout_s passed to recv is " + str(timeout_s))
timeoutTimer = ResettableTimer(timeout_s)

payload = []
Expand Down
6 changes: 6 additions & 0 deletions uds/uds_communications/TransportProtocols/Can/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ channel=0

[socketcan]
channel=can0

[neovi]
channel=1

[kvaser]
channel=0
4 changes: 2 additions & 2 deletions uds/uds_communications/Uds/Uds.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def transferFile(self,fileName=None,transmitChunkSize=None,compressionMethod=Non

##
# @brief
def send(self, msg, responseRequired=True, functionalReq=False):
def send(self, msg, responseRequired=True, functionalReq=False,nodelay=False):
# sets a current transmission in progress - tester present (if running) will not send if this flag is set to true
self.__transmissionActive_flag = True
#print(("__transmissionActive_flag set:",self.__transmissionActive_flag))
Expand All @@ -129,7 +129,7 @@ def send(self, msg, responseRequired=True, functionalReq=False):
# We're moving to threaded operation, so putting a lock around the send operation.
self.sendLock.acquire()
try:
a = self.tp.send(msg, functionalReq)
a = self.tp.send(msg, functionalReq,nodelay)
finally:
self.sendLock.release()

Expand Down
11 changes: 8 additions & 3 deletions uds/uds_config_tool/IHexFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def __init__(self, filename=None, padding=0xFF, continuousBlocking=True):

if recordType == ihexRecordType.Data: # ... We match data first as it's the most common record type, so more efficient
if nextAddress is None:
currentBlock.startAddress = baseAddress + address
if currentBlock is None:
currentBlock = ihexData() #... start a new block
currentBlock.startAddress = address
else:
currentBlock.startAddress = baseAddress + address

# As each line of data is individually addressed, there may be disconuities present in the data.
# If so (i.e. a gap in the addressing), and a continuous record is required, then pad the data.
Expand Down Expand Up @@ -210,8 +214,9 @@ def __init__(self, filename=None, padding=0xFF, continuousBlocking=True):
raise NotImplemented("Start segment address not implemented")

elif recordType == ihexRecordType.StartLinearAddress:
hexFile.close()
raise NotImplemented("Start linear address not implemented")
print("Found a Start Linear Address - Ignoring")
#hexFile.close()
#raise NotImplemented("Start linear address not implemented")
hexFile.close()

@property
Expand Down
4 changes: 2 additions & 2 deletions uds/uds_configuration/defaultConfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ interface=virtual
baudrate=500
defaultReqId=0x600
defaultResId=0x650
P2_Client=1
P2_Server=1
P2_Client=3
P2_Server=3
P3_Client=1

[virtual]
Expand Down