Index: DialysateGenerator.py =================================================================== diff -u -r085c19600947145ec02a4baccba379bdbf6844af -r8994bbc8683f5ddc74ccfedaeeb6ae6f73f45ea3 --- DialysateGenerator.py (.../DialysateGenerator.py) (revision 085c19600947145ec02a4baccba379bdbf6844af) +++ DialysateGenerator.py (.../DialysateGenerator.py) (revision 8994bbc8683f5ddc74ccfedaeeb6ae6f73f45ea3) @@ -14,8 +14,8 @@ # ############################################################################ -from DialityCoreSerialProtocol import DialitySerialMessenger -from DialityCoreSerialProtocol import DialityPacket +from DialityCoreCanProtocol import DialityCanMessenger +from DialityCoreCanProtocol import DialityPacket from time import sleep @@ -36,22 +36,22 @@ """ - def __init__(self, port="/dev/ttyUSB0"): + def __init__(self, can__interface="can0"): """ - DG constructor using serial port name + DG constructor using can bus - \param port: serial port name, e.g. "/dev/ttyUSB0" + \param bus: can bus, e.g. "can0" \returns DG object that allows communication with board via port \details For example: - dg_object = DG(port='/dev/ttyUSB69') or - dg_object = DG('/dev/ttyUSB69') + dg_object = DG(can__interface='can0') or + dg_object = DG('can0') """ # Create listener - self.__serialPort = DialitySerialMessenger(serial_port=port) - self.__serialPort.start() + self.__can_interface = DialityCanMessenger(can_interface=can__interface) + self.__can_interface.start() def fill(self): """ @@ -60,56 +60,49 @@ \returns True if ran the command, False otherwise """ - requestID = 3 - cargo = bytearray() + channel_id = 0x01 + requestID = 0x03 + cargo=[] - message = DialityPacket.buildPacket(request_id=requestID, cargo=cargo) + packet = DialityPacket.buildPacket(request_id=requestID, cargo=cargo) - print("fill") + print(">f",end='') # Send message - received_message = self.__serialPort.send(message) + received_packet = self.__can_interface.send(channel_id, packet) - if len(received_message) != 0: + if packet is not None: - print("Return:" + str(received_message[4])) + print(str(received_packet[4]),'<', end='') - return received_message[4] + return received_packet[4] else: print("Timeout!!!!") return False - def registerAsyncReceiver(self, message_id, method): - self.__serialPort.registerAsyncFunction(message_id, method) + def registerSyncReceiver(self, channel_id, request_id, method): + self.__can_interface.registerSyncFunction(channel_id, request_id, method) - def registerSyncReceiver(self, message_id, method): - self.__serialPort.registerSyncFunction(message_id, method) - -def async_function(message): - print("x", end="", flush=True) - - -def sync_function(message): +def test_sync_function(packet): print("s", end="", flush=True) if __name__ == "__main__": - thedg = DG() # \var thedg - thedg.registerAsyncReceiver(2, async_function) - thedg.registerSyncReceiver(5, sync_function) + test_dg = DG() + test_dg.registerSyncReceiver(0x01, 0x05, test_sync_function) sleep(2) - thedg.fill() + test_dg.fill() sleep(2) - thedg.fill() + test_dg.fill() sleep(1) - thedg.fill() + test_dg.fill() sleep(2) - thedg.fill() + test_dg.fill() Index: document/Doxyfile =================================================================== diff -u -r51197ba092f454f59d3e9da522c1806020a31e6e -r8994bbc8683f5ddc74ccfedaeeb6ae6f73f45ea3 --- document/Doxyfile (.../Doxyfile) (revision 51197ba092f454f59d3e9da522c1806020a31e6e) +++ document/Doxyfile (.../Doxyfile) (revision 8994bbc8683f5ddc74ccfedaeeb6ae6f73f45ea3) @@ -51,14 +51,14 @@ # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = /home/fw/PycharmProjects/Dialin2/document/logo.jpg +PROJECT_LOGO = $(PROJECT_DIRECTORY)/document/logo.jpg # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = $(OUTPUT_DIRECTORY) # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -2499,4 +2499,4 @@ OPTIMIZE_OUTPUT_JAVA = YES EXTRACT_ALL = YES FILE_PATTERNS = "*.py" -INPUT = "/home/fw/PycharmProjects/Dialin2" +INPUT = "$(PROJECT_DIRECTORY)"