/* Call this to pull data from the receive buffer for ghost nodes.. */ int ghost_get(uint8_t max_pkt, struct lgw_pkt_rx_s *pkt_data) { /* Calculate the number of available packets */ pthread_mutex_lock(&cb_ghost); uint8_t avail = (ghst_bgn - ghst_end + GHST_NM_RCV) % GHST_NM_RCV; pthread_mutex_unlock(&cb_ghost); /* Calculate the number of packets that we may or can copy */ uint8_t get_pkt = (avail<max_pkt) ? avail : max_pkt; /* Do the actual copying, take into account that the read buffer is circular. */ int i; for (i=0; i<get_pkt; i++) { int ind = (ghst_end + i) % GHST_NM_RCV; readRX(&pkt_data[i],(buffRX+ind*GHST_RX_BUFFSIZE)); } /* Shift the end index of the read buffer to the new position. */ pthread_mutex_lock(&cb_ghost); ghst_end = (ghst_end + get_pkt) % GHST_NM_RCV; pthread_mutex_unlock(&cb_ghost); if (get_pkt>0) { MSG("INFO: copied %i packets from ghost, ghst_end = %i \n",get_pkt,ghst_end); // To get more info enable this //for (i=0; i<get_pkt; i++) //{ printf("packet %i\n",i); // printRX(&pkt_data[i]); } } /* return the number of packets that where copied. */ return get_pkt; }
/*! \brief SerialDevice::syncRX Is the serial interface's implementation of syncRX. * Same functionality as readRX. */ void SerialDevice::syncRX() { readRX(); }