extern "C" int VSCPBlockingReceive(long handle, vscpEvent *pEvent, unsigned long timeout) { int rv = 0; // Check pointer if ( NULL == pEvent) return CANAL_ERROR_PARAMETER; CRpiLCD *pdrvObj = theApp.getDriverObject(handle); if (NULL == pdrvObj) return CANAL_ERROR_MEMORY; struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = timeout * 1e6; if ( ETIMEDOUT == sem_timedwait( &pdrvObj->m_semaphore_ReceiveQueue, &ts ) ) { return CANAL_ERROR_TIMEOUT; } pthread_mutex_lock( &pdrvObj->m_mutex_ReceiveQueue ); vscpEvent *pLocalEvent = pdrvObj->m_receiveList.front(); pdrvObj->m_receiveList.pop_front(); pthread_mutex_unlock( &pdrvObj->m_mutex_ReceiveQueue ); if ( NULL == pLocalEvent ) return CANAL_ERROR_MEMORY; vscp_copyVSCPEvent( pEvent, pLocalEvent ); vscp_deleteVSCPevent( pLocalEvent ); return CANAL_ERROR_SUCCESS; }
extern "C" int VSCPBlockingReceive(long handle, vscpEvent *pEvent, unsigned long timeout) { int rv = 0; // Check pointer if ( NULL == pEvent) return CANAL_ERROR_PARAMETER; CTcpipLink *pdrvObj = theApp.getDriverObject(handle); if (NULL == pdrvObj) return CANAL_ERROR_MEMORY; if ( wxSEMA_TIMEOUT == pdrvObj->m_semReceiveQueue.WaitTimeout( timeout ) ) { return CANAL_ERROR_TIMEOUT; } //VSCPEVENTLIST_RECEIVE::compatibility_iterator nodeClient; pdrvObj->m_mutexReceiveQueue.Lock(); //nodeClient = pdrvObj->m_receiveQueue.GetFirst(); //vscpEvent *pLocalEvent = nodeClient->GetData(); vscpEvent *pLocalEvent = pdrvObj->m_receiveList.front(); pdrvObj->m_receiveList.pop_front(); pdrvObj->m_mutexReceiveQueue.Unlock(); if (NULL == pLocalEvent) return CANAL_ERROR_MEMORY; vscp_copyVSCPEvent( pEvent, pLocalEvent ); //pdrvObj->m_receiveQueue.DeleteNode(nodeClient); vscp_deleteVSCPevent( pLocalEvent ); return CANAL_ERROR_SUCCESS; }
extern "C" int VSCPBlockingReceive(long handle, vscpEvent *pEvent, unsigned long timeout) { int rv = 0; // Check pointer if (NULL == pEvent) return CANAL_ERROR_PARAMETER; Cmqttobj *pdrvObj = theApp.getDriverObject(handle); if (NULL == pdrvObj) return CANAL_ERROR_MEMORY; if (wxSEMA_TIMEOUT == pdrvObj->m_semReceiveQueue.WaitTimeout(timeout)) { return CANAL_ERROR_TIMEOUT; } pdrvObj->m_mutexReceiveQueue.Lock(); vscpEvent *pLocalEvent = pdrvObj->m_receiveList.front(); pdrvObj->m_receiveList.pop_front(); pdrvObj->m_mutexReceiveQueue.Unlock(); if (NULL == pLocalEvent) return CANAL_ERROR_MEMORY; vscp_copyVSCPEvent(pEvent, pLocalEvent); vscp_deleteVSCPevent(pLocalEvent); return CANAL_ERROR_SUCCESS; }
extern "C" int VSCPBlockingSend(long handle, const vscpEvent *pEvent, unsigned long timeout) { int rv = 0; Cmqttobj *pdrvObj = theApp.getDriverObject(handle); if (NULL == pdrvObj) return CANAL_ERROR_MEMORY; pdrvObj->addEvent2SendQueue(pEvent); return CANAL_ERROR_SUCCESS; }
extern "C" int VSCPClose(long handle) { int rv = 0; CRpiLCD *pdrvObj = theApp.getDriverObject(handle); if (NULL == pdrvObj) return CANAL_ERROR_MEMORY; pdrvObj->close(); theApp.removeDriverObject(handle); rv = 1; return CANAL_ERROR_SUCCESS; }
extern "C" int VSCPBlockingSend(long handle, const vscpEvent *pEvent, unsigned long timeout) { int rv = 0; CTcpipLink *pdrvObj = theApp.getDriverObject(handle); if (NULL == pdrvObj) return CANAL_ERROR_MEMORY; //vscpEvent *pEventNew = new vscpEvent; //if ( NULL != pEventNew ) { // copyVSCPEvent( pEventNew, pEvent ); pdrvObj->addEvent2SendQueue( pEvent ); //} //else { // return CANAL_ERROR_MEMORY; //} return CANAL_ERROR_SUCCESS; }