Exemplo n.º 1
0
        /// <summary>
        /// Read a 32-bit register value.
        /// </summary>
        /// <param name="rtReg">Register pair's  (2 x 16-bit register) address</param>
        /// <returns>The 32-bit register value.</returns>
        /// <remarks>The result is in little-endian format so there is no need to do any additional conversions.</remarks>
        /// <exception cref="NurApiException">
        /// <para>This exception is thrown when the underlying physical read fails.</para>
        /// <para>Exception can also be thrown if the tag reports an error e.g. "out of range"</para>
        /// </exception>
        /// <exception cref="IndexOutOfRangeException">This exception is thrown if the read is out of the register address space.</exception>
        public uint ReadUInt32Reg(uint rtReg)
        {
            RTConst.RegRangeCheck(rtReg, "ReadUInt32Reg", RTConst.RW_32BIT);

            byte[] b;

            b = ReadTag(mPassword, mSecured, NurApi.BANK_USER, rtReg, 4);

            return(RTConverters.BytesToUInt32(b));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write a single 16-bit register.
        /// </summary>
        /// <param name="rtReg">Register to write, <seealso cref="RTRegs"/>.</param>
        /// <param name="wValue">Value to write.</param>
        /// <remarks>
        /// <para>See also: <seealso cref="Secured"/>, <seealso cref="Password"/></para>
        /// <para>The data to write is internally converted to the tag's big-endian format so there is no need for additional conversions.</para>
        /// </remarks>
        /// <exception cref="NurApiException">
        /// <para>This exception is thrown when the underlying physical write fails.</para>
        /// <para>Exception can also be thrown if the tag reports an error e.g. "out of range"</para>
        /// </exception>
        public void WriteShortReg(uint rtReg, ushort wValue)
        {
            RTConst.RegRangeCheck(rtReg, "WriteShortReg", RTConst.RW_16BIT);

            byte[] b;

            b = RTConverters.UInt16ToBytes(wValue);

            WriteTag(mPassword, mSecured, NurApi.BANK_USER, rtReg, b);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Read a 16-bit register.
        /// </summary>
        /// <param name="rtReg">Register value to read, <seealso cref="RTRegs"/>.</param>
        /// <returns>This call returns the 16-bit value of the register.</returns>
        /// <remarks>NOTE: this result is internally converted to little-endian format; no need to re-convert.</remarks>
        /// <exception cref="NurApiException">
        /// <para>This exception is thrown when the underlying physical read fails.</para>
        /// <para>Exception can also be thrown if the tag reports an error e.g. "out of range"</para>
        /// </exception>
        public ushort ReadShortReg(uint rtReg)
        {
            RTConst.RegRangeCheck(rtReg, "ReadShortReg", RTConst.RW_16BIT);

            byte[] b;

            b = ReadTag(mPassword, mSecured, NurApi.BANK_USER, rtReg, 2);

            return(RTConverters.BytesToUInt16(b));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Read multiple 16-bit registers at once.
        /// </summary>
        /// <param name="firstAddr">First register to read, <seealso cref="RTRegs"/>.</param>
        /// <param name="regCount">Number of registers to read.</param>
        /// <returns>An array of unsigned 16-bit register that were read.</returns>
        /// <remarks></remarks>
        /// <exception cref="NurApiException">This exception is thrown when the underlying physical read fails.</exception>
        /// <exception cref="RTException">
        /// <para>This exception is thrown when the number of registers is out of range, <seealso cref="RTConst.MIN_RD_COUNT"/>, <seealso cref="RTConst.MAX_RD_COUNT"/>.</para>
        /// </exception>
        /// <exception cref="RTException">
        /// <para>This exception is thrown if the total reading exceeds the last memory position, <seealso cref="RTConst.LOG_AREA_LAST"/></para>
        /// </exception>
        public ushort [] ReadMultipleRegs(uint firstAddr, int regCount)
        {
            RTConst.RegRangeCheck(firstAddr, "ReadMultipleRegs", RTConst.RW_16BIT);
            RTConst.RegRangeCheck((uint)(firstAddr + regCount), "ReadMultipleRegs: read length is out of range.", RTConst.RW_16BIT);
            RTConst.RWCountCheck(regCount, "ReadMultipleRegs");

            byte [] data;

            data = ReadTag(mPassword, mSecured, NurApi.BANK_USER, firstAddr, (regCount * 2));

            return(RTConverters.BytesToUInt16Arr(data));
        }