Example #1
0
    def createTestResponse(self, request):
        '''
        Create an accurate example response for testing
        '''
        self.setPayloadId(protocol.RESPONSE_BASIC_DATALOG)

        # Generate 2 random shorts for each of the 27 variables
        binary = ''
        while len(binary) < (27 * 4):
            binary += protocols.shortTo8bit(random.randint(0,65535))
            binary += protocols.shortTo8bit(random.randint(0,65535))

        self.setPayload(binary)
Example #2
0
 def setPayload(self, payload):
     '''
     Save payload as 8bit string
     '''
     if payload == []:
         # Hack around the send thread turning an empty payload into a list
         return
     elif isinstance(payload, str):
         self._payload = payload
     else:
         self._payload = protocols.shortTo8bit(payload)
Example #3
0
 def getPayloadId(self):
     '''
     Return payload id as 8-bit string
     '''
     return protocols.shortTo8bit(self.getPayloadIdInt())
Example #4
0
 def getCalculatedPayloadLength(self):
     '''
     Return length of payload as 8 bit string
     '''
     return protocols.shortTo8bit(self.getCalculatedPayloadLengthInt())
Example #5
0
 def createTestResponse(self, request):
     '''
     Run code to make an acurate test response
     '''
     self.setPayloadId(protocol.RESPONSE_MAX_PACKET_SIZE)
     self.setPayload(protocols.shortTo8bit(255))