|
|
@ -32,12 +32,13 @@ void usage(char* prog)
|
|
|
|
printf("\t-l crc_length [Default %d]\n", crc_length);
|
|
|
|
printf("\t-l crc_length [Default %d]\n", crc_length);
|
|
|
|
printf("\t-p crc_poly (Hex) [Default 0x%x]\n", crc_poly);
|
|
|
|
printf("\t-p crc_poly (Hex) [Default 0x%x]\n", crc_poly);
|
|
|
|
printf("\t-s seed [Default 0=time]\n");
|
|
|
|
printf("\t-s seed [Default 0=time]\n");
|
|
|
|
|
|
|
|
printf("\t-v [set srslte_verbose to debug, default none]\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void parse_args(int argc, char** argv)
|
|
|
|
void parse_args(int argc, char** argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int opt;
|
|
|
|
int opt;
|
|
|
|
while ((opt = getopt(argc, argv, "nlps")) != -1) {
|
|
|
|
while ((opt = getopt(argc, argv, "nlpsv")) != -1) {
|
|
|
|
switch (opt) {
|
|
|
|
switch (opt) {
|
|
|
|
case 'n':
|
|
|
|
case 'n':
|
|
|
|
num_bits = (int)strtol(argv[optind], NULL, 10);
|
|
|
|
num_bits = (int)strtol(argv[optind], NULL, 10);
|
|
|
@ -51,6 +52,9 @@ void parse_args(int argc, char** argv)
|
|
|
|
case 's':
|
|
|
|
case 's':
|
|
|
|
seed = (uint32_t)strtoul(argv[optind], NULL, 0);
|
|
|
|
seed = (uint32_t)strtoul(argv[optind], NULL, 0);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
|
|
|
|
srslte_verbose++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
usage(argv[0]);
|
|
|
|
usage(argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
@ -83,6 +87,11 @@ int main(int argc, char** argv)
|
|
|
|
data[i] = rand() % 2;
|
|
|
|
data[i] = rand() % 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_INFO && !handler_registered) {
|
|
|
|
|
|
|
|
INFO("data=");
|
|
|
|
|
|
|
|
srslte_vec_fprint_b(stdout, data, num_bits);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize CRC params and tables
|
|
|
|
// Initialize CRC params and tables
|
|
|
|
if (srslte_crc_init(&crc_p, crc_poly, crc_length)) {
|
|
|
|
if (srslte_crc_init(&crc_p, crc_poly, crc_length)) {
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
@ -91,6 +100,8 @@ int main(int argc, char** argv)
|
|
|
|
// generate CRC word
|
|
|
|
// generate CRC word
|
|
|
|
crc_word = srslte_crc_checksum(&crc_p, data, num_bits);
|
|
|
|
crc_word = srslte_crc_checksum(&crc_p, data, num_bits);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INFO("checksum=%x\n", crc_word);
|
|
|
|
|
|
|
|
|
|
|
|
free(data);
|
|
|
|
free(data);
|
|
|
|
|
|
|
|
|
|
|
|
// check if generated word is as expected
|
|
|
|
// check if generated word is as expected
|
|
|
|