def cardemu_write_ndef(self, ndef): """ Writes the NDEF messages that is to be transferred to the NFC peer. The maximum supported NDEF message size in Cardemu mode is 255 byte. You can call this function at any time in Cardemu mode. The internal buffer will not be overwritten until you call this function again or change the mode. """ ndef = list(map(int, ndef)) if len(ndef) > 65535: raise Error(Error.INVALID_PARAMETER, 'NDEF can be at most 65535 items long') ndef_length = len(ndef) ndef_chunk_offset = 0 if ndef_length == 0: ndef_chunk_data = [0] * 60 ret = self.cardemu_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) else: with self.stream_lock: while ndef_chunk_offset < ndef_length: ndef_chunk_data = create_chunk_data(ndef, ndef_chunk_offset, 60, 0) ret = self.cardemu_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) ndef_chunk_offset += 60 return ret
def cardemu_write_ndef(self, ndef): """ Writes the NDEF messages that is to be transferred to the NFC peer. The maximum supported NDEF message size in Cardemu mode is 255 byte. You can call this function at any time in Cardemu mode. The internal buffer will not be overwritten until you call this function again or change the mode. """ ndef = list(map(int, ndef)) if len(ndef) > 65535: raise Error(Error.INVALID_PARAMETER, 'NDEF can be at most 65535 items long') ndef_length = len(ndef) ndef_chunk_offset = 0 if ndef_length == 0: ndef_chunk_data = [0] * 60 ret = self.cardemu_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) else: with self.stream_lock: while ndef_chunk_offset < ndef_length: ndef_chunk_data = create_chunk_data(ndef, ndef_chunk_offset, 60, 0) ret = self.cardemu_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) ndef_chunk_offset += 60 return ret
def write_pixels(self, column_start, row_start, column_end, row_end, pixels): """ """ column_start = int(column_start) row_start = int(row_start) column_end = int(column_end) row_end = int(row_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 448 ret = self.write_pixels_low_level(column_start, row_start, column_end, row_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data(pixels, pixels_chunk_offset, 448, False) ret = self.write_pixels_low_level(column_start, row_start, column_end, row_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 448 return ret
def set_led_values(self, index, value): """ Sets the RGB(W) values for the LEDs starting from *index*. You can set at most 2048 RGB values or 1536 RGBW values (6144 byte each). To make the colors show correctly you need to configure the chip type (see :func:`Set Chip Type`) and a channel mapping (see :func:`Set Channel Mapping`) according to the connected LEDs. If the channel mapping has 3 colors, you need to give the data in the sequence RGBRGBRGB... if the channel mapping has 4 colors you need to give data in the sequence RGBWRGBWRGBW... The data is double buffered and the colors will be transfered to the LEDs when the next frame duration ends (see :func:`Set Frame Duration`). Generic approach: * Set the frame duration to a value that represents the number of frames per second you want to achieve. * Set all of the LED colors for one frame. * Wait for the :cb:`Frame Started` callback. * Set all of the LED colors for next frame. * Wait for the :cb:`Frame Started` callback. * And so on. This approach ensures that you can change the LED colors with a fixed frame rate. """ index = int(index) value = list(map(int, value)) if len(value) > 65535: raise Error(Error.INVALID_PARAMETER, 'Value can be at most 65535 items long') value_length = len(value) value_chunk_offset = 0 if value_length == 0: value_chunk_data = [0] * 58 ret = self.set_led_values_low_level(index, value_length, value_chunk_offset, value_chunk_data) else: with self.stream_lock: while value_chunk_offset < value_length: value_chunk_data = create_chunk_data( value, value_chunk_offset, 58, 0) ret = self.set_led_values_low_level( index, value_length, value_chunk_offset, value_chunk_data) value_chunk_offset += 58 return ret
def write_pixels(self, x_start, y_start, x_end, y_end, pixels): """ Writes pixels to the specified window. The x-axis goes from 0 to 127 and the y-axis from 0 to 63. The pixels are written into the window line by line top to bottom and each line is written from left to right. If automatic draw is enabled (default) the pixels are directly written to the screen. Only pixels that have actually changed are updated on the screen, the rest stays the same. If automatic draw is disabled the pixels are written to an internal buffer and the buffer is transferred to the display only after :func:`Draw Buffered Frame` is called. This can be used to avoid flicker when drawing a complex frame in multiple steps. Automatic draw can be configured with the :func:`Set Display Configuration` function. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 448 ret = self.write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data( pixels, pixels_chunk_offset, 448, False) ret = self.write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 448 return ret
def reader_write_page(self, page, data): """ Writes a maximum of 8192 bytes starting from the given page. How many pages are written depends on the tag type. The page sizes are as follows: * Mifare Classic page size: 16 byte * NFC Forum Type 1 page size: 8 byte * NFC Forum Type 2 page size: 4 byte * NFC Forum Type 3 page size: 16 byte * NFC Forum Type 4: No pages, page = file selection (CC or NDEF, see below) The general approach for writing to a tag is as follows: 1. Call :func:`Reader Request Tag ID` 2. Wait for state to change to *ReaderRequestTagIDReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) 3. If looking for a specific tag then call :func:`Reader Get Tag ID` and check if the expected tag was found, if it was not found got back to step 1 4. Call :func:`Reader Write Page` with page number and data 5. Wait for state to change to *ReaderWritePageReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) If you use a Mifare Classic tag you have to authenticate a page before you can write to it. See :func:`Reader Authenticate Mifare Classic Page`. NFC Forum Type 4 tags are not organized into pages but different files. We currently support two files: Capability Container file (CC) and NDEF file. Choose CC by setting page to 3 or NDEF by setting page to 4. """ page = int(page) data = list(map(int, data)) if len(data) > 65535: raise Error(Error.INVALID_PARAMETER, 'Data can be at most 65535 items long') data_length = len(data) data_chunk_offset = 0 if data_length == 0: data_chunk_data = [0] * 58 ret = self.reader_write_page_low_level(page, data_length, data_chunk_offset, data_chunk_data) else: with self.stream_lock: while data_chunk_offset < data_length: data_chunk_data = create_chunk_data(data, data_chunk_offset, 58, 0) ret = self.reader_write_page_low_level(page, data_length, data_chunk_offset, data_chunk_data) data_chunk_offset += 58 return ret
def reader_write_page(self, page, data): """ Writes a maximum of 8192 bytes starting from the given page. How many pages are written depends on the tag type. The page sizes are as follows: * Mifare Classic page size: 16 byte * NFC Forum Type 1 page size: 8 byte * NFC Forum Type 2 page size: 4 byte * NFC Forum Type 3 page size: 16 byte * NFC Forum Type 4: No pages, page = file selection (CC or NDEF, see below) The general approach for writing to a tag is as follows: 1. Call :func:`Reader Request Tag ID` 2. Wait for state to change to *ReaderRequestTagIDReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) 3. If looking for a specific tag then call :func:`Reader Get Tag ID` and check if the expected tag was found, if it was not found got back to step 1 4. Call :func:`Reader Write Page` with page number and data 5. Wait for state to change to *ReaderWritePageReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) If you use a Mifare Classic tag you have to authenticate a page before you can write to it. See :func:`Reader Authenticate Mifare Classic Page`. NFC Forum Type 4 tags are not organized into pages but different files. We currently support two files: Capability Container file (CC) and NDEF file. Choose CC by setting page to 3 or NDEF by setting page to 4. """ page = int(page) data = list(map(int, data)) if len(data) > 65535: raise Error(Error.INVALID_PARAMETER, 'Data can be at most 65535 items long') data_length = len(data) data_chunk_offset = 0 if data_length == 0: data_chunk_data = [0] * 58 ret = self.reader_write_page_low_level(page, data_length, data_chunk_offset, data_chunk_data) else: with self.stream_lock: while data_chunk_offset < data_length: data_chunk_data = create_chunk_data(data, data_chunk_offset, 58, 0) ret = self.reader_write_page_low_level(page, data_length, data_chunk_offset, data_chunk_data) data_chunk_offset += 58 return ret
def write_pixels(self, x_start, y_start, x_end, y_end, pixels): """ Writes pixels to the specified window. The x-axis goes from 0-127 and the y-axis from 0-63. The pixels are written into the window line by line from left to right. If automatic draw is enabled (default) the pixels are directly written to the screen and only changes are updated. If you only need to update a few pixels, only these pixels are updated on the screen, the rest stays the same. If automatic draw is disabled the pixels are written to a buffer and the buffer is transferred to the display only after :func:`Draw Buffered Frame` is called. Automatic draw can be configured with the :func:`Set Display Configuration` function. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 448 ret = self.write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data( pixels, pixels_chunk_offset, 448, False) ret = self.write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 448 return ret
def write_color(self, x_start, y_start, x_end, y_end, pixels): """ The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray. Depending on the model this function writes either red or gray pixels to the specified window into the buffer. The pixels are written into the window line by line top to bottom and each line is written from left to right. The value 0 (false) means that this pixel does not have color. It will be either black or white (see :func:`Write Black White`). The value 1 (true) corresponds to a red or gray pixel, depending on the Bricklet model. This function writes the pixels into the red or gray pixel buffer, to draw the buffer to the display use :func:`Draw`. Use :func:`Write Black White` to write black/white pixels. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 432 ret = self.write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data( pixels, pixels_chunk_offset, 432, False) ret = self.write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 432 return ret
def set_led_values(self, index, value): """ Sets the RGB(W) values for the LEDs starting from *index*. You can set at most 2048 RGB values or 1536 RGBW values. To make the colors show correctly you need to configure the chip type (see :func:`Set Chip Type`) and a channel mapping (see :func:`Set Channel Mapping`) according to the connected LEDs. If the channel mapping has 3 colors, you need to give the data in the sequence RGBRGBRGB... if the channel mapping has 4 colors you need to give data in the sequence RGBWRGBWRGBW... The data is double buffered and the colors will be transfered to the LEDs when the next frame duration ends (see :func:`Set Frame Duration`). Generic approach: * Set the frame duration to a value that represents the number of frames per second you want to achieve. * Set all of the LED colors for one frame. * Wait for the :cb:`Frame Started` callback. * Set all of the LED colors for next frame. * Wait for the :cb:`Frame Started` callback. * And so on. This approach ensures that you can change the LED colors with a fixed frame rate. """ index = int(index) value = list(map(int, value)) if len(value) > 65535: raise Error(Error.INVALID_PARAMETER, 'Value can be at most 65535 items long') value_length = len(value) value_chunk_offset = 0 if value_length == 0: value_chunk_data = [0] * 58 ret = self.set_led_values_low_level(index, value_length, value_chunk_offset, value_chunk_data) else: with self.stream_lock: while value_chunk_offset < value_length: value_chunk_data = create_chunk_data(value, value_chunk_offset, 58, 0) ret = self.set_led_values_low_level(index, value_length, value_chunk_offset, value_chunk_data) value_chunk_offset += 58 return ret
def write_frame(self, frame): """ Writes a DMX frame. The maximum frame size is 512 byte. Each byte represents one channel. The next frame can be written after the :cb:`Frame Started` callback was called. The frame is double buffered, so a new frame can be written as soon as the writing of the prior frame starts. The data will be transfered when the next frame duration ends, see :func:`Set Frame Duration`. Generic approach: * Set the frame duration to a value that represents the number of frames per second you want to achieve. * Set channels for first frame. * Wait for the :cb:`Frame Started` callback. * Set channels for next frame. * Wait for the :cb:`Frame Started` callback. * and so on. This approach ensures that you can set new DMX data with a fixed frame rate. This function can only be called in master mode. """ frame = list(map(int, frame)) if len(frame) > 65535: raise Error(Error.INVALID_PARAMETER, 'Frame can be at most 65535 items long') frame_length = len(frame) frame_chunk_offset = 0 if frame_length == 0: frame_chunk_data = [0] * 60 ret = self.write_frame_low_level(frame_length, frame_chunk_offset, frame_chunk_data) else: with self.stream_lock: while frame_chunk_offset < frame_length: frame_chunk_data = create_chunk_data( frame, frame_chunk_offset, 60, 0) ret = self.write_frame_low_level(frame_length, frame_chunk_offset, frame_chunk_data) frame_chunk_offset += 60 return ret
def write_black_white(self, x_start, y_start, x_end, y_end, pixels): """ Writes black/white pixels to the specified window into the buffer. The pixels are written into the window line by line top to bottom and each line is written from left to right. The value 0 (false) corresponds to a black pixel and the value 1 (true) to a white pixel. This function writes the pixels into the black/white pixel buffer, to draw the buffer to the display use :func:`Draw`. Use :func:`Write Color` to write red or gray pixels. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 432 ret = self.write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data( pixels, pixels_chunk_offset, 432, False) ret = self.write_black_white_low_level( x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 432 return ret
def write_pixels(self, x_start, y_start, x_end, y_end, pixels): """ Writes pixels to the specified window. The x-axis goes from 0 to 127 and the y-axis from 0 to 63. The pixels are written into the window line by line top to bottom and each line is written from left to right. If automatic draw is enabled (default) the pixels are directly written to the screen. Only pixels that have actually changed are updated on the screen, the rest stays the same. If automatic draw is disabled the pixels are written to an internal buffer and the buffer is transferred to the display only after :func:`Draw Buffered Frame` is called. This can be used to avoid flicker when drawing a complex frame in multiple steps. Automatic draw can be configured with the :func:`Set Display Configuration` function. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 448 ret = self.write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data(pixels, pixels_chunk_offset, 448, False) ret = self.write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 448 return ret
def write(self, message): """ Writes characters to the RS232 interface. The characters can be binary data, ASCII or similar is not necessary. The return value is the number of characters that were written. See :func:`Set Configuration` for configuration possibilities regarding baud rate, parity and so on. """ message = create_char_list(message) if len(message) > 65535: raise Error(Error.INVALID_PARAMETER, 'Message can be at most 65535 items long') message_length = len(message) message_chunk_offset = 0 if message_length == 0: message_chunk_data = ['\0'] * 60 ret = self.write_low_level(message_length, message_chunk_offset, message_chunk_data) message_written = ret else: message_written = 0 with self.stream_lock: while message_chunk_offset < message_length: message_chunk_data = create_chunk_data( message, message_chunk_offset, 60, '\0') ret = self.write_low_level(message_length, message_chunk_offset, message_chunk_data) message_written += ret if ret < 60: break # either last chunk or short write message_chunk_offset += 60 return message_written
def write_color(self, x_start, y_start, x_end, y_end, pixels): """ The E-Paper 296x128 Bricklet is available with the colors black/white/red and black/white/gray. Depending on the model this function writes either red or gray pixels to the specified window into the buffer. The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written into the window line by line top to bottom and each line is written from left to right. The value 0 (false) means that this pixel does not have color. It will be either black or white (see :func:`Write Black White`). The value 1 (true) corresponds to a red or gray pixel, depending on the Bricklet model. This function writes the pixels into the red or gray pixel buffer, to draw the buffer to the display use :func:`Draw`. Use :func:`Write Black White` to write black/white pixels. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 432 ret = self.write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data(pixels, pixels_chunk_offset, 432, False) ret = self.write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 432 return ret
def write_black_white(self, x_start, y_start, x_end, y_end, pixels): """ Writes black/white pixels to the specified window into the buffer. The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written into the window line by line top to bottom and each line is written from left to right. The value 0 (false) corresponds to a black pixel and the value 1 (true) to a white pixel. This function writes the pixels into the black/white pixel buffer, to draw the buffer to the display use :func:`Draw`. Use :func:`Write Color` to write red or gray pixels. """ x_start = int(x_start) y_start = int(y_start) x_end = int(x_end) y_end = int(y_end) pixels = list(map(bool, pixels)) if len(pixels) > 65535: raise Error(Error.INVALID_PARAMETER, 'Pixels can be at most 65535 items long') pixels_length = len(pixels) pixels_chunk_offset = 0 if pixels_length == 0: pixels_chunk_data = [False] * 432 ret = self.write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) else: with self.stream_lock: while pixels_chunk_offset < pixels_length: pixels_chunk_data = create_chunk_data(pixels, pixels_chunk_offset, 432, False) ret = self.write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data) pixels_chunk_offset += 432 return ret
def write(self, message): """ Writes characters to the RS232 interface. The characters can be binary data, ASCII or similar is not necessary. The return value is the number of characters that were written. See :func:`Set Configuration` for configuration possibilities regarding baud rate, parity and so on. """ message = create_char_list(message) if len(message) > 65535: raise Error(Error.INVALID_PARAMETER, 'Message can be at most 65535 items long') message_length = len(message) message_chunk_offset = 0 if message_length == 0: message_chunk_data = ['\0'] * 60 ret = self.write_low_level(message_length, message_chunk_offset, message_chunk_data) message_written = ret else: message_written = 0 with self.stream_lock: while message_chunk_offset < message_length: message_chunk_data = create_chunk_data(message, message_chunk_offset, 60, '\0') ret = self.write_low_level(message_length, message_chunk_offset, message_chunk_data) message_written += ret if ret < 60: break # either last chunk or short write message_chunk_offset += 60 return message_written
def reader_write_ndef(self, ndef): """ Writes NDEF formated data with a maximum of 255 bytes. This function currently supports NFC Forum Type 2 and 4. The general approach for writing a NDEF message is as follows: 1. Call :func:`Reader Request Tag ID` 2. Wait for state to change to *ReaderRequestTagIDReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) 3. If looking for a specific tag then call :func:`Reader Get Tag ID` and check if the expected tag was found, if it was not found got back to step 1 4. Call :func:`Reader Write NDEF` with the NDEF message that you want to write 5. Wait for state to change to *ReaderWriteNDEFReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) """ ndef = list(map(int, ndef)) if len(ndef) > 65535: raise Error(Error.INVALID_PARAMETER, 'NDEF can be at most 65535 items long') ndef_length = len(ndef) ndef_chunk_offset = 0 if ndef_length == 0: ndef_chunk_data = [0] * 60 ret = self.reader_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) else: with self.stream_lock: while ndef_chunk_offset < ndef_length: ndef_chunk_data = create_chunk_data(ndef, ndef_chunk_offset, 60, 0) ret = self.reader_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) ndef_chunk_offset += 60 return ret
def reader_write_ndef(self, ndef): """ Writes NDEF formated data with a maximum of 255 bytes. This function currently supports NFC Forum Type 2 and 4. The general approach for writing a NDEF message is as follows: 1. Call :func:`Reader Request Tag ID` 2. Wait for state to change to *ReaderRequestTagIDReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) 3. If looking for a specific tag then call :func:`Reader Get Tag ID` and check if the expected tag was found, if it was not found got back to step 1 4. Call :func:`Reader Write NDEF` with the NDEF message that you want to write 5. Wait for state to change to *ReaderWriteNDEFReady* (see :func:`Reader Get State` or :cb:`Reader State Changed` callback) """ ndef = list(map(int, ndef)) if len(ndef) > 65535: raise Error(Error.INVALID_PARAMETER, 'NDEF can be at most 65535 items long') ndef_length = len(ndef) ndef_chunk_offset = 0 if ndef_length == 0: ndef_chunk_data = [0] * 60 ret = self.reader_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) else: with self.stream_lock: while ndef_chunk_offset < ndef_length: ndef_chunk_data = create_chunk_data(ndef, ndef_chunk_offset, 60, 0) ret = self.reader_write_ndef_low_level(ndef_length, ndef_chunk_offset, ndef_chunk_data) ndef_chunk_offset += 60 return ret