• R/O
  • HTTP
  • SSH
  • HTTPS

scilog: Commit

Overoで動作するデータ収録プログラム
サブCPUからGPS時刻付きADデータを取得してSDに記録する。


Commit MetaInfo

Revisãof7e747009daa06f684fe5394ef29057010ff0bc7 (tree)
Hora2016-02-22 22:09:47
AutorNaoya Takamura <ntaka206@user...>
CommiterNaoya Takamura

Mensagem de Log

Ver1.0.3

Kernel 3.18.18 対応
i2cデバイス名変更
spiデバイス名変更 ->/dev/spikead spikeadデバイス側で変更したため
ad_ring.h AdDataのADデータ型をlong->int32_tに変更
data1sec[]
data[][]

avg[][]

thread_rcv.c b3_to_long32() 返り値long->int32_tにした

Mudança Sumário

Diff

--- a/Makefile
+++ b/Makefile
@@ -4,30 +4,25 @@
44 #
55 # OETMP is the same as TMPDIR as defined in ${OVEROTOP}/build/conf/site.conf
66 #
7-
7+OVEROTOP = /home/ntaka/dev/overo-yocto-2015/build
88 OETMP = ${OVEROTOP}/tmp
99
10-# There were some OE toolchain path changes recently
11-
12-# OE prior to around 30July2010
13-# TOOLDIR = ${OETMP}/cross/armv7a/bin
14-# STAGEDIR = ${OETMP}/staging/armv7a-angstrom-linux-gnueabi/usr
15-
16-# OE after 30July2010
17-#TOOLDIR = ${OETMP}/sysroots/`uname -m`-linux/usr/armv7a/bin
18-TOOLDIR = ${OETMP}/sysroots/i686-linux/usr/armv7a/bin
19-STAGEDIR = ${OETMP}/sysroots/armv7a-angstrom-linux-gnueabi/usr
20-
21-CC = ${TOOLDIR}/arm-angstrom-linux-gnueabi-gcc
22-
23-# for DEBUG
24-#CFLAGS = -Wall -lm -lpthread -DDEBUG_FILE_MIN -DDEBUG_FILE_MIN_PERIOD=1
10+TOOLDIR = ${OETMP}/sysroots/`uname -m`-linux/usr/bin/arm-poky-linux-gnueabi
11+STAGEDIR = ${OETMP}/sysroots/overo
12+#CC = ${TOOLDIR}/arm-poky-linux-gnueabi-gcc
13+#LD = ${TOOLDIR}/arm-poky-linux-gnueabi-ld
2514
2615 CFLAGS = -Wall -lm -lpthread
16+CFLAGS += -Wno-return-type -Werror=array-bounds -Warray-bounds
17+CFLAGS += --sysroot=${STAGEDIR}
18+CXXFLAGS += --sysroot=${STAGEDIR}
19+# 警告をエラー扱いにする
20+#CFLAGS += -Werror
21+# for DEBUG
22+#CFLAGS += -Wall -lm -lpthread -DDEBUG_FILE_MIN -DDEBUG_FILE_MIN_PERIOD=1
2723
28-LIBDIR = ${STAGEDIR}/lib
29-
30-INCDIR = ${STAGEDIR}/include
24+#LIBDIR = ${STAGEDIR}/lib
25+#INCDIR = ${STAGEDIR}/include
3126
3227 TARGET = scilog
3328
@@ -36,7 +31,8 @@ OBJS = scilog.o spi.o thread_rcv.o ring.o ad_ring.o thread_rec.o sts.o ad_file.o
3631 HDRS = mes_print.h debug_print.h spi.h my_thread.h ring.h ad_ring.h thread_rec.h sts.h ad_file.h conf.h lcd.h
3732
3833 ${TARGET} : $(OBJS) $(HDRS)
39- ${CC} ${CFLAGS} ${OBJS} -L ${LIBDIR} -o ${TARGET}
34+ ${CC} ${CFLAGS} ${OBJS} -o ${TARGET}
35+# ${CC} ${CFLAGS} ${OBJS} -L ${LIBDIR} -I ${INCDIR} -o ${TARGET}
4036
4137 #meas.o: meas.c
4238 # ${CC} ${CFLAGS} -I ${INCDIR} -c meas.c
--- a/ad_file.c
+++ b/ad_file.c
@@ -152,7 +152,7 @@ int sec_make_rec_data(AdData *ad, char *buf)
152152 ad->gps.year, ad->gps.month, ad->gps.day, ad->gps.hour, ad->gps.min, ad->gps.sec,
153153 ad->gps.tacc, ad->gps.valid);
154154 for(ch = 0; ch < AD_CHNUM; ch++) {
155- sprintf(buf2, ",%+7ld", ad->data1sec[ch]);
155+ sprintf(buf2, ",%+7d", ad->data1sec[ch]);
156156 strcat(buf, buf2);
157157 }
158158 strcat(buf, "\n");
--- a/ad_ring.h
+++ b/ad_ring.h
@@ -2,6 +2,7 @@
22 #define __AVG_RING_H__
33
44 #include <time.h>
5+#include <stdint.h>
56 #include "spi.h"
67
78 // リングバッファサイズ 個数
@@ -35,9 +36,9 @@ typedef struct {
3536 UbloxNavTimeUtc gps; // GPSタイムスタンプ SPIで受信
3637 struct tm t; // タイムスタンプ struct tmの月は(0〜11)なので注意 年は1900からのオフセット
3738 int freq; // 平均周波数 Hz
38- long data1sec[AD_CHNUM]; // 1sec平均値 SPIで受信
39- long data[AD_CHNUM][AD_SAMPLE]; // AD_SAMPLE[Hz]の生データ SPIで受信
40- long avg[AD_CHNUM][AD_SAMPLE]; // 平均後データ
39+ int32_t data1sec[AD_CHNUM]; // 1sec平均値 SPIで受信
40+ int32_t data[AD_CHNUM][AD_SAMPLE]; // AD_SAMPLE[Hz]の生データ SPIで受信
41+ int32_t avg[AD_CHNUM][AD_SAMPLE]; // 平均後データ
4142 unsigned int checksum; // SPI受信データのchecksumフィールド
4243 } AdData;
4344
--- a/lcd.c
+++ b/lcd.c
@@ -10,7 +10,7 @@
1010 #include "mes_print.h"
1111 #include "lcd.h"
1212
13-#define DEV_LCD "/dev/i2c-3"
13+#define DEV_LCD "/dev/i2c-2" // Kernel3.18から変わった 以前はi2c-3
1414
1515
1616 static int fh = -1;
--- a/scilog.c
+++ b/scilog.c
@@ -5,10 +5,25 @@
55 *
66 * Ver1.0.1
77 * conf_linux_time_set_XXX() add?
8+ * thread_disp.cでGPS時刻をlinuxにset
89 *
910 * Ver1.0.2
1011 * 2015/09/22
1112 * lcd.c i2clcd_init() i2cLCD基板のConfig変更 LCD自動初期化ON
13+ *
14+ * Ver1.0.3
15+ * Kernel 3.18.18 対応
16+ * i2cデバイス名変更
17+ * spiデバイス名変更 ->/dev/spikead spikeadデバイス側で変更したため
18+ * ad_ring.h AdDataのADデータ型をlong->int32_tに変更
19+ * data1sec[]
20+ * data[][]
21+ * avg[][]
22+ * thread_rcv.c b3_to_long32() 返り値long->int32_tにした
23+ *
24+ * ●コンパイル方法
25+ * . environment-setup-cortexa8hf-vfp-neon-poky-linux-gnueabi
26+ * make
1227 *
1328 */
1429 #include <stdio.h>
@@ -52,9 +67,9 @@
5267 // ダミーデータを自分で発生するときに定義
5368 //#define DUMMY
5469
55-#define VERSION "1.0.2"
70+#define VERSION "1.0.3"
5671
57-#define DEV_SPI "/dev/spike-ad"
72+#define DEV_SPI "/dev/spikead"
5873
5974 /**** 設定デフォルト値
6075 */
@@ -99,8 +114,9 @@ int main (int argc, char *argv[])
99114 signal(SIGTERM, sig_handler);
100115
101116 lcd_init();
102- lcd_pos(6, 1);
103- lcd_print("sciLogger");
117+ lcd_pos(0, 1);
118+ lcd_print("sciLogger ");
119+ lcd_print(VERSION);
104120 lcd_pos(0, 3);
105121
106122 ad_ring_init();
@@ -118,6 +134,7 @@ int main (int argc, char *argv[])
118134 conf_read();
119135 PDEBUG("freq=%d\n", conf_freq_get());
120136 PDEBUG("gain=%d\n", conf_gain_get());
137+ PDEBUG("linux_time_set=%d\n", conf_linux_time_set_get());
121138 lcd_print("*");
122139
123140 PDEBUG("sciLogger %s START\n", VERSION);
Binary files a/test and /dev/null differ
--- a/test.c
+++ /dev/null
@@ -1,23 +0,0 @@
1-
2-#include <stdio.h>
3-#include <CUnit/CUnit.h>
4-#include <CUnit/Console.h>
5-
6-#include "my_thread.h"
7-#include "spi.h"
8-#include "ad_ring.h"
9-
10-int main (int argc, char *argv[])
11-{
12- CU_pSuite test_suite;
13- CU_initialize_registry();
14- test_suite = CU_add_suite("scilog", NULL, NULL);
15-
16- thread_rcv_test(test_suite);
17- ad_ring_test(test_suite);
18-
19- CU_console_run_tests();
20-
21- CU_cleanup_registry();
22-
23-}
--- a/thread_disp.c
+++ b/thread_disp.c
@@ -38,14 +38,14 @@ static void scr_disp_ad(AdData *d)
3838 iLeft = 0;
3939 iY = 1;
4040 for(ch = 0; ch < 3; ch++) {
41- sprintf(buf, "%d% 8ld", ch+1, d->data1sec[ch]);
41+ sprintf(buf, "%d% 8d", ch+1, d->data1sec[ch]);
4242 lcd_pos(iLeft, iY++);
4343 lcd_print(buf);
4444 }
4545 iLeft = 10;
4646 iY = 1;
4747 for(ch = 3; ch < 6; ch++) {
48- sprintf(buf, "%d% 8ld", ch+1, d->data1sec[ch]);
48+ sprintf(buf, "%d% 8d", ch+1, d->data1sec[ch]);
4949 lcd_pos(iLeft, iY++);
5050 lcd_print(buf);
5151 }
--- a/thread_rcv.c
+++ b/thread_rcv.c
@@ -6,6 +6,7 @@
66 #include <syslog.h>
77 #include <sys/types.h>
88 #include <string.h>
9+#include <stdint.h>
910
1011 #include "debug_print.h"
1112 #include "spi.h"
@@ -16,7 +17,7 @@
1617 Little Endian
1718 3byte -> signed long(4byte)
1819 */
19-static long b3_to_long32(unsigned char *ptr)
20+static int32_t b3_to_long32(unsigned char *ptr)
2021 {
2122 char buf[4];
2223
@@ -28,7 +29,7 @@ static long b3_to_long32(unsigned char *ptr)
2829 } else {
2930 buf[3] = 0;
3031 }
31- return *((long*)buf);
32+ return *((int32_t*)buf);
3233 }
3334 static int decode(char *buf, AdData *ad)
3435 {
@@ -62,6 +63,15 @@ static int decode(char *buf, AdData *ad)
6263 ad->data1sec[ch] = *((int32_t*)ptr);
6364 ptr += 4;
6465 }
66+/*
67+u_int8_t *ptrsave = ptr;
68+for(i = 0; i < AD_SAMPLE; i++) {
69+ *ptr++ = i;
70+ *ptr++ = 0;
71+ *ptr++ = 0;
72+}
73+ptr = ptrsave;
74+*/
6575 // 50Hz data
6676 for(ch = 0; ch < AD_CHNUM; ch++) {
6777 for(i = 0; i < AD_SAMPLE; i++) {
@@ -69,6 +79,11 @@ static int decode(char *buf, AdData *ad)
6979 ptr += 3;
7080 }
7181 }
82+// DEBUG!!!!!!!!!!!!!!!!!!!!!!!
83+//for(i = 0; i < AD_SAMPLE; i++) {
84+// ad->data[0][i] = i;
85+//}
86+
7287 // Checksum
7388 ad->checksum = *((u_int16_t*)ptr);
7489
Show on old repository browser