Beispiel #1
0
	def _initPackets(self):
		#status
		self.statusResponsePacket = packets.packet(template = [packets.pString('status', 1), #status is encoded as 'b' for bootloader, 'a' for app.
																packets.pInteger('appValidity', 1)]) #app validity byte, gets set to 170 if app is valid
		
		#bootloader command
		self.bootCommandRequestPacket = packets.packet(template = [packets.pInteger('commandCode', 1)])
		self.bootCommandResponsePacket = packets.packet(template = [	packets.pInteger('responseCode', 1),
																packets.pInteger('pageNumber', 2)])
		#bootloader write
		self.bootWriteRequestPacket = packets.packet(template = [packets.pInteger('commandCode', 1),
															packets.pInteger('pageNumber', 2),
															packets.pList('writeData', self.bootPageSize)])
		self.bootWriteResponsePacket = packets.packet(self.bootCommandResponsePacket)
		
		#bootloader read
		self.bootReadRequestPacket = packets.packet(template = [packets.pInteger('pageNumber', 2)])
		self.bootReadResponsePacket = packets.packet(template = [packets.pList('readData', self.bootPageSize)])
		
		#request URL
		self.urlResponsePacket = packets.packet(template = [packets.pString('URL')])
		
		#set IP address
		self.setIPRequestPacket = packets.packet(template = [packets.pList('setAddress',2)])
		self.setIPResponsePacket = packets.packet(self.urlResponsePacket)
Beispiel #2
0
		def __call__(self, port, outboundFunction = None, outboundPacket = None, inboundFunction = None, inboundPacket = None):
			newResponseFlag = threading.Event()
			packetHolder = packets.packetHolder()
			
			#---CREATE FUNCTION INSTANCES AND UPDATE ROUTE DICTIONARIES---				
			if outboundFunction != None:
				if outboundPacket != None: packetSet = packets.packetSet(outboundPacket)	#gives the outbound function a packetSet initialized with the provided packet as a template
				else: packetSet = packets.packetSet(packets.packet(template=[]))	#gives the outbound function a packetSet initialized with a blank packet as a template
				if type(outboundFunction) == type: setattr(self.virtualNode, outboundFunction.__name__, outboundFunction(virtualNode = self.virtualNode, 	#create function instance
																														packetSet = packetSet,	#define packet format
																														responseFlag = newResponseFlag,	#creates a common response flag for outbound and inbound functions
																														packetHolder = packetHolder)) #creates a common packet holder for outbound and inbound functions
				outboundFunction = getattr(self.virtualNode, outboundFunction.__name__)	#update outboundFuncton pointer in event that new instance was created
				self.outPorts.update({outboundFunction:port})	#bind port to outbound instance
				
			if inboundFunction != None:
				if inboundPacket != None: packetSet = packets.packetSet(inboundPacket)	#gives the inbound function a packetSet initialized with the provided packet as a template
				else: packetSet = packets.packetSet(packets.packet(template=[])) #gives the inbound function a packetSet initialized with a blank packet as a template
				if type(inboundFunction) == type: setattr(self.virtualNode, inboundFunction.__name__, inboundFunction(virtualNode = self.virtualNode,	#create function instance
																														packetSet = packetSet,	#define packet format
																														responseFlag = newResponseFlag,	#creates a common response flag for outbound and inbound functions
																														packetHolder = packetHolder)) #creates a common packet holder for outbound and inbound functions
				inboundFunction = getattr(self.virtualNode, inboundFunction.__name__)
				self.inPorts.update({port:inboundFunction})	#bind port to inbound instance
			else:	#create a default inbound function which will handle incoming packets.
				if inboundPacket != None: packetSet = packets.packetSet(inboundPacket)	#use provided inbound packet
				else: packetSet = packets.packetSet(packets.packet(template=[])) #create default blank packet
				inboundFunction = functions.serviceRoutine(virtualNode = self.virtualNode, packetSet = packetSet,
															responseFlag = newResponseFlag, packetHolder = packetHolder)
				self.inPorts.update({port:inboundFunction})
Beispiel #3
0
 def initPackets(self):
     self.additionRequestPacket = packets.packet(
         template=[packets.pInteger('a', 2),
                   packets.pInteger('b', 2)])
     self.additionResponsePacket = packets.packet(
         template=[packets.pInteger('response', 2)])
     pass
Beispiel #4
0
	def initPackets(self):
		self.getReferenceVoltageResponsePacket = packets.packet(template = [packets.pInteger('voltage',2)])
		
		self.spinRequestPacket = packets.packet(template = [packets.pInteger('majorSteps',1),
															packets.pInteger('directions',1),
															packets.pInteger('steps', 1),
															packets.pInteger('accel',1),
															packets.pInteger('accelSteps',1),
															packets.pInteger('decelSteps',1),
															packets.pInteger('sync', 1)])	#if >0, indicates that move is synchronous
				
		self.spinStatusPacket = packets.packet(template = [packets.pInteger('statusCode',1),
															packets.pInteger('currentKey',1),
															packets.pInteger('stepsRemaining',1),
															packets.pInteger('readPosition',1),
															packets.pInteger('writePosition',1)])
		
		self.setVelocityPacket = packets.packet(template = [packets.pInteger('velocity',2)])
Beispiel #5
0
    def initPackets(self):
        self.getReferenceVoltageResponsePacket = packets.packet(
            template=[packets.pInteger('voltage', 2)])

        self.spinRequestPacket = packets.packet(template=[
            packets.pInteger('majorSteps', 1),
            packets.pInteger('directions', 1),
            packets.pInteger('steps', 1),
            packets.pInteger('accel', 1),
            packets.pInteger('accelSteps', 1),
            packets.pInteger('decelSteps', 1),
            packets.pInteger('sync', 1)
        ])  #if >0, indicates that move is synchronous

        self.spinStatusPacket = packets.packet(template=[
            packets.pInteger('statusCode', 1),
            packets.pInteger('currentKey', 1),
            packets.pInteger('stepsRemaining', 1),
            packets.pInteger('readPosition', 1),
            packets.pInteger('writePosition', 1)
        ])

        self.setVelocityPacket = packets.packet(
            template=[packets.pInteger('velocity', 2)])
Beispiel #6
0
    def __init__(self, name=None, interface=None, owner=None):
        self.name = name  #name becomes important for networked gestalt
        self.owner = owner
        self.interface = interfaceShell(
            interface, self
        )  #uses the interfaceShell object for connecting to sub-interface

        self.receiveQueue = Queue.Queue()
        self.CRC = CRC()
        self.nodeManager = self.nodeManager(
        )  #used to map network addresses (physical devices) to nodes

        self.startInterfaceThreads(
        )  #this will start the receiver, packetRouter, channelPriority, and channelAccess threads.

        #define standard gestalt packet
        self.gestaltPacket = packets.packet(template=[
            packets.pInteger('startByte', 1),
            packets.pList('address', 2),
            packets.pInteger('port', 1),
            packets.pLength(),
            packets.pList('payload')
        ])
Beispiel #7
0
    def __init__(self, name=None, interface=None, owner=None):
        self.name = name  # name becomes important for networked gestalt
        self.owner = owner
        self.interface = interfaceShell(
            interface, self
        )  # uses the interfaceShell object for connecting to sub-interface

        self.receiveQueue = Queue.Queue()
        self.CRC = CRC()
        self.nodeManager = self.nodeManager()  # used to map network addresses (physical devices) to nodes

        self.startInterfaceThreads()  # this will start the receiver, packetRouter, channelPriority, and channelAccess threads.

        # define standard gestalt packet
        self.gestaltPacket = packets.packet(
            template=[
                packets.pInteger("startByte", 1),
                packets.pList("address", 2),
                packets.pInteger("port", 1),
                packets.pLength(),
                packets.pList("payload"),
            ]
        )
	def initPackets(self):
		self.additionRequestPacket = packets.packet(template = [packets.pInteger('a',2),
									packets.pInteger('b',2)])
		self.additionResponsePacket = packets.packet(template = [packets.pInteger('response',2)])
		pass