From ac71234587241032871cfb0745471f011fcbb943 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Wed, 14 Dec 2011 01:47:13 +0000 Subject: [PATCH] nearly realy working --- rf433rcv/pc/compress.c | 42 +++++++++++++++++++++-------------- rf433rcv/pc/decode2.pl | 6 ++--- rf433rcv/pc/rawhid_test.c | 16 +++++++++----- rf433rcv/teensy/example.c | 54 +++++++++++++++++++++------------------------ 4 files changed, 64 insertions(+), 54 deletions(-) diff --git a/rf433rcv/pc/compress.c b/rf433rcv/pc/compress.c index 1e211d5..41f85aa 100644 --- a/rf433rcv/pc/compress.c +++ b/rf433rcv/pc/compress.c @@ -1,24 +1,34 @@ #include +#include +#include +#define MAX_RAM 502 void main() { - unsigned char c,out=0; - int count =0; - while (read(0,&c,1)) + unsigned char input[MAX_RAM*8+1]; + unsigned char output[MAX_RAM]; + uint16_t i=0; + uint16_t len=0; + uint16_t len_net=0; + for(i=0; i>count; - write(1,&out,1); + + len=read(0,input,MAX_RAM*8+1); + if (len<1) + { + perror("read(): "); + } else if (len==MAX_RAM*8+1) { + printf("File to big"); + } + for(i=0; i; my @samples = $ARGV[0]..$ARGV[1]; -print join ',', @data[@samples]; -print "\n"; +print join '',@data[@samples]; +print STDERR "\n"; diff --git a/rf433rcv/pc/rawhid_test.c b/rf433rcv/pc/rawhid_test.c index eaef389..38f3401 100644 --- a/rf433rcv/pc/rawhid_test.c +++ b/rf433rcv/pc/rawhid_test.c @@ -17,7 +17,7 @@ static char get_keystroke(void); void sendstr(char * tosend) { - rawhid_send(0, tosend, strlen(tosend),100); + rawhid_send(0, tosend, strlen(tosend),1000); } int main (int argc, char *argv[]) @@ -40,14 +40,18 @@ int main (int argc, char *argv[]) FILE * f = fopen (argv[1], "r"); if (!f) return -3; + printf("Clearing Buffer\n"); sendstr("c"); // clear the buffer buf[0]='f'; - size_t len= fread(buf+1, 1, 63, f); - for(i=len+1;i<64;i++) - buf[i]=0xff; - rawhid_send(0, buf, 64, 100); //fill the buffer + while ( fread(buf+1, 1, 63, f) ) + { + + rawhid_send(0, buf, 64, 1000); //fill the buffer + printf("Sending Buffer\n"); + } + printf("Executing Send command\n"); sendstr("s\x10"); // send 4 times - len = rawhid_recv(0, buf, 64, 255); + size_t len = rawhid_recv(0, buf, 64, 255); for(i=0;i2) - // rf_send_reload=rf_send_buffer_len*8-read_buffer[2]; // substract bit offset - //else - usb_rawhid_send(rf_send_buffer, 145); - rf_send=0; - rf_send_reload=rf_send_buffer_len*8; - rf_send_reload_count=read_buffer[1]; - //read_buffer[0]=rf_send_reload; - //read_buffer[1]=rf_send_reload>>8; - //read_buffer[2]=0; + rf_send_buf_pos=0; + rf_send_count=read_buffer[1]+1; } } if (send_buffer) { send_buffer=0; - usb_rawhid_send(write_buffer[active_buffer?0:1], 45); + usb_rawhid_send(write_buffer[active_buffer?0:1], 23); } } } @@ -152,19 +148,19 @@ int main(void) ISR(TIMER0_COMPA_vect) { PORTF^=2; - if (rf_send) + if (rf_send_count && rf_send_buf_pos> ( (rf_send%8)?8-(rf_send%8):0 ) ) & 1) + if ( rf_send_buffer[rf_send_buf_pos/8] & (1<< (rf_send_buf_pos%8))) { PORTF&=~1; } else { PORTF|=1; } //rf_send_buffer[rf_send/8]>>=1; - rf_send--; - } else if (rf_send_reload_count) { - rf_send=rf_send_reload; - rf_send_reload_count--; + rf_send_buf_pos++; + } else if (rf_send_count) { + rf_send_buf_pos=0; + rf_send_count--; } else { PORTF&=~1; if (capture) { -- 1.7.10.4