bool USB_ReceiveDataAck(ushort p_wCMD) { byte[] btCDB = new byte[8]; int[] nLen = new int[1]; int w_dwTimeOut = CommonDefine.COMM_TIMEOUT; byte[] w_WaitPacket = new byte[8]; byte[] w_pTmpBuf; if (p_wCMD == CommonDefine.CMD_VERIFY_CODE || p_wCMD == CommonDefine.CMD_IDENTIFY_CODE || p_wCMD == CommonDefine.CMD_IDENTIFY_FREE_CODE || p_wCMD == CommonDefine.CMD_ENROLL_CODE || p_wCMD == CommonDefine.CMD_ENROLL_ONETIME_CODE) { w_dwTimeOut = (CommonDefine.GD_MAX_FP_TIME_OUT + 1) * (1000); } CommandProc.memset(w_WaitPacket, 0xAF, 0, 8); CommandProc.memset(btCDB, 0, 0, 8); do { btCDB[0] = 0xEF; btCDB[1] = 0x15; nLen[0] = 6; if (!USBSCSIRead(btCDB, 8, CommandProc.m_pPacketBuffer, nLen, (uint)w_dwTimeOut)) { return(false); } Thread.Sleep(100); if (!CommandProc.DoEvents()) { return(false); } } while (CommandProc.memcmp(CommandProc.m_pPacketBuffer, w_WaitPacket, 6) == true); nLen[0] = CommandProc.GET_PACKET_LEN(false) + 2; w_pTmpBuf = new byte[nLen[0] + 10]; do { Array.Copy(CommandProc.m_pPacketBuffer, 6, w_pTmpBuf, 0, nLen[0]); if (!USB_ReceiveRawData(w_pTmpBuf, (uint)nLen[0])) { return(false); } Array.Copy(w_pTmpBuf, 0, CommandProc.m_pPacketBuffer, 6, nLen[0]); Thread.Sleep(5); if (!CommandProc.DoEvents()) { return(false); } } while (CommandProc.memcmp(CommandProc.m_pPacketBuffer, w_WaitPacket, 4) == true); return(MainWindow.m_clsCmdProc.CheckReceive(CommonDefine.RCM_DATA_PREFIX_CODE, p_wCMD)); }
public bool USB_SendPacket(ushort p_wCMD) { byte[] btCDB = new byte[8]; CommandProc.memset(btCDB, 0, 0, 8); btCDB[0] = 0xEF; btCDB[1] = 0x11; btCDB[4] = CommonDefine.ST_COM_PACKET_LEN + 2; if (!USBSCSIWrite(btCDB, 8, CommandProc.m_pPacketBuffer, CommonDefine.ST_COM_PACKET_LEN + 2, SCSI_TIMEOUT)) { return(false); } return(USB_ReceiveAck(p_wCMD, true)); }
public bool USB_ReceiveRawData(byte[] p_pBuffer, uint p_dwDataLen) { int[] w_nDataCnt = new int[1]; byte[] btCDB = new byte[8]; w_nDataCnt[0] = (int)p_dwDataLen; CommandProc.memset(btCDB, 0, 0, 8); btCDB[0] = 0xEF; btCDB[1] = 0x14; if (!USBSCSIRead(btCDB, 8, p_pBuffer, w_nDataCnt, SCSI_TIMEOUT)) { return(false); } return(true); }
public bool USB_SendDataPacket(ushort p_wCMD) { byte[] btCDB = new byte[8]; short w_wLen = (short)(CommandProc.GET_DATAPACKET_LEN(false) + 2); CommandProc.memset(btCDB, 0, 0, 8); btCDB[0] = 0xEF; btCDB[1] = 0x13; btCDB[4] = (byte)(w_wLen & 0xFF); btCDB[5] = (byte)(w_wLen >> 8); if (!USBSCSIWrite(btCDB, 8, CommandProc.m_pPacketBuffer, (uint)(CommandProc.GET_DATAPACKET_LEN(false) + 2), SCSI_TIMEOUT)) { return(false); } return(USB_ReceiveDataAck(p_wCMD)); }
public bool USB_ReceiveAck(ushort p_wCMD, bool p_bCmdData) { byte[] btCDB = new byte[8]; byte[] w_WaitPacket = new byte[24]; int[] nLen = new int[1]; int w_dwTimeOut = (int)SCSI_TIMEOUT; if (p_wCMD == CommonDefine.CMD_VERIFY_CODE || p_wCMD == CommonDefine.CMD_IDENTIFY_CODE || p_wCMD == CommonDefine.CMD_IDENTIFY_FREE_CODE || p_wCMD == CommonDefine.CMD_ENROLL_CODE || p_wCMD == CommonDefine.CMD_ENROLL_ONETIME_CODE) { w_dwTimeOut = (CommonDefine.GD_MAX_FP_TIME_OUT + 1) * (1000); } CommandProc.memset(w_WaitPacket, 0xAF, 0, CommonDefine.ST_COM_PACKET_LEN + 2); CommandProc.memset(btCDB, 0, 0, 8); do { CommandProc.memset(CommandProc.m_pPacketBuffer, 0, 0, CommonDefine.MAX_DATA_LEN + 10); btCDB[0] = 0xEF; btCDB[1] = 0x12; nLen[0] = CommonDefine.ST_COM_PACKET_LEN + 2; if (!USBSCSIRead(btCDB, 8, CommandProc.m_pPacketBuffer, nLen, (uint)w_dwTimeOut)) { return(false); } Thread.Sleep(100); if (!CommandProc.DoEvents()) { return(false); } } while (CommandProc.memcmp(CommandProc.m_pPacketBuffer, w_WaitPacket, CommonDefine.ST_COM_PACKET_LEN + 2) == true); if (p_bCmdData) { return(MainWindow.m_clsCmdProc.CheckReceive(CommonDefine.RCM_PREFIX_CODE, p_wCMD)); } else { return(MainWindow.m_clsCmdProc.CheckReceive(CommonDefine.RCM_DATA_PREFIX_CODE, p_wCMD)); } }
public bool USB_ReceiveImage(byte[] p_pBuffer, uint p_dwDataLen) { byte[] btCDB = new byte[8]; byte[] w_WaitPacket = new byte[8]; int[] w_nDataCnt = new int[1]; int[] w_nSentLen = new int[1]; byte[] w_pTmpBuf = new byte[ONCE_UP_IMAGE_UINT]; int w_nI; CommandProc.memset(w_WaitPacket, 0xAF, 0, 8); if (p_dwDataLen == 208 * 288 || p_dwDataLen == 242 * 266 || p_dwDataLen == 202 * 258 || p_dwDataLen == 256 * 288) { w_nDataCnt[0] = (int)p_dwDataLen; w_nI = 0; CommandProc.memset(btCDB, 0, 0, 8); while (w_nDataCnt[0] > ONCE_UP_IMAGE_UINT) { btCDB[0] = 0xEF; btCDB[1] = 0x16; btCDB[2] = (byte)w_nI; w_nSentLen[0] = (int)ONCE_UP_IMAGE_UINT; if (!USBSCSIRead(btCDB, 8, w_pTmpBuf, w_nSentLen, SCSI_TIMEOUT)) { return(false); } w_nDataCnt[0] -= (int)ONCE_UP_IMAGE_UINT; Array.Copy(w_pTmpBuf, 0, p_pBuffer, w_nI * ONCE_UP_IMAGE_UINT, ONCE_UP_IMAGE_UINT); w_nI++; } btCDB[0] = 0xEF; btCDB[1] = 0x16; btCDB[2] = (byte)w_nI; if (!USBSCSIRead(btCDB, 8, w_pTmpBuf, w_nDataCnt, SCSI_TIMEOUT)) { return(false); } Array.Copy(w_pTmpBuf, 0, p_pBuffer, w_nI * ONCE_UP_IMAGE_UINT, w_nDataCnt[0]); } return(true); }