/* Status has 2 different symbols, 0, 1 */ void statusTxSymbol(uint8_t symbol){ if (symbol == 0) { askHigh(); usleep(STATUS_SHORT); askLow(); usleep(STATUS_LONG); } else { askHigh(); usleep(STATUS_LONG); askLow(); usleep(STATUS_SHORT); } }
/* Send single signal block */ void send_block(long length) { askHigh(); wait(length); askLow(); wait(space_duration); }
void ook_transmit(const char *filename, int mod) { FILE *fd = fopen(filename, "r"); char cmd; int arg; int ret; struct timespec ts; if (!fd) { printf("ERROR: Unable to open data file\n"); return; } /* Calculate total tx time for calibration */ float took = 0; struct timeval start, stop; gettimeofday(&start, NULL); while (!feof(fd)) { fscanf(fd, "%c%d\n", &cmd, &arg); //printf("%c %d\n", cmd, arg); switch (cmd) { case 'N': if (arg == 0) { continue; } //printf("Sleep for %ld\n", ts.tv_nsec); //for (int X = 0; X < arg/162; X ++) { // ACCESS(CM_GP0DIV) = (0x5a << 24) + mod + (X/8)%3 - 1 ; // Going for 0.077 //} ts.tv_sec = 0; ts.tv_nsec = arg - 80000; ret = nanosleep(&ts, NULL); if (ret != 0) { printf("Warning nanosleep returned != 0: %d\n", ret); perror("nanosleep"); return; } continue; case 'S': if (arg) { //printf("TX 1\n"); askHigh(); } else { //printf("TX 0\n"); askLow(); } continue; default: printf("ERROR: Invalid command in data file: %c\n", cmd); return; } } gettimeofday(&stop, NULL); took = (stop.tv_sec - start.tv_sec) * 1e6; took += (stop.tv_usec - start.tv_usec); took /= 1e6; printf("Transmission took %10.5f\n", took); fclose(fd); return; }