<commit_before>import mraa as m


class SpiSerial():
    def __init__(self):
        self.cs0 = m.Gpio(23)
        self.cs0.dir(m.DIR_OUT)
        self.cs0.write(1)

        self.dev = m.spiFromDesc("spi-raw-5-1")
        self.dev.frequency(62500)
        self.dev.mode(m.SPI_MODE0)
        self.dev.bitPerWord(8)
        self.timeout = 0
        self.rx_buf = []

    def spi_xfer(self, b):
        tx = bytearray(1)
        tx[0] = (int('{:08b}'.format(b)[::-1], 2))
        self.cs0.write(0)
        rxbuf = self.dev.write(tx)
        self.cs0.write(1)
        return (int('{:08b}'.format(rxbuf[0])[::-1], 2))

    def close(self):
        pass

    def write(self, tx_bytes):
        tx_bytes = bytearray(tx_bytes)
        self.spi_xfer(0x99)
        num_rxd = self.spi_xfer(len(tx_bytes))
        for y in range(0, len(tx_bytes)):
            rx = self.spi_xfer(tx_bytes[y])
            if num_rxd > 0:
                self.rx_buf.append(rx)
                num_rxd -= 1
        for y in range(0, num_rxd):
            rx = self.spi_xfer(0)
            self.rx_buf.append(rx)

    def read(self, num_bytes=0):
        if num_bytes == 0:
            num_bytes = len(self.rx_buf)
        ret_val = self.rx_buf[0:num_bytes]
        del(self.rx_buf[0:num_bytes])
        return ret_val

    def inWaiting(self):
        self.spi_xfer(0x99)
        num_rxd = self.spi_xfer(0)
        for y in range(0, num_rxd):
            rx = self.spi_xfer(0)
            self.rx_buf.append(rx)
        return len(self.rx_buf)

    def reset(self):
        self.RST = m.Gpio(36)
        self.RST.dir(m.DIR_OUT)
        self.RST.write(1)<commit_msg>comment out reset as workaround for mmeowlink compatibility<commit_after>import mraa as m


class SpiSerial():
    def __init__(self):
        self.cs0 = m.Gpio(23)
        self.cs0.dir(m.DIR_OUT)
        self.cs0.write(1)

        self.dev = m.spiFromDesc("spi-raw-5-1")
        self.dev.frequency(62500)
        self.dev.mode(m.SPI_MODE0)
        self.dev.bitPerWord(8)
        self.timeout = 0
        self.rx_buf = []

    def spi_xfer(self, b):
        tx = bytearray(1)
        tx[0] = (int('{:08b}'.format(b)[::-1], 2))
        self.cs0.write(0)
        rxbuf = self.dev.write(tx)
        self.cs0.write(1)
        return (int('{:08b}'.format(rxbuf[0])[::-1], 2))

    def close(self):
        pass

    def write(self, tx_bytes):
        tx_bytes = bytearray(tx_bytes)
        self.spi_xfer(0x99)
        num_rxd = self.spi_xfer(len(tx_bytes))
        for y in range(0, len(tx_bytes)):
            rx = self.spi_xfer(tx_bytes[y])
            if num_rxd > 0:
                self.rx_buf.append(rx)
                num_rxd -= 1
        for y in range(0, num_rxd):
            rx = self.spi_xfer(0)
            self.rx_buf.append(rx)

    def read(self, num_bytes=0):
        if num_bytes == 0:
            num_bytes = len(self.rx_buf)
        ret_val = self.rx_buf[0:num_bytes]
        del(self.rx_buf[0:num_bytes])
        return ret_val

    def inWaiting(self):
        self.spi_xfer(0x99)
        num_rxd = self.spi_xfer(0)
        for y in range(0, num_rxd):
            rx = self.spi_xfer(0)
            self.rx_buf.append(rx)
        return len(self.rx_buf)

    #def reset(self):
        #self.RST = m.Gpio(36)
        #self.RST.dir(m.DIR_OUT)
        #self.RST.write(1)
{'fraction_non_alphanumeric': 0.13924050632911392, 'fraction_numerical': 0.03134418324291742, 'mean_word_length': 1.8174872665534805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4721275', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1279, 'n_words': 208}