增加导出DLL工程。
This commit is contained in:
@@ -277,7 +277,7 @@ usb_dev_handle* CKeyence_Proto::_open_usb_dev(void)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
|
||||
SSI_STATUS CKeyence_Proto::_usb_reset(void)
|
||||
{
|
||||
if (g_dev)
|
||||
{
|
||||
@@ -287,9 +287,9 @@ SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
|
||||
else
|
||||
{
|
||||
ASSERT(0);
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
return SSI_STATUS_TIMEOUT;
|
||||
}
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
return SSI_STATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,12 +298,12 @@ SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
|
||||
// Send is direct and async.
|
||||
// The receive thread will receive data and interpret it.
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
|
||||
SSI_STATUS CKeyence_Proto::Init_MvUsb()
|
||||
{
|
||||
// Set initial state of the machine
|
||||
g_machine.s_status._machine_running = false;
|
||||
|
||||
SSI_STATUS_MOTION Status=SSI_STATUS_MOTION_NORMAL;
|
||||
SSI_STATUS Status=SSI_STATUS_NORMAL;
|
||||
UNREFERENCED_PARAMETER(Status);
|
||||
/*if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
g_pLogger->SendAndFlushPerMode(_T("Enter Initialize Mv Usb\n"));
|
||||
@@ -317,20 +317,20 @@ SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
|
||||
{
|
||||
MessageBox(NULL, _T("Unable to open device"), _T("Message"), MB_OK);
|
||||
g_pLogger->SendAndFlushPerMode(_T("Unable to open device %s"), usb_strerror());
|
||||
return SSI_STATUS_MOTION_DATALINK_ERROR;
|
||||
return SSI_STATUS_DATALINK_ERROR;
|
||||
}
|
||||
|
||||
if (usb_set_configuration(g_dev, MY_CONFIG) < 0)
|
||||
{
|
||||
MessageBox(NULL, _T("Unable to SET CONFIGURATION"), _T("Message"), MB_OK);
|
||||
return SSI_STATUS_MOTION_DATALINK_ERROR;
|
||||
return SSI_STATUS_DATALINK_ERROR;
|
||||
}
|
||||
|
||||
if (usb_claim_interface(g_dev, 0) < 0)
|
||||
{
|
||||
usb_close(g_dev);
|
||||
MessageBox(NULL, _T("Unable to CLAIM DEVICE"), _T("Message"), MB_OK);
|
||||
return SSI_STATUS_MOTION_DATALINK_ERROR;
|
||||
return SSI_STATUS_DATALINK_ERROR;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -413,13 +413,13 @@ SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
|
||||
|
||||
//if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
// g_pLogger->SendAndFlushPerMode(_T("Exit Initialize Usb\n"));
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::Exit_MvUsb()
|
||||
SSI_STATUS CKeyence_Proto::Exit_MvUsb()
|
||||
{
|
||||
SSI_STATUS_MOTION Status=SSI_STATUS_MOTION_NORMAL;
|
||||
SSI_STATUS Status=SSI_STATUS_NORMAL;
|
||||
//if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
// g_pLogger->SendAndFlushPerMode(_T("Enter Exit_MvUsb\n"));
|
||||
|
||||
@@ -500,7 +500,7 @@ SSI_STATUS_MOTION CKeyence_Proto::Exit_MvUsb()
|
||||
// Kick the g_hEP01_Thread_Event to get the g_EP01_Thread going.
|
||||
// iEP = EP_KEYENCE_01 or EP_KEYENCE_02 = 0x01 or 0x02
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_do_single_threaded_usb_comm(int iEP_Base)
|
||||
SSI_STATUS CKeyence_Proto::_do_single_threaded_usb_comm(int iEP_Base)
|
||||
{
|
||||
TRACE1("=====_do_single_threaded_usb_comm(iEP) g_hEP01_Thread_Event. %x\n", iEP_Base);
|
||||
while ((ep_buff[iEP_Base]._hProtoPending == TRUE) || (ep_buff[iEP_Base+1]._hProtoPending == TRUE))
|
||||
@@ -516,52 +516,52 @@ SSI_STATUS_MOTION CKeyence_Proto::_do_single_threaded_usb_comm(int iEP_Base)
|
||||
Sleep(3);
|
||||
}
|
||||
TRACE1("=====_do_single_threaded_usb_comm(iEP) g_hProtoDoneEvents. %x\n", iEP_Base);
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// This startup just kicks off the EP_KEYENCE_81 worker thread.
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_start_machine()
|
||||
SSI_STATUS CKeyence_Proto::_start_machine()
|
||||
{
|
||||
g_hEP81_Thread_State = THREAD_RUNNING;
|
||||
g_hEP82_Thread_State = THREAD_RUNNING;
|
||||
g_machine.s_status._machine_running = true;
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_shutdown_machine()
|
||||
SSI_STATUS CKeyence_Proto::_shutdown_machine()
|
||||
{
|
||||
g_machine.s_status._machine_running = false;
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
// iEP = EP_KEYENCE_01 or EP_KEYENCE_02
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_submit_async_8x(int iEP_Base)
|
||||
SSI_STATUS CKeyence_Proto::_submit_async_8x(int iEP_Base)
|
||||
{
|
||||
int _ret;
|
||||
_ret = usb_bulk_setup_async(g_dev, &(ep_buff[iEP_Base]._async_context), (unsigned char)ep_buff[iEP_Base]._ep);
|
||||
if (_ret < 0)
|
||||
{
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
return SSI_STATUS_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
_ret = usb_submit_async(ep_buff[iEP_Base]._async_context, ep_buff[iEP_Base]._buffer, ep_buff[iEP_Base]._size);
|
||||
if (_ret < 0)
|
||||
{
|
||||
printf("error usb_submit_async_ep_xx:\n%s\n", usb_strerror());
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
return SSI_STATUS_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
// iEP_Base : EP_81_DATA_IDX/EP_82_DATA_IDX
|
||||
//
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_reap_async_8x(int iEP_Base)
|
||||
SSI_STATUS CKeyence_Proto::_reap_async_8x(int iEP_Base)
|
||||
{
|
||||
int _ret;
|
||||
_ret = usb_reap_async(ep_buff[iEP_Base]._async_context, 1000);
|
||||
@@ -575,16 +575,16 @@ SSI_STATUS_MOTION CKeyence_Proto::_reap_async_8x(int iEP_Base)
|
||||
{
|
||||
usb_free_async(&(ep_buff[iEP_Base]._async_context));
|
||||
ASSERT(0);
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
return SSI_STATUS_TIMEOUT;
|
||||
}
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
// _send_usb_data(iEP) sends data to the corresponding iEP channel.
|
||||
// iEP = EP_KEYENCE_01 / EP_KEYENCE_02 EP_KEYENCE_01 = 0x01; EP_KEYENCE_02 = 0x02;
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
|
||||
SSI_STATUS CKeyence_Proto::_send_usb_data(int iEP_Base)
|
||||
{
|
||||
int _ret;
|
||||
ep_buff[iEP_Base]._save_send_cmd = ep_buff[iEP_Base]._buffer[0];
|
||||
@@ -595,13 +595,13 @@ SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
|
||||
_ret = usb_bulk_setup_async(g_dev, &(ep_buff[iEP_Base]._async_context), (unsigned char)ep_buff[iEP_Base]._ep);
|
||||
if (_ret < 0)
|
||||
{
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
return SSI_STATUS_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
_ret = usb_submit_async(ep_buff[iEP_Base]._async_context, ep_buff[iEP_Base]._buffer, ep_buff[iEP_Base]._size);//send data
|
||||
if (_ret < 0)
|
||||
{
|
||||
printf("error usb_submit_async_ep_xx:\n%s\n", usb_strerror());
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
return SSI_STATUS_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
TRACE1("_submit_async_8x(EP:%X)\r\n", iEP_Base);
|
||||
//
|
||||
@@ -624,13 +624,13 @@ SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
|
||||
{
|
||||
usb_free_async(&(ep_buff[iEP_Base]._async_context));
|
||||
ASSERT(0);
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
return SSI_STATUS_TIMEOUT;
|
||||
}
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_send_cmd_KEYENCE_CMD_GET_LASER_DATA()
|
||||
SSI_STATUS CKeyence_Proto::_send_cmd_KEYENCE_CMD_GET_LASER_DATA()
|
||||
{
|
||||
WaitForSingleObject(g_hEP01_Serial_Mutex, INFINITE);
|
||||
memset(ep_buff[EP_01_CMD_IDX]._buffer, 0x00, MAX_BUFF_SIZE);
|
||||
@@ -648,13 +648,13 @@ SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
|
||||
|
||||
_do_single_threaded_usb_comm(EP_01_CMD_IDX);
|
||||
ReleaseMutex(g_hEP01_Serial_Mutex);
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_process_KEYENCE_CMD_GET_LASER_DATA()
|
||||
SSI_STATUS CKeyence_Proto::_process_KEYENCE_CMD_GET_LASER_DATA()
|
||||
{
|
||||
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
return SSI_STATUS_NORMAL;
|
||||
};
|
||||
@@ -155,22 +155,22 @@ public:
|
||||
static CLogger* g_pLogger;
|
||||
static usb_dev_handle *g_dev;
|
||||
|
||||
SSI_STATUS_MOTION Init_MvUsb();
|
||||
SSI_STATUS_MOTION Exit_MvUsb();
|
||||
SSI_STATUS Init_MvUsb();
|
||||
SSI_STATUS Exit_MvUsb();
|
||||
static void Trace_EP_Buff(long lIndex);
|
||||
static void _process_rcv_transfer_data(int iEP);
|
||||
usb_dev_handle* _open_usb_dev(void);
|
||||
SSI_STATUS_MOTION _usb_reset(void);
|
||||
SSI_STATUS _usb_reset(void);
|
||||
|
||||
SSI_STATUS_MOTION _start_machine();
|
||||
SSI_STATUS_MOTION _shutdown_machine();
|
||||
SSI_STATUS_MOTION _do_single_threaded_usb_comm(int iEP);
|
||||
SSI_STATUS_MOTION _submit_async_8x(int iEP_Base);
|
||||
SSI_STATUS_MOTION _reap_async_8x(int iEP_Base);
|
||||
SSI_STATUS_MOTION _send_usb_data(int iEP_Base);
|
||||
SSI_STATUS _start_machine();
|
||||
SSI_STATUS _shutdown_machine();
|
||||
SSI_STATUS _do_single_threaded_usb_comm(int iEP);
|
||||
SSI_STATUS _submit_async_8x(int iEP_Base);
|
||||
SSI_STATUS _reap_async_8x(int iEP_Base);
|
||||
SSI_STATUS _send_usb_data(int iEP_Base);
|
||||
|
||||
SSI_STATUS_MOTION _send_cmd_KEYENCE_CMD_GET_LASER_DATA();
|
||||
static SSI_STATUS_MOTION _process_KEYENCE_CMD_GET_LASER_DATA();
|
||||
SSI_STATUS _send_cmd_KEYENCE_CMD_GET_LASER_DATA();
|
||||
static SSI_STATUS _process_KEYENCE_CMD_GET_LASER_DATA();
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user