def write(self, page, data):
        """Send a WRITE command to store data on the tag.

        The *page* argument specifies the offset in multiples of 4
        bytes. The *data* argument must be a string or bytearray of
        length 4.

        Command execution errors raise :exc:`Type2TagCommandError`.

        """
        if len(data) != 4:
            raise ValueError("data must be a four byte string or array")

        log.debug("write {0} to page {1}".format(hexlify(data), page))
        rsp = self.transceive("\xA2" + chr(page % 256) + data)

        if len(rsp) != 1:
            log.debug("invalid response " + hexlify(data))
            raise Type2TagCommandError(INVALID_RESPONSE_ERROR)

        if rsp[0] != 0x0A:  # NAK
            log.debug("invalid page, received nak")
            raise Type2TagCommandError(INVALID_PAGE_ERROR)

        return True
def write ( self , page , data ) : if len ( data ) != 4 : raise ValueError ( "data must be a four byte string or array" ) log . debug ( "write {0} to page {1}" . format ( hexlify ( data ) , page ) ) rsp = self . transceive ( "\xA2" + chr ( page % 256 ) + data ) if len ( rsp ) != 1 : log . debug ( "invalid response " + hexlify ( data ) ) raise Type2TagCommandError ( INVALID_RESPONSE_ERROR ) if rsp [ 0 ] != 0x0A : log . debug ( "invalid page, received nak" ) raise Type2TagCommandError ( INVALID_PAGE_ERROR ) return True
Send a WRITE command to store data on the tag.

        The *page* argument specifies the offset in multiples of 4
        bytes. The *data* argument must be a string or bytearray of
        length 4.

        Command execution errors raise :exc:`Type2TagCommandError`.