OSDN Git Service

Ver1.0.3
[scilog/scilog.git] / thread_rcv.c
index be188f6..31cb202 100644 (file)
@@ -6,6 +6,7 @@
 #include <syslog.h>
 #include <sys/types.h>
 #include <string.h>
+#include <stdint.h>
 
 #include "debug_print.h"
 #include "spi.h"
@@ -16,7 +17,7 @@
        Little Endian
        3byte -> signed long(4byte)
 */
-static long b3_to_long32(unsigned char *ptr)
+static int32_t b3_to_long32(unsigned char *ptr)
 {
        char    buf[4];
        
@@ -28,7 +29,7 @@ static long b3_to_long32(unsigned char *ptr)
        } else {
                buf[3] = 0;
        }
-       return *((long*)buf);
+       return *((int32_t*)buf);
 }
 static int decode(char *buf, AdData *ad)
 {
@@ -62,6 +63,15 @@ static int decode(char *buf, AdData *ad)
                ad->data1sec[ch] = *((int32_t*)ptr);
                ptr += 4;
        }
+/*
+u_int8_t       *ptrsave = ptr;
+for(i = 0; i < AD_SAMPLE; i++) {
+       *ptr++ = i;
+       *ptr++ = 0;
+       *ptr++ = 0;
+}
+ptr = ptrsave;
+*/
        // 50Hz data
        for(ch = 0; ch < AD_CHNUM; ch++) {
                for(i = 0; i < AD_SAMPLE; i++) {
@@ -69,6 +79,11 @@ static int decode(char *buf, AdData *ad)
                        ptr += 3;
                }
        }
+// DEBUG!!!!!!!!!!!!!!!!!!!!!!!
+//for(i = 0; i < AD_SAMPLE; i++) {
+//     ad->data[0][i] = i;
+//}
+
        // Checksum
        ad->checksum = *((u_int16_t*)ptr);