/* * Copyright (C) 2010 Jiri Pittner * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include #include #include #include #include #include #include #include #include #include #include #include "keeloq.c" //set modulation depth here float l_zero= 0.; float l_one = 1.; void delay_ms(int fd,unsigned int sr,unsigned int t ) { unsigned long count = sr*(double)t/1000.; while(count-- >0) write(fd,&l_zero,sizeof(float)); } //outputs a stream of floats at given sample rate to be used for ASK or FSK modulation in gnuradio void transmit(int fd, unsigned int sr, uint8_t *outcode, uint8_t outcodelen) { unsigned int te = .0004*sr; //basic pulse element int i,j; float *l_zero_array = malloc(te*sizeof(float)); float *l_one_array = malloc(te*sizeof(float)); for(i=0; i>8; outcode[2]=0x78; outcode[3]=0x23; encrypt((uint32_t *)outcode,&keeloq_crypt); outcode[4]=0x53; outcode[5]=0x4d; outcode[6]=0x08; outcode[7]=0x20; outcode[8]=0x02; outcodelen=65; } int i; printf("TX code: "); for(i=0; i<9; ++i) printf("%02x ",outcode[i]); printf("\n"); unsigned int sr=50000; //sampling rate //just a test - transmit constant data repeatedly while(1) { transmit(fd,sr,outcode,65); delay_ms(fd,sr,500); //every 500 ms } close(fd); }