/*---------------------------------------------------------------------------*/ static int uz2400_read(void *buf, unsigned short bufsize) { cyg_uint8 len; len = uz_rx(buf); if(len > UZ2400_MAX_PACKET_LEN) { /* Oops, we must be out of sync. */ return 0; } if(len <= AUX_LEN) { return 0; } if(len - AUX_LEN > bufsize) { return 0; } if(len < AUX_LEN) { return 0; } // still bug here, check the datasheet uz2400_last_rssi = buf+(len-1); uz2400_last_correlation = buf+(len-2); // LQI if(len < AUX_LEN) { return 0; } return len - AUX_LEN; }
/*---------------------------------------------------------------------------*/ static int uz2400_read(void *buf, unsigned short bufsize) { uint8_t len; len = uz_rx(buf); /*printf("================================\n"); printf("Reading\n"); printf("================================\n"); int i; for(i = 0; i < len; i++) printf("%2x ", *(UINT8 *)(buf+i)); printf("\n================================\n");*/ if(len > bufsize) { uz_rx_flush(); return 0; } if(len > UZ2400_MAX_PACKET_LEN) { /* Oops, we must be out of sync. */ return 0; } if(len <= AUX_LEN) { return 0; } if(len - AUX_LEN > bufsize) { return 0; } if(len < AUX_LEN) { return 0; } // still bug here, check the datasheet uz2400_last_rssi = buf+(len-1); uz2400_last_correlation = buf+(len-2); // LQI if(len < AUX_LEN) { return 0; } return len - AUX_LEN; //if(len > 0) process_poll(&uz2400_process); //printf("uz2400_read length: %d\n", len); return len; }