Example #1
0
    def parseDeviceReadResponse(self, deviceID: int, completionID: int,
                                ioStatus: int,
                                stream: BytesIO) -> DeviceReadResponsePDU:
        length = Uint32LE.unpack(stream)
        payload = stream.read(length)

        return DeviceReadResponsePDU(deviceID, completionID, ioStatus, payload)
Example #2
0
 def parseReadResponse(self, pdu: DeviceIOResponsePDU) -> DeviceReadResponsePDU:
     """
     Starts at length (just before readData). This one is a bit special since we need
     to look at previous packet before parsing it as a read response, and we need the packet data.
     """
     stream = BytesIO(pdu.payload)
     length = Uint32LE.unpack(stream)
     readData = stream.read(length)
     return DeviceReadResponsePDU(pdu.deviceId, pdu.completionId, pdu.ioStatus, readData)