Skip to content

Commit

Permalink
Distribute messages from slave to queues.
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Apr 6, 2018
1 parent 97ae06a commit 28ae9fd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pyxcp/transport/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import abc
import queue
import struct
import time
import threading

from ..logger import Logger
Expand Down Expand Up @@ -85,14 +86,13 @@ def request(self, cmd, *data):
raise types.XcpTimeoutError("Response timed out.") from None
else:
raise types.XcpTimeoutError("Response timed out.")
self.resQueue.task_done()
self.resQueue.task_done() # TODO: move up!?
self.timing.stop()

pid = types.Response.parse(xcpPDU).type
if pid != 'OK' and pid == 'ERR':
if cmd.name != 'SYNCH':
err = types.XcpError.parse(xcpPDU[1 : ])
raise types.XcpResponseError(err)
if pid == 'ERR' and cmd.name != 'SYNCH':
err = types.XcpError.parse(xcpPDU[1 : ])
raise types.XcpResponseError(err)
else:
pass # Und nu??
return xcpPDU[1 : ]
Expand All @@ -118,5 +118,13 @@ def processResponse(self, response):
xcpPDU = response[4 : ]
if len(xcpPDU) != packetLen:
raise types.FrameSizeError("Size mismatch.")
self.resQueue.put(xcpPDU)
pid = xcpPDU[0]
if pid == 0xff or xcpPDU[0] == 0xfe:
self.resQueue.put(xcpPDU)
elif pid == 0xfd:
self.evQueue.put(xcpPDU)
elif pid == 0xfc:
self.servQueue.put(xcpPDU)
else:
self.daqQueue.put(xcpPDU)

0 comments on commit 28ae9fd

Please sign in to comment.