From: Othmar Gsenger Date: Tue, 13 Dec 2011 23:33:38 +0000 (+0000) Subject: neerly working version of rf433rcv X-Git-Url: https://git.realraum.at/?p=svn42.git;a=commitdiff_plain;h=f505a1c37ea1c76897991f9882de765e34f0cc98 neerly working version of rf433rcv --- diff --git a/rf433rcv/pc/compress.c b/rf433rcv/pc/compress.c new file mode 100644 index 0000000..1e211d5 --- /dev/null +++ b/rf433rcv/pc/compress.c @@ -0,0 +1,24 @@ +#include + + +void main() +{ + unsigned char c,out=0; + int count =0; + while (read(0,&c,1)) + { + out<<=1; + if (c=='1') + out |=1; + count++; + if (count ==8) + { + write(1,&out,1); + count=0; + out=0; + } + } + out<<=8-count; + out |= 0xff>>count; + write(1,&out,1); +} diff --git a/rf433rcv/pc/decode.pl b/rf433rcv/pc/decode.pl index 685a283..8a0a4d6 100755 --- a/rf433rcv/pc/decode.pl +++ b/rf433rcv/pc/decode.pl @@ -61,7 +61,7 @@ if (my $delemiter = $ARGV[0]) $binarydata[int($bitcount/8)]|=$bits; $bitcount++; } - $binarydata[int($bitcount/8)]<<= 7 - ($bitcount % 8); + $binarydata[int($bitcount/8)]<<= 8 - ($bitcount % 8) if $bitcount % 8; my @chars = map { chr($_) } @binarydata; print STDERR join '',@chars; # print STDERR "\ns\x04"; # send 4 times diff --git a/rf433rcv/pc/decode2.pl b/rf433rcv/pc/decode2.pl new file mode 100755 index 0000000..4d81139 --- /dev/null +++ b/rf433rcv/pc/decode2.pl @@ -0,0 +1,7 @@ +#!/usr/bin/perl +use strict; +print $ARGV[2]-$ARGV[1], "samples\n"; +my @data = split /,/,<>; +my @samples = $ARGV[0]..$ARGV[1]; +print join ',', @data[@samples]; +print "\n"; diff --git a/rf433rcv/pc/rawhid_test.c b/rf433rcv/pc/rawhid_test.c index 3bccde4..eaef389 100644 --- a/rf433rcv/pc/rawhid_test.c +++ b/rf433rcv/pc/rawhid_test.c @@ -1,6 +1,7 @@ #include #include #include +#include #if defined(OS_LINUX) || defined(OS_MACOSX) #include @@ -14,12 +15,15 @@ static char get_keystroke(void); +void sendstr(char * tosend) +{ + rawhid_send(0, tosend, strlen(tosend),100); +} int main (int argc, char *argv[]) { int i, r, num; char c, buf[64]; - // C-based example is 16C0:0480:FFAB:0200 r = rawhid_open(1, 0x16C0, 0x0480, 0xFFAB, 0x0200); if (r <= 0) { @@ -36,12 +40,19 @@ int main (int argc, char *argv[]) FILE * f = fopen (argv[1], "r"); if (!f) return -3; + sendstr("c"); // clear the buffer buf[0]='f'; - size_t len= fread(buf+1, 63, 1, f); - rawhid_send(0, buf, 1+len, 100); - buf[0]='s'; - buf[1]=4; - rawhid_send(0, buf, 2, 100); + 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 + sendstr("s\x10"); // send 4 times + 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 - rf_send_reload=rf_send_buffer_len*8; + //if (r>2) + // 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; } } if (send_buffer) @@ -149,18 +154,19 @@ ISR(TIMER0_COMPA_vect) PORTF^=2; if (rf_send) { - if (rf_send_buffer[rf_send/8] & 0x80) + if ( ( rf_send_buffer[rf_send/8] >> ( (rf_send%8)?8-(rf_send%8):0 ) ) & 1) { - PORTF|=1; - } else { PORTF&=~1; + } else { + PORTF|=1; } - rf_send_buffer[rf_send/8]<<=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--; } else { - PORTF&=~1; + PORTF&=~1; if (capture) { write_buffer[active_buffer][output_count/8]<<=1; write_buffer[active_buffer][output_count++/8]|=PINB&1;