added uncompressor
authorOthmar Gsenger <otti@realraum.at>
Wed, 14 Dec 2011 21:04:09 +0000 (21:04 +0000)
committerOthmar Gsenger <otti@realraum.at>
Wed, 14 Dec 2011 21:04:09 +0000 (21:04 +0000)
rf433rcv/pc/Makefile
rf433rcv/pc/uncompress.c [new file with mode: 0644]

index 8ff6534..6badbc0 100644 (file)
@@ -36,11 +36,14 @@ endif
 OBJS = $(PROG).o hid.o
 
 
-all: $(TARGET) compress
+all: $(TARGET) compress uncompress
 
 compress: compress.c
        $(CC) -o compress compress.c
 
+uncompress: uncompress.c
+       $(CC) -o uncompress uncompress.c
+
 $(PROG): $(OBJS)
        $(CC) -o $(PROG) $(OBJS) $(LIBS)
        $(STRIP) $(PROG)
diff --git a/rf433rcv/pc/uncompress.c b/rf433rcv/pc/uncompress.c
new file mode 100644 (file)
index 0000000..14d20b8
--- /dev/null
@@ -0,0 +1,32 @@
+#include <unistd.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#define MAX_RAM 502
+
+void main()
+{
+  unsigned char input[MAX_RAM];
+  uint16_t i=0;
+  uint16_t len=0;
+  uint16_t len_net=0;
+
+  len=read(0,input,MAX_RAM+1);
+  if (len<1)
+  {
+    perror("read(): ");
+  } else if (len==MAX_RAM+1) {
+    printf("File to big");
+  }
+  
+  len_net= *((uint16_t *) input);
+  len = ntohs(len_net);
+  //very unsave!!!
+  for(i=2*8; i<len+2*8;i++)
+  {
+    if ( input[i/8] & (1<< (i%8)))
+      printf("1");
+    else
+      printf("0");
+  }
+}