Example #1
0
File: status.c Project: s7mx1/pihat
/* 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);
       }
}
Example #2
0
/* Send single signal block */
void send_block(long length)
{
	askHigh();
	wait(length);
	askLow();
	wait(space_duration);
}
Example #3
0
int main (int argc, char **argv)
{
	/* Setup RF-configuration */
	setup_io();
	setup_fm();

	char *fname = argv[1];
	if (!fname) {
		printf("Pass data file as first and only argument\n");
		return -1;
	}

	printf("Reading signal data from %s\n", fname);

	
        //float freq = 433.800;
        float freq = 433.917;
	transmit_repeat(fname, freq / 3.0);
	//transmit_repeat(fname, freq / 4.0);
	//transmit_repeat(fname, freq / 5.0);
	//transmit_repeat(fname, freq / 6.0);
	//transmit_repeat(fname, freq / 8.0);
	//transmit_repeat(fname, freq / 11.0 + 0.02/11.0);

	printf("Shutting down transmission\n");
	askLow();
	return 0;
}
Example #4
0
int main (int argc, char **argv)
{
	/* Setup RF-configuration */
	setup_io();
	setup_fm();

        float freq = 27.100;
	transmit_repeat(freq);
	printf("Shutting down transmission\n");
	askLow();
	return 0;
}
Example #5
0
void transmit_repeat(float freq) 
{
	int dev = -2;
	int i = 0;
	set_freq(freq, dev);
	askLow();
	usleep(10000);
	
	set_freq(freq, dev);		

	printf("TX dev=%d try %d\n", dev, i);
	ook_transmit();
	usleep(25000);

}
Example #6
0
void transmit_repeat(const char *fname, float freq) 
{
	int mod;
	int dev = -2;
	int i = 0;
	set_freq(freq, dev);
	askLow();
	usleep(10000);
	
	//for (; dev<=2; dev++) {
	//	for (int i=0; i<1; i++) {
			mod = set_freq(freq, dev);		

			printf("TX dev=%d try %d\n", dev, i);
			ook_transmit(fname, mod);
			usleep(25000);
	//	}
	//}

}
Example #7
0
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;
}