From: Naoya Takamura Date: Mon, 22 Feb 2016 13:09:47 +0000 (+0900) Subject: Ver1.0.3 X-Git-Url: http://git.osdn.net/view?p=scilog%2Fscilog.git;a=commitdiff_plain;h=f7e747009daa06f684fe5394ef29057010ff0bc7 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にした --- diff --git a/Makefile b/Makefile index f7d300d..ceec26d 100644 --- a/Makefile +++ b/Makefile @@ -4,30 +4,25 @@ # # OETMP is the same as TMPDIR as defined in ${OVEROTOP}/build/conf/site.conf # - +OVEROTOP = /home/ntaka/dev/overo-yocto-2015/build OETMP = ${OVEROTOP}/tmp -# There were some OE toolchain path changes recently - -# OE prior to around 30July2010 -# TOOLDIR = ${OETMP}/cross/armv7a/bin -# STAGEDIR = ${OETMP}/staging/armv7a-angstrom-linux-gnueabi/usr - -# OE after 30July2010 -#TOOLDIR = ${OETMP}/sysroots/`uname -m`-linux/usr/armv7a/bin -TOOLDIR = ${OETMP}/sysroots/i686-linux/usr/armv7a/bin -STAGEDIR = ${OETMP}/sysroots/armv7a-angstrom-linux-gnueabi/usr - -CC = ${TOOLDIR}/arm-angstrom-linux-gnueabi-gcc - -# for DEBUG -#CFLAGS = -Wall -lm -lpthread -DDEBUG_FILE_MIN -DDEBUG_FILE_MIN_PERIOD=1 +TOOLDIR = ${OETMP}/sysroots/`uname -m`-linux/usr/bin/arm-poky-linux-gnueabi +STAGEDIR = ${OETMP}/sysroots/overo +#CC = ${TOOLDIR}/arm-poky-linux-gnueabi-gcc +#LD = ${TOOLDIR}/arm-poky-linux-gnueabi-ld CFLAGS = -Wall -lm -lpthread +CFLAGS += -Wno-return-type -Werror=array-bounds -Warray-bounds +CFLAGS += --sysroot=${STAGEDIR} +CXXFLAGS += --sysroot=${STAGEDIR} +# 警告をエラー扱いにする +#CFLAGS += -Werror +# for DEBUG +#CFLAGS += -Wall -lm -lpthread -DDEBUG_FILE_MIN -DDEBUG_FILE_MIN_PERIOD=1 -LIBDIR = ${STAGEDIR}/lib - -INCDIR = ${STAGEDIR}/include +#LIBDIR = ${STAGEDIR}/lib +#INCDIR = ${STAGEDIR}/include TARGET = scilog @@ -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 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 ${TARGET} : $(OBJS) $(HDRS) - ${CC} ${CFLAGS} ${OBJS} -L ${LIBDIR} -o ${TARGET} + ${CC} ${CFLAGS} ${OBJS} -o ${TARGET} +# ${CC} ${CFLAGS} ${OBJS} -L ${LIBDIR} -I ${INCDIR} -o ${TARGET} #meas.o: meas.c # ${CC} ${CFLAGS} -I ${INCDIR} -c meas.c diff --git a/ad_file.c b/ad_file.c index cf76e52..5b1f004 100644 --- a/ad_file.c +++ b/ad_file.c @@ -152,7 +152,7 @@ int sec_make_rec_data(AdData *ad, char *buf) ad->gps.year, ad->gps.month, ad->gps.day, ad->gps.hour, ad->gps.min, ad->gps.sec, ad->gps.tacc, ad->gps.valid); for(ch = 0; ch < AD_CHNUM; ch++) { - sprintf(buf2, ",%+7ld", ad->data1sec[ch]); + sprintf(buf2, ",%+7d", ad->data1sec[ch]); strcat(buf, buf2); } strcat(buf, "\n"); diff --git a/ad_ring.h b/ad_ring.h index eefac44..90f6306 100644 --- a/ad_ring.h +++ b/ad_ring.h @@ -2,6 +2,7 @@ #define __AVG_RING_H__ #include +#include #include "spi.h" // リングバッファサイズ 個数 @@ -35,9 +36,9 @@ typedef struct { UbloxNavTimeUtc gps; // GPSタイムスタンプ SPIで受信 struct tm t; // タイムスタンプ struct tmの月は(0〜11)なので注意 年は1900からのオフセット int freq; // 平均周波数 Hz - long data1sec[AD_CHNUM]; // 1sec平均値 SPIで受信 - long data[AD_CHNUM][AD_SAMPLE]; // AD_SAMPLE[Hz]の生データ SPIで受信 - long avg[AD_CHNUM][AD_SAMPLE]; // 平均後データ + int32_t data1sec[AD_CHNUM]; // 1sec平均値 SPIで受信 + int32_t data[AD_CHNUM][AD_SAMPLE]; // AD_SAMPLE[Hz]の生データ SPIで受信 + int32_t avg[AD_CHNUM][AD_SAMPLE]; // 平均後データ unsigned int checksum; // SPI受信データのchecksumフィールド } AdData; diff --git a/lcd.c b/lcd.c index bac280d..1c8f5bc 100644 --- a/lcd.c +++ b/lcd.c @@ -10,7 +10,7 @@ #include "mes_print.h" #include "lcd.h" -#define DEV_LCD "/dev/i2c-3" +#define DEV_LCD "/dev/i2c-2" // Kernel3.18から変わった 以前はi2c-3 static int fh = -1; diff --git a/scilog.c b/scilog.c index ac9cd88..8375928 100644 --- a/scilog.c +++ b/scilog.c @@ -5,10 +5,25 @@ * * Ver1.0.1 * conf_linux_time_set_XXX() add? + * thread_disp.cでGPS時刻をlinuxにset * * Ver1.0.2 * 2015/09/22 * lcd.c i2clcd_init() i2cLCD基板のConfig変更 LCD自動初期化ON + * + * 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にした + * + * ●コンパイル方法 + * . environment-setup-cortexa8hf-vfp-neon-poky-linux-gnueabi + * make * */ #include @@ -52,9 +67,9 @@ // ダミーデータを自分で発生するときに定義 //#define DUMMY -#define VERSION "1.0.2" +#define VERSION "1.0.3" -#define DEV_SPI "/dev/spike-ad" +#define DEV_SPI "/dev/spikead" /**** 設定デフォルト値 */ @@ -99,8 +114,9 @@ int main (int argc, char *argv[]) signal(SIGTERM, sig_handler); lcd_init(); - lcd_pos(6, 1); - lcd_print("sciLogger"); + lcd_pos(0, 1); + lcd_print("sciLogger "); + lcd_print(VERSION); lcd_pos(0, 3); ad_ring_init(); @@ -118,6 +134,7 @@ int main (int argc, char *argv[]) conf_read(); PDEBUG("freq=%d\n", conf_freq_get()); PDEBUG("gain=%d\n", conf_gain_get()); + PDEBUG("linux_time_set=%d\n", conf_linux_time_set_get()); lcd_print("*"); PDEBUG("sciLogger %s START\n", VERSION); diff --git a/test b/test deleted file mode 100755 index 49390a4..0000000 Binary files a/test and /dev/null differ diff --git a/test.c b/test.c deleted file mode 100644 index 31418a4..0000000 --- a/test.c +++ /dev/null @@ -1,23 +0,0 @@ - -#include -#include -#include - -#include "my_thread.h" -#include "spi.h" -#include "ad_ring.h" - -int main (int argc, char *argv[]) -{ - CU_pSuite test_suite; - CU_initialize_registry(); - test_suite = CU_add_suite("scilog", NULL, NULL); - - thread_rcv_test(test_suite); - ad_ring_test(test_suite); - - CU_console_run_tests(); - - CU_cleanup_registry(); - -} diff --git a/thread_disp.c b/thread_disp.c index 087dbb1..2246ab5 100644 --- a/thread_disp.c +++ b/thread_disp.c @@ -38,14 +38,14 @@ static void scr_disp_ad(AdData *d) iLeft = 0; iY = 1; for(ch = 0; ch < 3; ch++) { - sprintf(buf, "%d% 8ld", ch+1, d->data1sec[ch]); + sprintf(buf, "%d% 8d", ch+1, d->data1sec[ch]); lcd_pos(iLeft, iY++); lcd_print(buf); } iLeft = 10; iY = 1; for(ch = 3; ch < 6; ch++) { - sprintf(buf, "%d% 8ld", ch+1, d->data1sec[ch]); + sprintf(buf, "%d% 8d", ch+1, d->data1sec[ch]); lcd_pos(iLeft, iY++); lcd_print(buf); } diff --git a/thread_rcv.c b/thread_rcv.c index be188f6..31cb202 100644 --- a/thread_rcv.c +++ b/thread_rcv.c @@ -6,6 +6,7 @@ #include #include #include +#include #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);