예제 #1
0
        public static int SL_CommBase_MassRead(uint wCmd, int wCmdLen, ref byte[] xferBuf, int xbufLen)
        {
            if (xferBuf.Length < xbufLen)
            {
                return(Chip.ERROR_BUFLEN_ERR);
            }
            if (wCmdLen < 1 || wCmdLen > 4)
            {
                return(Chip.ERROR_BUFLEN_ERR);
            }
            if (!SL_AddrWrite(ADDRWRMODE))
            {
                return(Chip.ERROR_DISADDRWR);
            }
            for (int i = wCmdLen; i > 0; i--)
            {
                if (!SL_DataWrite((byte)((wCmd >> (8 * (wCmdLen - 1))) & 0xff)))
                {
                    return(Chip.ERROR_DISDATAWR);
                }
            }

            if (!SL_AddrWrite(DATARDMODE))
            {
                return(Chip.ERROR_DISDATAWR);
            }
            IntPtr ReadBackDatapPtr = Marshal.AllocHGlobal(xbufLen);
            bool   ret = Epp2USB.UsbReadScanner(ReadBackDatapPtr, (uint)xbufLen, RWSCANNER_EPPCTL_8BIT);

            Marshal.Copy(ReadBackDatapPtr, xferBuf, 0, xbufLen); //ReadBackDatapPtr to xferBuf
            Marshal.FreeHGlobal(ReadBackDatapPtr);
            return((ret == true) ? Chip.ERROR_RESULT_OK : Chip.ERROR_RESULT_FAIL);
        }
예제 #2
0
        public static int SL_CommBase_MassRead(ref byte[] xferBuf, int xbufLen, bool Mass)
        {
            bool ret = true;

            if (!SL_AddrWrite(DATARDMODE))
            {
                return(Chip.ERROR_DISDATAWR);
            }
            if (Mass)
            {
                IntPtr ReadBackDatapPtr = Marshal.AllocHGlobal(xbufLen);
                ret = Epp2USB.UsbReadScanner(ReadBackDatapPtr, (uint)xbufLen, RWSCANNER_EPPCTL_8BIT);
                Marshal.Copy(ReadBackDatapPtr, xferBuf, 0, xbufLen); //ReadBackDatapPtr to xferBuf
                Marshal.FreeHGlobal(ReadBackDatapPtr);
            }
            else
            {
                for (int i = 0; i < xbufLen; i++)
                {
                    xferBuf[i] = SL_DataRead();
                }
            }
            return((ret == true) ? Chip.ERROR_RESULT_OK : Chip.ERROR_RESULT_FAIL);
        }