<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_frame(self):
 """Convert the object to its frame format."""

        self.sanitize()
        res = []
        res.append((1 << 7) + (1 << 4) + (self.repeat << 5) +
                   (self.priority << 2))
        res.append(self.src_addr >> 8)
        res.append(self.src_addr % 0x100)
        res.append(self.dst_addr >> 8)
        res.append(self.dst_addr % 0x100)
        res.append((self.multicast << 7) + (self.routing << 4) + self.length)

        for i in range(0, self.length - 1):
            res.append(self.data[i])

        checksum = 0
        for i in range(0, 5 + self.length):
            checksum += res[i]

        res.append(checksum % 0x100)

        return bytearray(res)