Exemplo n.º 1
0
		/// <summary> Redirect the specifed page in the current memory bank to a new page.
		/// Not supported by all devices.  See the method 'canRedirectPage()'.
		/// 
		/// </summary>
		/// <param name="page">     number of page to redirect
		/// </param>
		/// <param name="newPage">  new page number to redirect to
		/// 
		/// </param>
		/// <throws>  OneWireIOException </throws>
		/// <throws>  OneWireException </throws>
		public virtual void  redirectPage(int page, int newPage)
		{
			
			// create byte to redirect page
			byte[] wr_byte = new byte[1];
			
			wr_byte[0] = (byte) ~ newPage;
			
			// writing byte so turn on write verification
			mbRedirect.WriteVerification = true;
			
			// write the redirection byte
			mbRedirect.write(page + redirectOffset, wr_byte, 0, 1);
		}
Exemplo n.º 2
0
		/// <summary> Lock the redirection option for the specifed page in the current
		/// memory bank. Not supported by all devices.  See the method
		/// 'canLockRedirectPage()'.
		/// 
		/// </summary>
		/// <param name="page">     number of page to redirect
		/// 
		/// </param>
		/// <throws>  OneWireIOException </throws>
		/// <throws>  OneWireException </throws>
		public virtual void  lockRedirectPage(int page)
		{
			
			// create byte to write to mlLock to lock page
			int nbyt = (SupportClass.URShift(page, 3));
			int nbit = page - (nbyt << 3);
			byte[] wr_byte = new byte[1];
			
			wr_byte[0] = (byte) ~ (0x01 << nbit);
			
			// bit field so turn off write verification
			mbLockRedirect.WriteVerification = false;
			
			// write the lock bit
			mbLockRedirect.write(nbyt + lockRedirectOffset, wr_byte, 0, 1);
			
			// read back to verify
			if (!isRedirectPageLocked(page))
			{
				forceVerify();
				
				throw new OneWireIOException("Read back from write incorrect, could not lock redirect byte");
			}
		}