# Dynamicaly changes data of message from Send Tab # Message from Send tab is sent to virtual channel # The Python code reads the message, changes it, and sends it on a real channel # One bit in the message is toggled for every other message togglebit = 0 # Function handling incoming signals def recvFunc(canmsg): # Create a global variable global togglebit # Toggle bit for specific channel if (canmsg.Channel == 2 and canmsg.Id == 52): original = canmsg.Data[:] if togglebit == 0: togglebit = 1 canmsg.Data[3] = 128 # Changes one bit in data else: togglebit = 0 ctapi.Send(1, canmsg) # Sends toggled data to channel 1 canmsg.Data = original # Returns original msg back to original state return True