def _got_sol_payload(self, payload):
        """SOL payload callback
        """
        #TODO(jbjohnso) test cases to throw some likely scenarios at functions
        #for example, retry with new data, retry with no new data
        #retry with unexpected sequence number
        if type(payload) == dict:  # we received an error condition
            self.activated = False
            self._print_error(payload)
            return
        newseq = payload[0] & 0b1111
        ackseq = payload[1] & 0b1111
        ackcount = payload[2]
        nacked = payload[3] & 0b1000000
        poweredoff = payload[3] & 0b100000
        deactivated = payload[3] & 0b10000
        breakdetected = payload[3] & 0b100
        #for now, ignore overrun.  I assume partial NACK for this reason or for
        #no reason would be treated the same, new payload with partial data
        remdata = ""
        remdatalen = 0
        if newseq != 0:  # this packet at least has some data to send to us..
            if len(payload) > 4:
                remdatalen = len(payload[4:])  # store remote len before dupe
                    #retry logic, we must ack *this* many even if it is
                    #a retry packet with new partial data
                remdata = struct.pack("%dB" % remdatalen, *payload[4:])
            if newseq == self.remseq:  # it is a retry, but could have new data
                if remdatalen > self.lastsize:
                    remdata = remdata[4 + self.lastsize:]
                else:  # no new data...
                    remdata = ""
            else:  # TODO(jbjohnso) what if remote sequence number is wrong??
                self.remseq = newseq
            self.lastsize = remdatalen
            if remdata:  # Do not subject callers to empty data
                self._print_data(remdata)
            ackpayload = (0, self.remseq, remdatalen, 0)
            #Why not put pending data into the ack? because it's rare
            #and might be hard to decide what to do in the context of
            #retry situation
            try:
                self.send_payload(ackpayload, retry=False)
            except exc.IpmiException:
                #if the session is broken, then close the SOL session
                self.close()
        if self.myseq != 0 and ackseq == self.myseq:  # the bmc has something
                                                      # to say about last xmit
            self.awaitingack = False
            if nacked and not breakdetected:  # the BMC was in some way unhappy
                if poweredoff:
                    self._print_info("Remote system is powered down")
                if deactivated:
                    self.activated = False
                    self._print_error("Remote IPMI console disconnected")
                else:  # retry all or part of packet, but in a new form
                    # also add pending output for efficiency and ease
                    newtext = self.lastpayload[4 + ackcount:]
                    newtext = struct.pack("B"*len(newtext), *newtext)
                    if (self.pendingoutput and
                            not isinstance(self.pendingoutput[0], dict)):
                        self.pendingoutput[0] = newtext + self.pendingoutput[0]
                    else:
                        self.pendingoutput = [newtext] + self.pendingoutput
                    self._sendpendingoutput()
            if len(self.pendingoutput) > 0:
                self._sendpendingoutput()
        elif ackseq != 0 and self.awaitingack:
            # if an ack packet came in, but did not match what we
            # expected, retry our payload now.
            # the situation that was triggered was a senseless retry
            # when data came in while we xmitted.  In theory, a BMC
            # should handle a retry correctly, but some do not, so
            # try to mitigate by avoiding overeager retries
            # occasional retry of a packet
            # sooner than timeout suggests is evidently a big deal
            self.send_payload(payload=self.lastpayload)
dataset/ETHPy150Open openstack/pyghmi/pyghmi/ipmi/console.py/Console._got_sol_payload/original