diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..27f23125 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/LightPcapNg"] + path = src/LightPcapNg + url = https://github.com/rvelea/LightPcapNg.git diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 015ca5b0..a906ce1c --- a/README.md +++ b/README.md @@ -1,17 +1,22 @@ # cangaroo open source can bus analyzer -written by Hubert Denkmair +written by Hubert Denkmair (https://github.com/HubertD/cangaroo) + +Raw CAN tx support added by Ethan Zonca (https://github.com/normaldotcom/cangaroo) + +Pcanng file support added by Skip Hansen (https://github.com/skiphansen/cangaroo) ## building on linux * to install all required packages in a vanilla ubuntu 16.04: * sudo apt-get install build-essential git qt5-qmake qtbase5-dev libnl-3-dev libnl-route-3-dev * build with: + * git submodule init;git submodule update * qmake -qt=qt5 * make * make install -## building on windows +## building on windows * Qt Creator (Community Version is okay) brings everything you need * except for the PCAN libraries. * Get them from http://www.peak-system.com/fileadmin/media/files/pcan-basic.zip @@ -24,6 +29,8 @@ written by Hubert Denkmair * if you want to deploy the cangaroo app, make sure to also include the needed Qt Libraries. for a normal release build, these are: Qt5Core.dll Qt5Gui.dll Qt5Widgets.dll Qt5Xml.dll +**NB: Building on Windows has not been tested on Skip Hansen's fork** + ## changelog ### v0.2.1 unreleased diff --git a/bin/cangaroo.zip b/bin/cangaroo.zip new file mode 100644 index 00000000..be960310 Binary files /dev/null and b/bin/cangaroo.zip differ diff --git a/build/moc/moc_predefs.h b/build/moc/moc_predefs.h new file mode 100644 index 00000000..d8dfc82c --- /dev/null +++ b/build/moc/moc_predefs.h @@ -0,0 +1,382 @@ +#define __SSP_STRONG__ 3 +#define __DBL_MIN_EXP__ (-1021) +#define __FLT32X_MAX_EXP__ 1024 +#define __cpp_attributes 200809 +#define __UINT_LEAST16_MAX__ 0xffff +#define __ATOMIC_ACQUIRE 2 +#define __FLT128_MAX_10_EXP__ 4932 +#define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F +#define __GCC_IEC_559_COMPLEX 2 +#define __UINT_LEAST8_TYPE__ unsigned char +#define __SIZEOF_FLOAT80__ 16 +#define __INTMAX_C(c) c ## L +#define __CHAR_BIT__ 8 +#define __UINT8_MAX__ 0xff +#define __WINT_MAX__ 0xffffffffU +#define __FLT32_MIN_EXP__ (-125) +#define __cpp_static_assert 200410 +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __SIZE_MAX__ 0xffffffffffffffffUL +#define __WCHAR_MAX__ 0x7fffffff +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 +#define __DBL_DENORM_MIN__ double(4.94065645841246544176568792868221372e-324L) +#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 +#define __GCC_ATOMIC_CHAR_LOCK_FREE 2 +#define __GCC_IEC_559 2 +#define __FLT32X_DECIMAL_DIG__ 17 +#define __FLT_EVAL_METHOD__ 0 +#define __unix__ 1 +#define __cpp_binary_literals 201304 +#define __FLT64_DECIMAL_DIG__ 17 +#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 +#define __x86_64 1 +#define __cpp_variadic_templates 200704 +#define __UINT_FAST64_MAX__ 0xffffffffffffffffUL +#define __SIG_ATOMIC_TYPE__ int +#define __DBL_MIN_10_EXP__ (-307) +#define __FINITE_MATH_ONLY__ 0 +#define __GNUC_PATCHLEVEL__ 0 +#define __FLT32_HAS_DENORM__ 1 +#define __UINT_FAST8_MAX__ 0xff +#define __has_include(STR) __has_include__(STR) +#define __DEC64_MAX_EXP__ 385 +#define __INT8_C(c) c +#define __INT_LEAST8_WIDTH__ 8 +#define __UINT_LEAST64_MAX__ 0xffffffffffffffffUL +#define __SHRT_MAX__ 0x7fff +#define __LDBL_MAX__ 1.18973149535723176502126385303097021e+4932L +#define __FLT64X_MAX_10_EXP__ 4932 +#define __UINT_LEAST8_MAX__ 0xff +#define __GCC_ATOMIC_BOOL_LOCK_FREE 2 +#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128 +#define __UINTMAX_TYPE__ long unsigned int +#define __linux 1 +#define __DEC32_EPSILON__ 1E-6DF +#define __FLT_EVAL_METHOD_TS_18661_3__ 0 +#define __OPTIMIZE__ 1 +#define __unix 1 +#define __UINT32_MAX__ 0xffffffffU +#define __GXX_EXPERIMENTAL_CXX0X__ 1 +#define __LDBL_MAX_EXP__ 16384 +#define __FLT128_MIN_EXP__ (-16381) +#define __WINT_MIN__ 0U +#define __linux__ 1 +#define __FLT128_MIN_10_EXP__ (-4931) +#define __INT_LEAST16_WIDTH__ 16 +#define __SCHAR_MAX__ 0x7f +#define __FLT128_MANT_DIG__ 113 +#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) +#define __INT64_C(c) c ## L +#define __DBL_DIG__ 15 +#define __GCC_ATOMIC_POINTER_LOCK_FREE 2 +#define __FLT64X_MANT_DIG__ 64 +#define _FORTIFY_SOURCE 2 +#define __SIZEOF_INT__ 4 +#define __SIZEOF_POINTER__ 8 +#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 +#define __USER_LABEL_PREFIX__ +#define __FLT64X_EPSILON__ 1.08420217248550443400745280086994171e-19F64x +#define __STDC_HOSTED__ 1 +#define __LDBL_HAS_INFINITY__ 1 +#define __FLT32_DIG__ 6 +#define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F +#define __GXX_WEAK__ 1 +#define __SHRT_WIDTH__ 16 +#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L +#define __DEC32_MAX__ 9.999999E96DF +#define __cpp_threadsafe_static_init 200806 +#define __FLT64X_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951F64x +#define __FLT32X_HAS_INFINITY__ 1 +#define __INT32_MAX__ 0x7fffffff +#define __INT_WIDTH__ 32 +#define __SIZEOF_LONG__ 8 +#define __STDC_IEC_559__ 1 +#define __STDC_ISO_10646__ 201706L +#define __UINT16_C(c) c +#define __PTRDIFF_WIDTH__ 64 +#define __DECIMAL_DIG__ 21 +#define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64 +#define __gnu_linux__ 1 +#define __INTMAX_WIDTH__ 64 +#define __FLT64_MIN_EXP__ (-1021) +#define __has_include_next(STR) __has_include_next__(STR) +#define __FLT64X_MIN_10_EXP__ (-4931) +#define __LDBL_HAS_QUIET_NAN__ 1 +#define __FLT64_MANT_DIG__ 53 +#define __GNUC__ 7 +#define __GXX_RTTI 1 +#define __pie__ 2 +#define __MMX__ 1 +#define __cpp_delegating_constructors 200604 +#define __FLT_HAS_DENORM__ 1 +#define __SIZEOF_LONG_DOUBLE__ 16 +#define __BIGGEST_ALIGNMENT__ 16 +#define __STDC_UTF_16__ 1 +#define __FLT64_MAX_10_EXP__ 308 +#define __FLT32_HAS_INFINITY__ 1 +#define __DBL_MAX__ double(1.79769313486231570814527423731704357e+308L) +#define __cpp_raw_strings 200710 +#define __INT_FAST32_MAX__ 0x7fffffffffffffffL +#define __DBL_HAS_INFINITY__ 1 +#define __INT64_MAX__ 0x7fffffffffffffffL +#define __DEC32_MIN_EXP__ (-94) +#define __INTPTR_WIDTH__ 64 +#define __FLT32X_HAS_DENORM__ 1 +#define __INT_FAST16_TYPE__ long int +#define __LDBL_HAS_DENORM__ 1 +#define __cplusplus 201103L +#define __cpp_ref_qualifiers 200710 +#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL +#define __INT_LEAST32_MAX__ 0x7fffffff +#define __DEC32_MIN__ 1E-95DF +#define __DEPRECATED 1 +#define __cpp_rvalue_references 200610 +#define __DBL_MAX_EXP__ 1024 +#define __WCHAR_WIDTH__ 32 +#define __FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32 +#define __DEC128_EPSILON__ 1E-33DL +#define __SSE2_MATH__ 1 +#define __ATOMIC_HLE_RELEASE 131072 +#define __PTRDIFF_MAX__ 0x7fffffffffffffffL +#define __amd64 1 +#define __STDC_NO_THREADS__ 1 +#define __ATOMIC_HLE_ACQUIRE 65536 +#define __FLT32_HAS_QUIET_NAN__ 1 +#define __GNUG__ 7 +#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL +#define __SIZEOF_SIZE_T__ 8 +#define __cpp_rvalue_reference 200610 +#define __cpp_nsdmi 200809 +#define __FLT64X_MIN_EXP__ (-16381) +#define __SIZEOF_WINT_T__ 4 +#define __LONG_LONG_WIDTH__ 64 +#define __cpp_initializer_lists 200806 +#define __FLT32_MAX_EXP__ 128 +#define __cpp_hex_float 201603 +#define __GCC_HAVE_DWARF2_CFI_ASM 1 +#define __GXX_ABI_VERSION 1011 +#define __FLT128_HAS_INFINITY__ 1 +#define __FLT_MIN_EXP__ (-125) +#define __cpp_lambdas 200907 +#define __FLT64X_HAS_QUIET_NAN__ 1 +#define __INT_FAST64_TYPE__ long int +#define __FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64 +#define __DBL_MIN__ double(2.22507385850720138309023271733240406e-308L) +#define __PIE__ 2 +#define __LP64__ 1 +#define __FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x +#define __DECIMAL_BID_FORMAT__ 1 +#define __FLT64_MIN_10_EXP__ (-307) +#define __FLT64X_DECIMAL_DIG__ 21 +#define __DEC128_MIN__ 1E-6143DL +#define __REGISTER_PREFIX__ +#define __UINT16_MAX__ 0xffff +#define __DBL_HAS_DENORM__ 1 +#define __FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32 +#define __UINT8_TYPE__ unsigned char +#define __FLT_MANT_DIG__ 24 +#define __LDBL_DECIMAL_DIG__ 21 +#define __VERSION__ "7.5.0" +#define __UINT64_C(c) c ## UL +#define __cpp_unicode_characters 200704 +#define _STDC_PREDEF_H 1 +#define __GCC_ATOMIC_INT_LOCK_FREE 2 +#define __FLT128_MAX_EXP__ 16384 +#define __FLT32_MANT_DIG__ 24 +#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __STDC_IEC_559_COMPLEX__ 1 +#define __FLT128_HAS_DENORM__ 1 +#define __FLT128_DIG__ 33 +#define __SCHAR_WIDTH__ 8 +#define __INT32_C(c) c +#define __DEC64_EPSILON__ 1E-15DD +#define __ORDER_PDP_ENDIAN__ 3412 +#define __DEC128_MIN_EXP__ (-6142) +#define __FLT32_MAX_10_EXP__ 38 +#define __INT_FAST32_TYPE__ long int +#define __UINT_LEAST16_TYPE__ short unsigned int +#define __FLT64X_HAS_INFINITY__ 1 +#define unix 1 +#define __INT16_MAX__ 0x7fff +#define __cpp_rtti 199711 +#define __SIZE_TYPE__ long unsigned int +#define __UINT64_MAX__ 0xffffffffffffffffUL +#define __FLT64X_DIG__ 18 +#define __INT8_TYPE__ signed char +#define __ELF__ 1 +#define __GCC_ASM_FLAG_OUTPUTS__ 1 +#define __FLT_RADIX__ 2 +#define __INT_LEAST16_TYPE__ short int +#define __LDBL_EPSILON__ 1.08420217248550443400745280086994171e-19L +#define __UINTMAX_C(c) c ## UL +#define __GLIBCXX_BITSIZE_INT_N_0 128 +#define __k8 1 +#define __SIG_ATOMIC_MAX__ 0x7fffffff +#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 +#define __SIZEOF_PTRDIFF_T__ 8 +#define __FLT32X_MANT_DIG__ 53 +#define __x86_64__ 1 +#define __FLT32X_MIN_EXP__ (-1021) +#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF +#define __INT_FAST16_MAX__ 0x7fffffffffffffffL +#define __FLT64_DIG__ 15 +#define __UINT_FAST32_MAX__ 0xffffffffffffffffUL +#define __UINT_LEAST64_TYPE__ long unsigned int +#define __FLT_HAS_QUIET_NAN__ 1 +#define __FLT_MAX_10_EXP__ 38 +#define __LONG_MAX__ 0x7fffffffffffffffL +#define __FLT64X_HAS_DENORM__ 1 +#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL +#define __FLT_HAS_INFINITY__ 1 +#define __cpp_unicode_literals 200710 +#define __UINT_FAST16_TYPE__ long unsigned int +#define __DEC64_MAX__ 9.999999999999999E384DD +#define __INT_FAST32_WIDTH__ 64 +#define __CHAR16_TYPE__ short unsigned int +#define __PRAGMA_REDEFINE_EXTNAME 1 +#define __SIZE_WIDTH__ 64 +#define __SEG_FS 1 +#define __INT_LEAST16_MAX__ 0x7fff +#define __DEC64_MANT_DIG__ 16 +#define __UINT_LEAST32_MAX__ 0xffffffffU +#define __SEG_GS 1 +#define __FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32 +#define __GCC_ATOMIC_LONG_LOCK_FREE 2 +#define __SIG_ATOMIC_WIDTH__ 32 +#define __INT_LEAST64_TYPE__ long int +#define __INT16_TYPE__ short int +#define __INT_LEAST8_TYPE__ signed char +#define __DEC32_MAX_EXP__ 97 +#define __INT_FAST8_MAX__ 0x7f +#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128 +#define __INTPTR_MAX__ 0x7fffffffffffffffL +#define linux 1 +#define __cpp_range_based_for 200907 +#define __FLT64_HAS_QUIET_NAN__ 1 +#define __FLT32_MIN_10_EXP__ (-37) +#define __SSE2__ 1 +#define __EXCEPTIONS 1 +#define __LDBL_MANT_DIG__ 64 +#define __DBL_HAS_QUIET_NAN__ 1 +#define __FLT64_HAS_INFINITY__ 1 +#define __FLT64X_MAX__ 1.18973149535723176502126385303097021e+4932F64x +#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) +#define __code_model_small__ 1 +#define __k8__ 1 +#define __INTPTR_TYPE__ long int +#define __UINT16_TYPE__ short unsigned int +#define __WCHAR_TYPE__ int +#define __SIZEOF_FLOAT__ 4 +#define __pic__ 2 +#define __UINTPTR_MAX__ 0xffffffffffffffffUL +#define __INT_FAST64_WIDTH__ 64 +#define __DEC64_MIN_EXP__ (-382) +#define __cpp_decltype 200707 +#define __FLT32_DECIMAL_DIG__ 9 +#define __INT_FAST64_MAX__ 0x7fffffffffffffffL +#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 +#define __FLT_DIG__ 6 +#define __FLT64X_MAX_EXP__ 16384 +#define __UINT_FAST64_TYPE__ long unsigned int +#define __INT_MAX__ 0x7fffffff +#define __amd64__ 1 +#define __INT64_TYPE__ long int +#define __FLT_MAX_EXP__ 128 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __DBL_MANT_DIG__ 53 +#define __cpp_inheriting_constructors 201511 +#define __SIZEOF_FLOAT128__ 16 +#define __INT_LEAST64_MAX__ 0x7fffffffffffffffL +#define __DEC64_MIN__ 1E-383DD +#define __WINT_TYPE__ unsigned int +#define __UINT_LEAST32_TYPE__ unsigned int +#define __SIZEOF_SHORT__ 2 +#define __SSE__ 1 +#define __LDBL_MIN_EXP__ (-16381) +#define __FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64 +#define __WINT_WIDTH__ 32 +#define __INT_LEAST8_MAX__ 0x7f +#define __FLT32X_MAX_10_EXP__ 308 +#define __SIZEOF_INT128__ 16 +#define __LDBL_MAX_10_EXP__ 4932 +#define __ATOMIC_RELAXED 0 +#define __DBL_EPSILON__ double(2.22044604925031308084726333618164062e-16L) +#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128 +#define _LP64 1 +#define __UINT8_C(c) c +#define __FLT64_MAX_EXP__ 1024 +#define __INT_LEAST32_TYPE__ int +#define __SIZEOF_WCHAR_T__ 4 +#define __FLT128_HAS_QUIET_NAN__ 1 +#define __INT_FAST8_TYPE__ signed char +#define __FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x +#define __GNUC_STDC_INLINE__ 1 +#define __FLT64_HAS_DENORM__ 1 +#define __FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32 +#define __DBL_DECIMAL_DIG__ 17 +#define __STDC_UTF_32__ 1 +#define __INT_FAST8_WIDTH__ 8 +#define __FXSR__ 1 +#define __DEC_EVAL_METHOD__ 2 +#define __FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x +#define __cpp_runtime_arrays 198712 +#define __UINT64_TYPE__ long unsigned int +#define __UINT32_C(c) c ## U +#define __INTMAX_MAX__ 0x7fffffffffffffffL +#define __cpp_alias_templates 200704 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F +#define __INT8_MAX__ 0x7f +#define __LONG_WIDTH__ 64 +#define __PIC__ 2 +#define __UINT_FAST32_TYPE__ long unsigned int +#define __CHAR32_TYPE__ unsigned int +#define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F +#define __cpp_constexpr 200704 +#define __INT32_TYPE__ int +#define __SIZEOF_DOUBLE__ 8 +#define __cpp_exceptions 199711 +#define __FLT_MIN_10_EXP__ (-37) +#define __FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64 +#define __INT_LEAST32_WIDTH__ 32 +#define __INTMAX_TYPE__ long int +#define __DEC128_MAX_EXP__ 6145 +#define __FLT32X_HAS_QUIET_NAN__ 1 +#define __ATOMIC_CONSUME 1 +#define __GNUC_MINOR__ 5 +#define __GLIBCXX_TYPE_INT_N_0 __int128 +#define __INT_FAST16_WIDTH__ 64 +#define __UINTMAX_MAX__ 0xffffffffffffffffUL +#define __DEC32_MANT_DIG__ 7 +#define __FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x +#define __DBL_MAX_10_EXP__ 308 +#define __LDBL_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951L +#define __INT16_C(c) c +#define __STDC__ 1 +#define __FLT32X_DIG__ 15 +#define __PTRDIFF_TYPE__ long int +#define __ATOMIC_SEQ_CST 5 +#define __UINT32_TYPE__ unsigned int +#define __FLT32X_MIN_10_EXP__ (-307) +#define __UINTPTR_TYPE__ long unsigned int +#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD +#define __DEC128_MANT_DIG__ 34 +#define __LDBL_MIN_10_EXP__ (-4931) +#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128 +#define __SSE_MATH__ 1 +#define __SIZEOF_LONG_LONG__ 8 +#define __cpp_user_defined_literals 200809 +#define __FLT128_DECIMAL_DIG__ 36 +#define __GCC_ATOMIC_LLONG_LOCK_FREE 2 +#define __FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x +#define __LDBL_DIG__ 18 +#define __FLT_DECIMAL_DIG__ 9 +#define __UINT_FAST16_MAX__ 0xffffffffffffffffUL +#define __GCC_ATOMIC_SHORT_LOCK_FREE 2 +#define __INT_LEAST64_WIDTH__ 64 +#define __UINT_FAST8_TYPE__ unsigned char +#define _GNU_SOURCE 1 +#define __ATOMIC_ACQ_REL 4 +#define __ATOMIC_RELEASE 3 diff --git a/cangaroo.pro b/cangaroo.pro index c414d160..1c3128bd 100644 --- a/cangaroo.pro +++ b/cangaroo.pro @@ -1,5 +1,6 @@ -SUBDIRS += src \ - canifconfig -TEMPLATE = subdirs +QT += charts +SUBDIRS += src +TEMPLATE = subdirs CONFIG += ordered warn_on qt debug_and_release CONFIG += c++11 + diff --git a/src/LightPcapNg b/src/LightPcapNg new file mode 160000 index 00000000..ff286c2b --- /dev/null +++ b/src/LightPcapNg @@ -0,0 +1 @@ +Subproject commit ff286c2b89a6541ef1793a7f931fa0f94206d26f diff --git a/src/LightPcapNg.pri b/src/LightPcapNg.pri new file mode 100755 index 00000000..a5151575 --- /dev/null +++ b/src/LightPcapNg.pri @@ -0,0 +1,21 @@ +HEADERS += \ + $$PWD/LightPcapNg/include/light_debug.h \ + $$PWD/LightPcapNg/include/light_internal.h \ + $$PWD/LightPcapNg/include/light_pcapng_ext.h \ + $$PWD/LightPcapNg/include/light_pcapng.h \ + $$PWD/LightPcapNg/include/light_platform.h \ + $$PWD/LightPcapNg/include/light_special.h \ + $$PWD/LightPcapNg/include/light_types.h \ + $$PWD/LightPcapNg/include/light_util.h + +SOURCES += \ + $$PWD/LightPcapNg/src/light_advanced.c \ + $$PWD/LightPcapNg/src/light_alloc.c \ + $$PWD/LightPcapNg/src/light_internal.c \ + $$PWD/LightPcapNg/src/light_io.c \ + $$PWD/LightPcapNg/src/light_manipulate.c \ + $$PWD/LightPcapNg/src/light_option.c \ + $$PWD/LightPcapNg/src/light_pcapng.c \ + $$PWD/LightPcapNg/src/light_pcapng_cont.c \ + $$PWD/LightPcapNg/src/light_pcapng_ext.c \ + $$PWD/LightPcapNg/src/light_platform.c diff --git a/src/core/CanDbSignal.cpp b/src/core/CanDbSignal.cpp index 2ae83a28..c039be09 100644 --- a/src/core/CanDbSignal.cpp +++ b/src/core/CanDbSignal.cpp @@ -75,7 +75,7 @@ void CanDbSignal::setComment(const QString &comment) _comment = comment; } -QString CanDbSignal::getValueName(const uint32_t value) const +QString CanDbSignal::getValueName(const uint64_t value) const { if (_valueTable.contains(value)) { return _valueTable[value]; @@ -84,22 +84,23 @@ QString CanDbSignal::getValueName(const uint32_t value) const } } -void CanDbSignal::setValueName(const uint32_t value, const QString &name) +void CanDbSignal::setValueName(const uint64_t value, const QString &name) { _valueTable[value] = name; } -double CanDbSignal::convertRawValueToPhysical(const uint32_t rawValue) +double CanDbSignal::convertRawValueToPhysical(const uint64_t rawValue) { - int v; if (isUnsigned()) { - v = rawValue; + uint64_t v = rawValue; + return v * _factor + _offset; } else { // TODO check with DBC that actually contains signed values?! - v = (int32_t)(rawValue<<(32-_length)); - v>>=(32-_length); + int64_t v = (int64_t)(rawValue<<(64-_length)); + v>>=(64-_length); + return v * _factor + _offset; + } - return v * _factor + _offset; } double CanDbSignal::extractPhysicalFromMessage(const CanMessage &msg) @@ -220,7 +221,7 @@ bool CanDbSignal::isPresentInMessage(const CanMessage &msg) return _muxValue == muxer->extractRawDataFromMessage(msg); } -uint32_t CanDbSignal::extractRawDataFromMessage(const CanMessage &msg) +uint64_t CanDbSignal::extractRawDataFromMessage(const CanMessage &msg) { return msg.extractRawSignal(startBit(), length(), isBigEndian()); } diff --git a/src/core/CanDbSignal.h b/src/core/CanDbSignal.h index debdd9f3..64ff4b44 100644 --- a/src/core/CanDbSignal.h +++ b/src/core/CanDbSignal.h @@ -28,7 +28,7 @@ class CanDbMessage; -typedef QMap CanDbValueTable; +typedef QMap CanDbValueTable; class CanDbSignal { @@ -46,8 +46,8 @@ class CanDbSignal QString comment() const; void setComment(const QString &comment); - QString getValueName(const uint32_t value) const; - void setValueName(const uint32_t value, const QString &name); + QString getValueName(const uint64_t value) const; + void setValueName(const uint64_t value, const QString &name); double getFactor() const; void setFactor(double factor); @@ -80,9 +80,9 @@ class CanDbSignal void setMuxValue(const uint32_t &muxValue); bool isPresentInMessage(const CanMessage &msg); - uint32_t extractRawDataFromMessage(const CanMessage &msg); + uint64_t extractRawDataFromMessage(const CanMessage &msg); - double convertRawValueToPhysical(const uint32_t rawValue); + double convertRawValueToPhysical(const uint64_t rawValue); double extractPhysicalFromMessage(const CanMessage &msg); diff --git a/src/core/CanMessage.cpp b/src/core/CanMessage.cpp index 0493b4ac..06d687a0 100644 --- a/src/core/CanMessage.cpp +++ b/src/core/CanMessage.cpp @@ -165,18 +165,12 @@ uint64_t CanMessage::getU64() const uint64_t CanMessage::extractRawSignal(uint8_t start_bit, const uint8_t length, const bool isBigEndian) const { - if ((start_bit+length) > (getLength()*8)) { - return 0; - } +// if ((start_bit+length) > (getLength()*8)) { +// return 0; +// } uint64_t data = le64toh(_u64); - if (isBigEndian) { - // it's magic. just swap the byte order and adjust the startbit, then it works like little endian - data = __builtin_bswap64(data); - start_bit = 63 - start_bit - length; - } - data >>= start_bit; uint64_t mask = 0xFFFFFFFFFFFFFFFF; @@ -185,6 +179,17 @@ uint64_t CanMessage::extractRawSignal(uint8_t start_bit, const uint8_t length, c data &= mask; + // If the length is greater than 8, we need to byteswap to preserve endianness + if (isBigEndian && (length > 8)) + { + + // Swap bytes + data = __builtin_bswap64(data); + + // Shift out unused bits + data >>= 64 - length; + } + return data; } diff --git a/src/core/CanTrace.cpp b/src/core/CanTrace.cpp index 1a2c40a2..d558cf6a 100644 --- a/src/core/CanTrace.cpp +++ b/src/core/CanTrace.cpp @@ -204,7 +204,7 @@ void CanTrace::saveVectorAsc(QFile &file) stream << "End TriggerBlock" << endl; } -bool CanTrace::getMuxedSignalFromCache(const CanDbSignal *signal, uint32_t *raw_value) +bool CanTrace::getMuxedSignalFromCache(const CanDbSignal *signal, uint64_t *raw_value) { if (_muxCache.contains(signal)) { *raw_value = _muxCache[signal]; diff --git a/src/core/CanTrace.h b/src/core/CanTrace.h index f8cb3ec3..09dbca7f 100644 --- a/src/core/CanTrace.h +++ b/src/core/CanTrace.h @@ -51,7 +51,7 @@ class CanTrace : public QObject void saveCanDump(QFile &file); void saveVectorAsc(QFile &file); - bool getMuxedSignalFromCache(const CanDbSignal *signal, uint32_t *raw_value); + bool getMuxedSignalFromCache(const CanDbSignal *signal, uint64_t *raw_value); signals: void messageEnqueued(int idx); @@ -75,7 +75,7 @@ private slots: int _newRows; bool _isTimerRunning; - QMap _muxCache; + QMap _muxCache; QMutex _mutex; QMutex _timerMutex; diff --git a/src/core/MeasurementNetwork.cpp b/src/core/MeasurementNetwork.cpp index fcc8f900..79c08440 100644 --- a/src/core/MeasurementNetwork.cpp +++ b/src/core/MeasurementNetwork.cpp @@ -77,6 +77,15 @@ void MeasurementNetwork::addCanDb(QSharedPointer candb) _canDbs.append(candb); } +void MeasurementNetwork::reloadCanDbs(Backend *backend) +{ + foreach(pCanDb db, _canDbs) + { + db = backend->loadDbc(db->getPath()); + } +} + + QString MeasurementNetwork::name() const { return _name; diff --git a/src/core/MeasurementNetwork.h b/src/core/MeasurementNetwork.h index 0fe63ec7..5acd6220 100644 --- a/src/core/MeasurementNetwork.h +++ b/src/core/MeasurementNetwork.h @@ -46,6 +46,7 @@ class MeasurementNetwork CanInterfaceIdList getReferencedCanInterfaces(); void addCanDb(pCanDb candb); + void reloadCanDbs(Backend *backend); QList _canDbs; QString name() const; diff --git a/src/driver/GenericCanSetupPage.ui b/src/driver/GenericCanSetupPage.ui index dfccfc6b..a53ca1ed 100644 --- a/src/driver/GenericCanSetupPage.ui +++ b/src/driver/GenericCanSetupPage.ui @@ -188,8 +188,8 @@ 9 220 - 41 - 16 + 59 + 17 @@ -202,7 +202,7 @@ 140 220 411 - 126 + 141 diff --git a/src/driver/PeakCanDriver/PeakCanDriver.cpp b/src/driver/PeakCanDriver/PeakCanDriver.cpp deleted file mode 100644 index 8ec14c11..00000000 --- a/src/driver/PeakCanDriver/PeakCanDriver.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "PeakCanDriver.h" -#include "PeakCanInterface.h" -#include - -#include -#include "pcan-basic-api/Include/PCANBasic.h" - -PeakCanDriver::PeakCanDriver(Backend &backend) - : CanDriver(backend), - setupPage(new GenericCanSetupPage(0)) -{ - QObject::connect(&backend, SIGNAL(onSetupDialogCreated(SetupDialog&)), setupPage, SLOT(onSetupDialogCreated(SetupDialog&))); -} - -QString PeakCanDriver::getName() -{ - return "PCAN"; -} - -bool PeakCanDriver::update() -{ - uint32_t channel_status; - for (uint32_t i=PCAN_USBBUS1; i<=PCAN_USBBUS8; i++) { - TPCANStatus result = CAN_GetValue(i, PCAN_CHANNEL_CONDITION, &channel_status, sizeof(channel_status)); - // returns PCAN_CHANNEL_UNAVAILABLE, PCAN_CHANNEL_AVAILABLE, PCAN_CHANNEL_OCCUPIED, PCAN_CHANNEL_PCANVIEW - if(result == PCAN_ERROR_OK) { - if (channel_status!=PCAN_CHANNEL_UNAVAILABLE) { - PeakCanInterface *intf = createOrUpdateInterface(i); - intf->update(); - } - } else { - return false; - } - } - return true; -} - -PeakCanInterface *PeakCanDriver::createOrUpdateInterface(uint32_t hnd) -{ - foreach (CanInterface *intf, getInterfaces()) { - PeakCanInterface *pcif = dynamic_cast(intf); - if (pcif->getHandle() == hnd) { - return pcif; - } - } - - PeakCanInterface *pcif = new PeakCanInterface(this, hnd); - addInterface(pcif); - return pcif; -} diff --git a/src/driver/PeakCanDriver/PeakCanDriver.h b/src/driver/PeakCanDriver/PeakCanDriver.h deleted file mode 100644 index 0c38dad8..00000000 --- a/src/driver/PeakCanDriver/PeakCanDriver.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include - -class PeakCanInterface; -class GenericCanSetupPage; - -class PeakCanDriver : public CanDriver -{ -public: - PeakCanDriver(Backend &backend); - - virtual QString getName(); - virtual bool update(); - -private: - PeakCanInterface *createOrUpdateInterface(uint32_t hnd); - GenericCanSetupPage *setupPage; - -}; diff --git a/src/driver/PeakCanDriver/PeakCanDriver.pri b/src/driver/PeakCanDriver/PeakCanDriver.pri deleted file mode 100644 index 711cefee..00000000 --- a/src/driver/PeakCanDriver/PeakCanDriver.pri +++ /dev/null @@ -1,13 +0,0 @@ -SOURCES += \ - $$PWD/PeakCanDriver.cpp \ - $$PWD/PeakCanInterface.cpp - -win32:LIBS += -L$$PWD/pcan-basic-api/Win32/VC_LIB/ -lPCANBasic -win32:INCLUDEPATH += $$PWD/pcan-basic-api/Win32/VC_LIB -win32:DEPENDPATH += $$PWD/pcan-basic-api/Win32/VC_LIB - -HEADERS += \ - $$PWD/PeakCanDriver.h \ - $$PWD/PeakCanInterface.h - -FORMS += diff --git a/src/driver/PeakCanDriver/PeakCanInterface.cpp b/src/driver/PeakCanDriver/PeakCanInterface.cpp deleted file mode 100644 index 2548301b..00000000 --- a/src/driver/PeakCanDriver/PeakCanInterface.cpp +++ /dev/null @@ -1,354 +0,0 @@ -#include "PeakCanInterface.h" -#include "PeakCanDriver.h" - -#include -#include -#include "pcan-basic-api/Include/PCANBasic.h" - -#include - -PeakCanInterface::PeakCanInterface(PeakCanDriver *driver, uint32_t handle) - : CanInterface(driver), - _handle(handle), - _hostOffsetFirstFrame(0), - _peakOffsetFirstFrame(0) -{ - _autoResetEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - - _config.autoRestart = true; - _config.listenOnly = false; - _config.bitrate = 500000; - _config.samplePoint = 875; - - // sample point: 50.0% - _timings << CanTiming(0x3176, 10000, 0, 500) \ - << CanTiming(0x1876, 20000, 0, 500) \ - << CanTiming(0x0976, 50000, 0, 500) \ - << CanTiming(0x0576, 83333, 0, 500) \ - << CanTiming(0x0476, 100000, 0, 500) \ - << CanTiming(0x0376, 125000, 0, 500) \ - << CanTiming(0x0176, 250000, 0, 500) \ - << CanTiming(0x0076, 500000, 0, 500) \ - << CanTiming(0x0043, 800000, 0, 500) \ - << CanTiming(0x0032, 1000000, 0, 500); - - // sample point: 62.5% - _timings << CanTiming(0x3158, 10000, 0, 625) \ - << CanTiming(0x1858, 20000, 0, 625) \ - << CanTiming(0x0958, 50000, 0, 625) \ - << CanTiming(0x0558, 83333, 0, 625) \ - << CanTiming(0x0458, 100000, 0, 625) \ - << CanTiming(0x0358, 125000, 0, 625) \ - << CanTiming(0x0158, 250000, 0, 625) \ - << CanTiming(0x0058, 500000, 0, 625) \ - << CanTiming(0x0034, 800000, 0, 600) \ - << CanTiming(0x0023, 1000000, 0, 625); - - // sample point: 75.0% - _timings << CanTiming(0x313A, 10000, 0, 750) \ - << CanTiming(0x183A, 20000, 0, 750) \ - << CanTiming(0x093A, 50000, 0, 750) \ - << CanTiming(0x053A, 83333, 0, 750) \ - << CanTiming(0x043A, 100000, 0, 750) \ - << CanTiming(0x033A, 125000, 0, 750) \ - << CanTiming(0x013A, 250000, 0, 750) \ - << CanTiming(0x003A, 500000, 0, 750) \ - << CanTiming(0x0016, 800000, 0, 800) \ - << CanTiming(0x0014, 1000000, 0, 750); - - // sample point: 87.5% - _timings << CanTiming(0x311C, 10000, 0, 875) \ - << CanTiming(0x181C, 20000, 0, 875) \ - << CanTiming(0x091C, 50000, 0, 875) \ - << CanTiming(0x051C, 83333, 0, 875) \ - << CanTiming(0x041C, 100000, 0, 875) \ - << CanTiming(0x031C, 125000, 0, 875) \ - << CanTiming(0x011C, 250000, 0, 875) \ - << CanTiming(0x001C, 500000, 0, 875) \ - << CanTiming(0x0007, 800000, 0, 900) \ - << CanTiming(0x0005, 1000000, 0, 875); - -} - -PeakCanInterface::~PeakCanInterface() -{ - CloseHandle(_autoResetEvent); -} - -void PeakCanInterface::update() -{ - // TODO: implement me -} - -uint32_t PeakCanInterface::getHandle() const -{ - return _handle; -} - -QString PeakCanInterface::getName() const -{ - switch (_handle) { - case PCAN_USBBUS1: - case PCAN_USBBUS2: - case PCAN_USBBUS3: - case PCAN_USBBUS4: - case PCAN_USBBUS5: - case PCAN_USBBUS6: - case PCAN_USBBUS7: - case PCAN_USBBUS8: - return QString("pusb%1").arg(_handle - PCAN_USBBUS1 + 1); - default: - return QString("pcan_%1").arg(_handle); - } - - /* - char name[32]; - if (CAN_GetValue(_handle, PCAN_HARDWARE_NAME, name, sizeof(name))==PCAN_ERROR_OK) { - return QString(name); - } else { - return ""; - } -*/ -} - -void PeakCanInterface::applyConfig(const MeasurementInterface &mi) -{ - _config.autoRestart = mi.doAutoRestart(); - _config.listenOnly = mi.isListenOnlyMode(); - _config.bitrate = mi.bitrate(); - _config.samplePoint = mi.samplePoint(); -} - -uint32_t PeakCanInterface::getCapabilities() -{ - return CanInterface::capability_listen_only | CanInterface::capability_auto_restart; -} - -unsigned PeakCanInterface::getBitrate() -{ - uint32_t speed = 0; - if (CAN_GetValue(_handle, PCAN_BUSSPEED_NOMINAL, &speed, sizeof(speed))==PCAN_ERROR_OK) { - return speed; - } else { - return 0; - } -} - -uint16_t PeakCanInterface::calcBitrateMode(unsigned bitrate, unsigned samplePoint) -{ - foreach (CanTiming t, _timings) { - if ( (t.getBitrate()==bitrate) && (t.getSamplePoint()==samplePoint) ) { - return t.getId() & 0xFFFF; - } - } - - return 0; -} - -QString PeakCanInterface::getErrorText(uint32_t status_code) -{ - char s[256]; - TPCANStatus result = CAN_GetErrorText(status_code, 9, s); - if (result==PCAN_ERROR_OK) { - return QString(s); - } else { - return "Unknown error"; - } -} - -QList PeakCanInterface::getAvailableBitrates() -{ - return _timings; -} - -void PeakCanInterface::open() -{ - TPCANStatus result; - - uint32_t bitrate_adapt = PCAN_PARAMETER_ON; - - result = CAN_SetValue(_handle, PCAN_BITRATE_ADAPTING, &bitrate_adapt, sizeof(bitrate_adapt)); - if (result!=PCAN_ERROR_OK) { - log_error(QString("could not set bitrate adapt parameter for CAN channel %1: %2").arg(getName()).arg(getErrorText(result))); - } - - uint32_t listen_only = _config.listenOnly ? PCAN_PARAMETER_ON : PCAN_PARAMETER_OFF; - result = CAN_SetValue(_handle, PCAN_LISTEN_ONLY, &listen_only, sizeof(listen_only)); - if (result!=PCAN_ERROR_OK) { - log_error(QString("could not set listen only mode=%3 for CAN channel %1: %2").arg(getName()).arg(getErrorText(result)).arg(_config.listenOnly ? "on" : "off")); - } - - uint16_t bitrate_mode = calcBitrateMode(_config.bitrate, _config.samplePoint); - if (bitrate_mode==0) { - log_error( - QString("CAN channel %1: cannot find bitrate settings for baud rate %2, sample point %3") - .arg(getName()) - .arg(_config.bitrate) - .arg(CanTiming::getSamplePointStr(_config.samplePoint)) - ); - return; - } - - result = CAN_Initialize(_handle, bitrate_mode); - - if ( (result!=PCAN_ERROR_OK) && (result != PCAN_ERROR_CAUTION) ) { - log_error(QString("could not initialize CAN channel %1: %2").arg(getName()).arg(getErrorText(result))); - return; - } - - log_info(QString("CAN channel %1 initialized").arg(getName())); - if (getBitrate() == _config.bitrate) { - log_info(QString("setting bitrate of CAN channel %1 to %2").arg(getName()).arg(getBitrate())); - } else { - log_warning(QString("could not set correct bitrate for CAN channel %1: bitrate is now %2 instead of configured %3").arg(getName()).arg(getBitrate()).arg(_config.bitrate)); - } - - if (CAN_SetValue(_handle, PCAN_RECEIVE_EVENT, &_autoResetEvent, sizeof(_autoResetEvent))!=PCAN_ERROR_OK) { - log_error(QString("could not set read event for CAN channel: %1").arg(getName())); - } - - uint32_t autoreset = _config.autoRestart ? PCAN_PARAMETER_ON : PCAN_PARAMETER_OFF; - result = CAN_SetValue(_handle, PCAN_BUSOFF_AUTORESET, &autoreset, sizeof(autoreset)); - if (result!=PCAN_ERROR_OK) { - log_error(QString("could not set busoff auto reset mode=%3 for CAN channel %1: %2").arg(getName()).arg(getErrorText(result)).arg(_config.autoRestart ? "on" : "off")); - } - - _peakOffsetFirstFrame = 0; - _hostOffsetFirstFrame = 0; - -} - -void PeakCanInterface::close() -{ - CAN_Uninitialize(_handle); - log_info(QString("CAN channel %1 uninitialized").arg(getName())); -} - -uint32_t PeakCanInterface::getState() -{ - // TODO implement me - return state_unknown; -} - -bool PeakCanInterface::tryReadMessage(CanMessage &msg) -{ - TPCANMsg buf; - TPCANTimestamp timestamp; - - TPCANStatus result = CAN_Read(_handle, &buf, ×tamp); - if (result != PCAN_ERROR_OK) { - return false; - } - - if ((buf.MSGTYPE & PCAN_MESSAGE_STATUS) != 0) { - // TODO handle status message? - return false; - } - msg.setErrorFrame(false); - - msg.setInterfaceId(getId()); - msg.setId(buf.ID); - msg.setExtended((buf.MSGTYPE & PCAN_MESSAGE_EXTENDED)!=0); - msg.setRTR((buf.MSGTYPE & PCAN_MESSAGE_RTR)!=0); - - uint8_t len = (buf.LEN > 8) ? 8 : buf.LEN; - msg.setLength(len); - for (int i=0; ibackend().getUsecsAtMeasurementStart() - + getDriver()->backend().getUsecsSinceMeasurementStart(); - _peakOffsetFirstFrame = ts; - } - - ts += _hostOffsetFirstFrame; - ts -= _peakOffsetFirstFrame; - - msg.setTimestamp(ts/1000000, ts % 1000000); - - return true; -} - -bool PeakCanInterface::readMessage(CanMessage &msg, unsigned int timeout_ms) -{ - - if (tryReadMessage(msg)) - { - return true; - } - - if (WaitForSingleObject(_autoResetEvent, timeout_ms) != WAIT_OBJECT_0) - { - return false; - } - - bool retval = tryReadMessage(msg); - if (!retval) - { - QThread::msleep(1); - } - return retval; -} - -void PeakCanInterface::sendMessage(const CanMessage &msg) -{ - TPCANMsg buf; - buf.ID = msg.getId(); - buf.MSGTYPE = 0; - if (msg.isExtended()) { - buf.MSGTYPE |= PCAN_MESSAGE_EXTENDED; - } - if (msg.isRTR()) { - buf.MSGTYPE |= PCAN_MESSAGE_EXTENDED; - } - - buf.LEN = msg.getLength(); - for (int i=0; i<8; i++) { - buf.DATA[i] = msg.getByte(i); - } - CAN_Write(_handle, &buf); - // TODO check error, update statistics (increment txerrors or txframes) -} - -bool PeakCanInterface::updateStatistics() -{ - return true; -} - -int PeakCanInterface::getNumTxDropped() -{ - return 0; -} - -int PeakCanInterface::getNumRxOverruns() -{ - return 0; -} - -int PeakCanInterface::getNumTxErrors() -{ - return 0; -} - -int PeakCanInterface::getNumTxFrames() -{ - return 0; -} - -int PeakCanInterface::getNumRxErrors() -{ - return 0; -} - -int PeakCanInterface::getNumRxFrames() -{ - return 0; -} diff --git a/src/driver/PeakCanDriver/PeakCanInterface.h b/src/driver/PeakCanDriver/PeakCanInterface.h deleted file mode 100644 index 49dc4b3e..00000000 --- a/src/driver/PeakCanDriver/PeakCanInterface.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include -#include - -class PeakCanDriver; - -class PeakCanInterface : public CanInterface -{ -public: - PeakCanInterface(PeakCanDriver *driver, uint32_t handle); - virtual ~PeakCanInterface(); - void update(); - uint32_t getHandle() const; - - virtual QString getName() const; - - virtual void applyConfig(const MeasurementInterface &mi); - - virtual uint32_t getCapabilities(); - virtual unsigned getBitrate(); - - virtual QList getAvailableBitrates(); - - virtual void open(); - virtual void close(); - - virtual void sendMessage(const CanMessage &msg); - virtual bool readMessage(CanMessage &msg, unsigned int timeout_ms); - - virtual bool updateStatistics(); - virtual uint32_t getState(); - virtual int getNumRxFrames(); - virtual int getNumRxErrors(); - virtual int getNumTxFrames(); - virtual int getNumTxErrors(); - virtual int getNumRxOverruns(); - virtual int getNumTxDropped(); - -private: - uint32_t _handle; - uint64_t _hostOffsetFirstFrame; - uint64_t _peakOffsetFirstFrame; - void *_autoResetEvent; - - struct { - bool autoRestart; - bool listenOnly; - unsigned bitrate; - unsigned samplePoint; - } _config; - - QList _timings; - - uint16_t calcBitrateMode(unsigned bitrate, unsigned samplePoint); - QString getErrorText(uint32_t status_code); - bool tryReadMessage(CanMessage &msg); - -}; diff --git a/src/driver/SocketCanDriver/SocketCanInterface.cpp b/src/driver/SocketCanDriver/SocketCanInterface.cpp old mode 100644 new mode 100755 index 3e9a2391..6bbb70b0 --- a/src/driver/SocketCanDriver/SocketCanInterface.cpp +++ b/src/driver/SocketCanDriver/SocketCanInterface.cpp @@ -44,10 +44,19 @@ #include #include +#ifndef SIOCGSTAMP +// linux-headers-5.2 updated SIOCGSTAMP ioctl to work against 32-bit and +// 64-bit struct timeval. +// Commit: https://github.com/torvalds/linux/commit/0768e17073dc527ccd18ed5f96ce85f9985e9115 +// This shuffled headers a bit and caused build breakage for if only sys/socket.h +// is included. Fix: Include if SIOCGSTAMP not defined. +#include +#endif + SocketCanInterface::SocketCanInterface(SocketCanDriver *driver, int index, QString name) : CanInterface((CanDriver *)driver), - _idx(index), - _fd(0), + _idx(index), + _fd(0), _name(name), _ts_mode(ts_mode_SIOCSHWTSTAMP) { @@ -57,7 +66,7 @@ SocketCanInterface::~SocketCanInterface() { } QString SocketCanInterface::getName() const { - return _name; + return _name; } void SocketCanInterface::setName(QString name) { @@ -347,53 +356,53 @@ const char *SocketCanInterface::cname() } void SocketCanInterface::open() { - if((_fd = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { - perror("Error while opening socket"); - } + if((_fd = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { + perror("Error while opening socket"); + } - struct ifreq ifr; + struct ifreq ifr; struct sockaddr_can addr; strcpy(ifr.ifr_name, _name.toStdString().c_str()); - ioctl(_fd, SIOCGIFINDEX, &ifr); + ioctl(_fd, SIOCGIFINDEX, &ifr); - addr.can_family = AF_CAN; - addr.can_ifindex = ifr.ifr_ifindex; + addr.can_family = AF_CAN; + addr.can_ifindex = ifr.ifr_ifindex; - if(bind(_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - perror("Error in socket bind"); - } + if(bind(_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + perror("Error in socket bind"); + } } void SocketCanInterface::close() { - ::close(_fd); + ::close(_fd); } void SocketCanInterface::sendMessage(const CanMessage &msg) { - struct can_frame frame; + struct can_frame frame; - frame.can_id = msg.getId(); + frame.can_id = msg.getId(); - if (msg.isExtended()) { - frame.can_id |= CAN_EFF_FLAG; - } + if (msg.isExtended()) { + frame.can_id |= CAN_EFF_FLAG; + } - if (msg.isRTR()) { - frame.can_id |= CAN_RTR_FLAG; - } + if (msg.isRTR()) { + frame.can_id |= CAN_RTR_FLAG; + } - if (msg.isErrorFrame()) { - frame.can_id |= CAN_ERR_FLAG; - } + if (msg.isErrorFrame()) { + frame.can_id |= CAN_ERR_FLAG; + } - uint8_t len = msg.getLength(); - if (len>8) { len = 8; } + uint8_t len = msg.getLength(); + if (len>8) { len = 8; } - frame.can_dlc = len; - for (int i=0; i8) { len = 8; } diff --git a/src/driver/SocketCanDriver/SocketCanInterface.h b/src/driver/SocketCanDriver/SocketCanInterface.h old mode 100644 new mode 100755 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp old mode 100644 new mode 100755 index 9030ac82..7cffe39a --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -35,11 +35,14 @@ #include #include #include +#include +#include +#include +#include "light_pcapng_ext.h" #if defined(__linux__) #include #else -#include #include #endif @@ -56,7 +59,9 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->action_Trace_View, SIGNAL(triggered()), this, SLOT(createTraceWindow())); connect(ui->actionLog_View, SIGNAL(triggered()), this, SLOT(addLogWidget())); connect(ui->actionGraph_View, SIGNAL(triggered()), this, SLOT(createGraphWindow())); + connect(ui->actionGraph_View_2, SIGNAL(triggered()), this, SLOT(addGraphWidget())); connect(ui->actionSetup, SIGNAL(triggered()), this, SLOT(showSetupDialog())); + connect(ui->actionTransmit_View, SIGNAL(triggered()), this, SLOT(addRawTxWidget())); connect(ui->actionStart_Measurement, SIGNAL(triggered()), this, SLOT(startMeasurement())); connect(ui->actionStop_Measurement, SIGNAL(triggered()), this, SLOT(stopMeasurement())); @@ -67,12 +72,11 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionSave_Trace_to_file, SIGNAL(triggered(bool)), this, SLOT(saveTraceToFile())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutDialog())); - + connect(ui->action_Load_Trace_from_file, SIGNAL(triggered(bool)), this, SLOT(loadTraceFromFile())); #if defined(__linux__) Backend::instance().addCanDriver(*(new SocketCanDriver(Backend::instance()))); #else - Backend::instance().addCanDriver(*(new PeakCanDriver(Backend::instance()))); Backend::instance().addCanDriver(*(new CandleApiDriver(Backend::instance()))); #endif @@ -264,6 +268,7 @@ void MainWindow::newWorkspace() stopAndClearMeasurement(); clearWorkspace(); createTraceWindow(); + addRawTxWidget(); backend().setDefaultSetup(); } } @@ -361,6 +366,27 @@ QMainWindow *MainWindow::createGraphWindow(QString title) return mm; } +void MainWindow::addGraphWidget(QMainWindow *parent) +{ + if (!parent) { + parent = currentTab(); + } + QDockWidget *dock = new QDockWidget("Graph", parent); + dock->setWidget(new GraphWindow(dock, backend())); + parent->addDockWidget(Qt::BottomDockWidgetArea, dock); +} + +void MainWindow::addRawTxWidget(QMainWindow *parent) +{ + if (!parent) { + parent = currentTab(); + } + QDockWidget *dock = new QDockWidget("Transmit View", parent); + dock->setWidget(new RawTxWindow(dock, backend())); + parent->addDockWidget(Qt::BottomDockWidgetArea, dock); +} + + void MainWindow::addLogWidget(QMainWindow *parent) { if (!parent) { @@ -408,15 +434,17 @@ void MainWindow::showAboutDialog() "cangaroo\n" "open source can bus analyzer\n" "\n" - "version 0.2.3\n" + "version 0.2.4\n" "\n" - "(c)2015-2017 Hubert Denkmair" + "(c)2015-2017 Hubert Denkmair\n" + "(c)2018 Ethan Zonca" ); } void MainWindow::startMeasurement() { if (showSetupDialog()) { + backend().clearTrace(); backend().startMeasurement(); } } @@ -484,3 +512,60 @@ void MainWindow::on_action_WorkspaceNew_triggered() newWorkspace(); } +void MainWindow::loadTraceFromFile() +{ + QString filters("pcap NG (*.pcapng)"); + QString defaultFilter("pcap NG ASC (*.pcapng)"); + + QFileDialog fileDialog(0, "Load Trace from file", QDir::currentPath(), filters); + fileDialog.setAcceptMode(QFileDialog::AcceptOpen); + fileDialog.selectNameFilter(defaultFilter); + fileDialog.setDefaultSuffix("pcap"); + if (fileDialog.exec()) { + QString QFilename = fileDialog.selectedFiles()[0]; + QByteArray filename = QFilename.toLocal8Bit(); + light_pcapng_t *p = light_pcapng_open_read(filename.data(),LIGHT_FALSE); + if(p != NULL) { + int Records = 0; + QString Msg; + log_info(QString("opened %1").arg(QFilename)); + for( ; ; ) { + light_packet_header pkt_header; + const uint8_t *pkt_data = NULL; + int res = 0; + + res = light_get_next_packet(p,&pkt_header,&pkt_data); + if(res == 0) { + break; + } + + if (pkt_data != NULL) { + Records++; + CanMessage msg; + struct can_frame *frame = (struct can_frame *) pkt_data; + + msg.setTimestamp(pkt_header.timestamp); + msg.setRawId(__builtin_bswap32(frame->can_id)); + msg.setInterfaceId(0); + + uint8_t len = frame->can_dlc; + if(len > 8) { + log_warning(QString("DLC reduced from %1 to 8").arg(len)); + len = 8; + } + + msg.setLength(len); + for (int i=0; idata[i]); + } + backend().getTrace()->enqueueMessage(msg, false); + } + } + light_pcapng_close(p); + log_info(QString("%1 records read").arg(Records)); + } + else { + QMessageBox::critical(this,"Error","Couldn't open file"); + } + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h old mode 100644 new mode 100755 index 1e7c0a2d..57e59085 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -56,7 +56,8 @@ class MainWindow : public QMainWindow public slots: QMainWindow *createTraceWindow(QString title=QString()); QMainWindow *createGraphWindow(QString title=QString()); - + void addGraphWidget(QMainWindow *parent=0); + void addRawTxWidget(QMainWindow *parent=0); void addLogWidget(QMainWindow *parent=0); void addStatusWidget(QMainWindow *parent=0); @@ -66,6 +67,7 @@ public slots: void startMeasurement(); void stopMeasurement(); void saveTraceToFile(); + void loadTraceFromFile(); void updateMeasurementActions(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index aad701f8..e00e3fa2 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -69,7 +69,7 @@ 0 0 1200 - 21 + 22 @@ -96,6 +96,8 @@ + + @@ -121,6 +123,7 @@ + @@ -187,6 +190,9 @@ + + false + &Graph View @@ -242,6 +248,26 @@ Can &Status View + + + Graph View + + + + + Transmit View + + + + + &Load Capture File... + + + + + &Load Trace from file... + + diff --git a/src/object_script.cangaroo.Debug b/src/object_script.cangaroo.Debug new file mode 100644 index 00000000..6ba65a6d --- /dev/null +++ b/src/object_script.cangaroo.Debug @@ -0,0 +1,60 @@ +INPUT( +./../build/o/win32/main.o +./../build/o/win32/mainwindow.o +./../build/o/win32/Backend.o +./../build/o/win32/CanMessage.o +./../build/o/win32/CanTrace.o +./../build/o/win32/CanDbMessage.o +./../build/o/win32/CanDb.o +./../build/o/win32/CanDbNode.o +./../build/o/win32/CanDbSignal.o +./../build/o/win32/MeasurementSetup.o +./../build/o/win32/MeasurementNetwork.o +./../build/o/win32/MeasurementInterface.o +./../build/o/win32/LogModel.o +./../build/o/win32/ConfigurableWidget.o +./../build/o/win32/Log.o +./../build/o/win32/CanInterface.o +./../build/o/win32/CanListener.o +./../build/o/win32/CanDriver.o +./../build/o/win32/CanTiming.o +./../build/o/win32/GenericCanSetupPage.o +./../build/o/win32/DbcParser.o +./../build/o/win32/DbcTokens.o +./../build/o/win32/LinearTraceViewModel.o +./../build/o/win32/AggregatedTraceViewModel.o +./../build/o/win32/BaseTraceViewModel.o +./../build/o/win32/AggregatedTraceViewItem.o +./../build/o/win32/TraceWindow.o +./../build/o/win32/SetupDialog.o +./../build/o/win32/SetupDialogTreeModel.o +./../build/o/win32/SetupDialogTreeItem.o +./../build/o/win32/SelectCanInterfacesDialog.o +./../build/o/win32/LogWindow.o +./../build/o/win32/GraphWindow.o +./../build/o/win32/CanStatusWindow.o +./../build/o/win32/CandleApiDriver.o +./../build/o/win32/CandleApiInterface.o +./../build/o/win32/candle.o +./../build/o/win32/candle_ctrl_req.o +./../build/o/win32/CandleApiTiming.o +./../build/o/win32/qrc_cangaroo.o +./../build/o/win32/moc_mainwindow.o +./../build/o/win32/moc_Backend.o +./../build/o/win32/moc_CanTrace.o +./../build/o/win32/moc_MeasurementSetup.o +./../build/o/win32/moc_LogModel.o +./../build/o/win32/moc_ConfigurableWidget.o +./../build/o/win32/moc_CanListener.o +./../build/o/win32/moc_GenericCanSetupPage.o +./../build/o/win32/moc_LinearTraceViewModel.o +./../build/o/win32/moc_AggregatedTraceViewModel.o +./../build/o/win32/moc_BaseTraceViewModel.o +./../build/o/win32/moc_TraceWindow.o +./../build/o/win32/moc_SetupDialog.o +./../build/o/win32/moc_SetupDialogTreeModel.o +./../build/o/win32/moc_SelectCanInterfacesDialog.o +./../build/o/win32/moc_LogWindow.o +./../build/o/win32/moc_GraphWindow.o +./../build/o/win32/moc_CanStatusWindow.o +); diff --git a/src/object_script.cangaroo.Release b/src/object_script.cangaroo.Release new file mode 100644 index 00000000..6ba65a6d --- /dev/null +++ b/src/object_script.cangaroo.Release @@ -0,0 +1,60 @@ +INPUT( +./../build/o/win32/main.o +./../build/o/win32/mainwindow.o +./../build/o/win32/Backend.o +./../build/o/win32/CanMessage.o +./../build/o/win32/CanTrace.o +./../build/o/win32/CanDbMessage.o +./../build/o/win32/CanDb.o +./../build/o/win32/CanDbNode.o +./../build/o/win32/CanDbSignal.o +./../build/o/win32/MeasurementSetup.o +./../build/o/win32/MeasurementNetwork.o +./../build/o/win32/MeasurementInterface.o +./../build/o/win32/LogModel.o +./../build/o/win32/ConfigurableWidget.o +./../build/o/win32/Log.o +./../build/o/win32/CanInterface.o +./../build/o/win32/CanListener.o +./../build/o/win32/CanDriver.o +./../build/o/win32/CanTiming.o +./../build/o/win32/GenericCanSetupPage.o +./../build/o/win32/DbcParser.o +./../build/o/win32/DbcTokens.o +./../build/o/win32/LinearTraceViewModel.o +./../build/o/win32/AggregatedTraceViewModel.o +./../build/o/win32/BaseTraceViewModel.o +./../build/o/win32/AggregatedTraceViewItem.o +./../build/o/win32/TraceWindow.o +./../build/o/win32/SetupDialog.o +./../build/o/win32/SetupDialogTreeModel.o +./../build/o/win32/SetupDialogTreeItem.o +./../build/o/win32/SelectCanInterfacesDialog.o +./../build/o/win32/LogWindow.o +./../build/o/win32/GraphWindow.o +./../build/o/win32/CanStatusWindow.o +./../build/o/win32/CandleApiDriver.o +./../build/o/win32/CandleApiInterface.o +./../build/o/win32/candle.o +./../build/o/win32/candle_ctrl_req.o +./../build/o/win32/CandleApiTiming.o +./../build/o/win32/qrc_cangaroo.o +./../build/o/win32/moc_mainwindow.o +./../build/o/win32/moc_Backend.o +./../build/o/win32/moc_CanTrace.o +./../build/o/win32/moc_MeasurementSetup.o +./../build/o/win32/moc_LogModel.o +./../build/o/win32/moc_ConfigurableWidget.o +./../build/o/win32/moc_CanListener.o +./../build/o/win32/moc_GenericCanSetupPage.o +./../build/o/win32/moc_LinearTraceViewModel.o +./../build/o/win32/moc_AggregatedTraceViewModel.o +./../build/o/win32/moc_BaseTraceViewModel.o +./../build/o/win32/moc_TraceWindow.o +./../build/o/win32/moc_SetupDialog.o +./../build/o/win32/moc_SetupDialogTreeModel.o +./../build/o/win32/moc_SelectCanInterfacesDialog.o +./../build/o/win32/moc_LogWindow.o +./../build/o/win32/moc_GraphWindow.o +./../build/o/win32/moc_CanStatusWindow.o +); diff --git a/src/parser/dbc/DbcParser.cpp b/src/parser/dbc/DbcParser.cpp index 1fe0ec23..f12f119b 100644 --- a/src/parser/dbc/DbcParser.cpp +++ b/src/parser/dbc/DbcParser.cpp @@ -541,6 +541,7 @@ bool DbcParser::parseSectionBoSg(CanDb &candb, CanDbMessage *msg, DbcTokenList & if (!expectAndSkipToken(tokens, dbc_tok_colon)) { return false; } if (!expectInt(tokens, &start_bit)) { return false; } + signal->setStartBit(start_bit); if (!expectAndSkipToken(tokens, dbc_tok_pipe)) { return false; } @@ -551,6 +552,21 @@ bool DbcParser::parseSectionBoSg(CanDb &candb, CanDbMessage *msg, DbcTokenList & if (!expectInt(tokens, &byte_order)) { return false; } signal->setIsBigEndian(byte_order==0); + // If the signal is big endian, convert the start bit to the Intel-style start bit for further parsing + if(signal->isBigEndian()) + { + // This will be the number of 8-bit rows above the message + uint8_t row_position = signal->startBit() >> 3; + + // Bit position in current row (0-7) + uint8_t column_position = signal->startBit() & 0b111; + + // Calcualte the normalized start bit position (bit index starting at 0) + uint8_t normalized_position = (row_position * 8) + (7 - column_position); + + signal->setStartBit(normalized_position); + } + if (expectAndSkipToken(tokens, dbc_tok_plus)) { signal->setUnsigned(true); } else { diff --git a/src/src.pro b/src/src.pro old mode 100644 new mode 100755 index a6dc6e28..68a1860b --- a/src/src.pro +++ b/src/src.pro @@ -3,6 +3,7 @@ lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5") QT += core gui QT += widgets QT += xml +QT += charts TARGET = cangaroo TEMPLATE = app @@ -17,9 +18,10 @@ unix:OBJECTS_DIR = ../build/o/unix win32:OBJECTS_DIR = ../build/o/win32 macx:OBJECTS_DIR = ../build/o/mac +INCLUDEPATH += $$PWD/LightPcapNg/include SOURCES += main.cpp\ - mainwindow.cpp \ + mainwindow.cpp HEADERS += mainwindow.h \ @@ -35,10 +37,11 @@ include($$PWD/window/SetupDialog/SetupDialog.pri) include($$PWD/window/LogWindow/LogWindow.pri) include($$PWD/window/GraphWindow/GraphWindow.pri) include($$PWD/window/CanStatusWindow/CanStatusWindow.pri) +include($$PWD/window/RawTxWindow/RawTxWindow.pri) +include($$PWD/LightPcapNg.pri) unix:PKGCONFIG += libnl-3.0 unix:PKGCONFIG += libnl-route-3.0 unix:include($$PWD/driver/SocketCanDriver/SocketCanDriver.pri) -win32:include($$PWD/driver/PeakCanDriver/PeakCanDriver.pri) win32:include($$PWD/driver/CandleApiDriver/CandleApiDriver.pri) diff --git a/src/window/GraphWindow/GraphWindow.cpp b/src/window/GraphWindow/GraphWindow.cpp index 8dc743e4..f8e7ba38 100644 --- a/src/window/GraphWindow/GraphWindow.cpp +++ b/src/window/GraphWindow/GraphWindow.cpp @@ -25,6 +25,9 @@ #include #include +#include + +#define NUM_GRAPH_POINTS 20 GraphWindow::GraphWindow(QWidget *parent, Backend &backend) : ConfigurableWidget(parent), @@ -32,11 +35,71 @@ GraphWindow::GraphWindow(QWidget *parent, Backend &backend) : _backend(backend) { ui->setupUi(this); + + + data_series = new QLineSeries(); + + for(uint32_t i=0; iappend(i, i); + } + + data_chart = new QChart(); + data_chart->legend()->hide(); + data_chart->addSeries(data_series); + data_chart->createDefaultAxes(); + data_chart->setTitle("Simple line chart example"); + + + + ui->chartView->setChart(data_chart); + ui->chartView->setRenderHint(QPainter::Antialiasing); + +// connect(ui->buttonTest, SIGNAL(released()), this, SLOT(testAddData())); + + +} + +void GraphWindow::testAddData(qreal new_yval) +{ + QLineSeries* serbuf = new QLineSeries(); + + // Start autorange at first point + qreal ymin = data_series->at(1).y(); + qreal ymax = ymin; + + // Copy all points but first one + for(uint32_t i=1; i < data_series->count(); i++) + { + serbuf->append(data_series->at(i).x()-1, data_series->at(i).y()); + + // Autoranging + if(data_series->at(i).y() < ymin) + ymin = data_series->at(i).y(); + if(data_series->at(i).y() > ymax) + ymax = data_series->at(i).y(); + } + + // Apply Y margin and set range + ymin -= 1; + ymax += 1; + data_chart->axisY()->setRange(ymin, ymax); + + // Add new point in + serbuf->append(serbuf->points().at(serbuf->count()-1).x() + 1, new_yval); + testcount++; + + // Replace data + data_series->replace(serbuf->points()); + + delete serbuf; } GraphWindow::~GraphWindow() { delete ui; + delete data_chart; + delete data_series; } bool GraphWindow::saveXML(Backend &backend, QDomDocument &xml, QDomElement &root) diff --git a/src/window/GraphWindow/GraphWindow.h b/src/window/GraphWindow/GraphWindow.h index 906be889..7698360a 100644 --- a/src/window/GraphWindow/GraphWindow.h +++ b/src/window/GraphWindow/GraphWindow.h @@ -24,6 +24,9 @@ #include #include #include +#include +#include +#include namespace Ui { class GraphWindow; @@ -42,7 +45,14 @@ class GraphWindow : public ConfigurableWidget virtual bool saveXML(Backend &backend, QDomDocument &xml, QDomElement &root); virtual bool loadXML(Backend &backend, QDomElement &el); +private slots: + void testAddData(qreal new_yval); + private: + QLineSeries *data_series; + QChart *data_chart; + uint32_t testcount; + Ui::GraphWindow *ui; Backend &_backend; }; diff --git a/src/window/GraphWindow/GraphWindow.ui b/src/window/GraphWindow/GraphWindow.ui index 003cb024..fb619169 100644 --- a/src/window/GraphWindow/GraphWindow.ui +++ b/src/window/GraphWindow/GraphWindow.ui @@ -6,14 +6,62 @@ 0 0 - 752 - 541 + 301 + 274 + + + 0 + 0 + + + + + 301 + 274 + + Graph + + + + 10 + 10 + 281 + 231 + + + + + 281 + 231 + + + + + + + 210 + 250 + 75 + 23 + + + + Test + + + + + QChartView + QGraphicsView +
QtCharts
+
+
diff --git a/src/window/RawTxWindow/RawTxWindow.cpp b/src/window/RawTxWindow/RawTxWindow.cpp new file mode 100644 index 00000000..79a3eade --- /dev/null +++ b/src/window/RawTxWindow/RawTxWindow.cpp @@ -0,0 +1,187 @@ +/* + + Copyright (c) 2015, 2016 Hubert Denkmair + + This file is part of cangaroo. + + cangaroo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + cangaroo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cangaroo. If not, see . + +*/ + +#include "RawTxWindow.h" +#include "ui_RawTxWindow.h" + +#include +#include +#include +#include + +RawTxWindow::RawTxWindow(QWidget *parent, Backend &backend) : + ConfigurableWidget(parent), + ui(new Ui::RawTxWindow), + _backend(backend) +{ + ui->setupUi(this); + + connect(ui->singleSendButton, SIGNAL(released()), this, SLOT(sendRawMessage())); + connect(ui->repeatSendButton, SIGNAL(toggled(bool)), this, SLOT(sendRepeatMessage(bool))); + + connect(ui->spinBox_RepeatRate, SIGNAL(valueChanged(int)), this, SLOT(changeRepeatRate(int))); + + // Timer for repeating messages + repeatmsg_timer = new QTimer(this); + connect(repeatmsg_timer, SIGNAL(timeout()), this, SLOT(sendRawMessage())); + + + // TODO: Grey out checkboxes that are invalid depending on DLC spinbox state + connect(ui->fieldDLC, SIGNAL(valueChanged(int)), this, SLOT(changeDLC(int))); + +} + +RawTxWindow::~RawTxWindow() +{ + delete ui; +} + + +void RawTxWindow::changeDLC(int dlc) +{ + ui->fieldByte0->setEnabled(true); + ui->fieldByte1->setEnabled(true); + ui->fieldByte2->setEnabled(true); + ui->fieldByte3->setEnabled(true); + ui->fieldByte4->setEnabled(true); + ui->fieldByte5->setEnabled(true); + ui->fieldByte6->setEnabled(true); + ui->fieldByte7->setEnabled(true); + + switch(dlc) + { + case 0: + ui->fieldByte0->setEnabled(false); + //fallthrough + case 1: + ui->fieldByte1->setEnabled(false); + //fallthrough + + case 2: + ui->fieldByte2->setEnabled(false); + //fallthrough + + case 3: + ui->fieldByte3->setEnabled(false); + //fallthrough + + case 4: + ui->fieldByte4->setEnabled(false); + //fallthrough + + case 5: + ui->fieldByte5->setEnabled(false); + //fallthrough + + case 6: + ui->fieldByte6->setEnabled(false); + //fallthrough + + case 7: + ui->fieldByte7->setEnabled(false); + //fallthrough + } +// repeatmsg_timer->setInterval(ms); +} + + +void RawTxWindow::changeRepeatRate(int ms) +{ + repeatmsg_timer->setInterval(ms); +} + +void RawTxWindow::sendRepeatMessage(bool enable) +{ + if(enable) + { + repeatmsg_timer->start(ui->spinBox_RepeatRate->value()); + } + else + { + repeatmsg_timer->stop(); + } +} + +void RawTxWindow::sendRawMessage() +{ + CanMessage msg; + + bool en_extended = ui->checkBox_IsExtended->isChecked(); + bool en_rtr = ui->checkBox_IsRTR->isChecked(); + bool en_errorframe = ui->checkBox_IsErrorFrame->isChecked(); + + uint8_t data_int[8]; + + data_int[0] = ui->fieldByte0->text().toUpper().toInt(NULL, 16); + data_int[1] = ui->fieldByte1->text().toUpper().toInt(NULL, 16); + data_int[2] = ui->fieldByte2->text().toUpper().toInt(NULL, 16); + data_int[3] = ui->fieldByte3->text().toUpper().toInt(NULL, 16); + data_int[4] = ui->fieldByte4->text().toUpper().toInt(NULL, 16); + data_int[5] = ui->fieldByte5->text().toUpper().toInt(NULL, 16); + data_int[6] = ui->fieldByte6->text().toUpper().toInt(NULL, 16); + data_int[7] = ui->fieldByte7->text().toUpper().toInt(NULL, 16); + + uint32_t address = ui->fieldAddress->text().toUpper().toInt(NULL, 16); + + // If address is beyond std address namespace, force extended + if(address > 0x7ff) + { + en_extended = true; + ui->checkBox_IsExtended->setChecked(true); + } + + uint8_t dlc = ui->fieldDLC->text().toUpper().toInt(NULL, 16); + + msg.setData(data_int[0],data_int[1],data_int[2],data_int[3],data_int[4],data_int[5],data_int[6],data_int[7]); + msg.setId(address); + msg.setLength(dlc); + + msg.setExtended(en_extended); + msg.setRTR(en_rtr); + msg.setErrorFrame(en_errorframe); + + + foreach (CanInterfaceId ifid, _backend.getInterfaceList()) { + CanInterface *intf = _backend.getInterfaceById(ifid); + intf->sendMessage(msg); + + + char outmsg[256]; + snprintf(outmsg, 256, "Send [%s] to %d on port %s [ext=%u rtr=%u err=%u]", + msg.getDataHexString().toLocal8Bit().constData(), msg.getId(), _backend.getInterfaceById(ifid)->getName().toLocal8Bit().constData(), + msg.isExtended(), msg.isRTR(), msg.isErrorFrame()); + log_info(outmsg); + } + +} + +bool RawTxWindow::saveXML(Backend &backend, QDomDocument &xml, QDomElement &root) +{ + if (!ConfigurableWidget::saveXML(backend, xml, root)) { return false; } + root.setAttribute("type", "RawTxWindow"); + return true; +} + +bool RawTxWindow::loadXML(Backend &backend, QDomElement &el) +{ + if (!ConfigurableWidget::loadXML(backend, el)) { return false; } + return true; +} diff --git a/src/window/RawTxWindow/RawTxWindow.h b/src/window/RawTxWindow/RawTxWindow.h new file mode 100644 index 00000000..aafa3a2d --- /dev/null +++ b/src/window/RawTxWindow/RawTxWindow.h @@ -0,0 +1,57 @@ +/* + + Copyright (c) 2015, 2016 Hubert Denkmair + + This file is part of cangaroo. + + cangaroo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + cangaroo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cangaroo. If not, see . + +*/ + +#pragma once + +#include +#include +#include + +namespace Ui { +class RawTxWindow; +} + +class QDomDocument; +class QDomElement; + +class RawTxWindow : public ConfigurableWidget +{ + Q_OBJECT + +public: + explicit RawTxWindow(QWidget *parent, Backend &backend); + ~RawTxWindow(); + + virtual bool saveXML(Backend &backend, QDomDocument &xml, QDomElement &root); + virtual bool loadXML(Backend &backend, QDomElement &el); + +private slots: + void changeDLC(int dlc); + void changeRepeatRate(int ms); + void sendRepeatMessage(bool enable); + void sendRawMessage(); + + +private: + Ui::RawTxWindow *ui; + Backend &_backend; + QTimer *repeatmsg_timer; +}; diff --git a/src/window/RawTxWindow/RawTxWindow.pri b/src/window/RawTxWindow/RawTxWindow.pri new file mode 100644 index 00000000..c0005567 --- /dev/null +++ b/src/window/RawTxWindow/RawTxWindow.pri @@ -0,0 +1,8 @@ +SOURCES += \ + $$PWD/RawTxWindow.cpp + +HEADERS += \ + $$PWD/RawTxWindow.h + +FORMS += \ + $$PWD/RawTxWindow.ui diff --git a/src/window/RawTxWindow/RawTxWindow.ui b/src/window/RawTxWindow/RawTxWindow.ui new file mode 100644 index 00000000..b00b9154 --- /dev/null +++ b/src/window/RawTxWindow/RawTxWindow.ui @@ -0,0 +1,485 @@ + + + RawTxWindow + + + + 0 + 0 + 371 + 151 + + + + + 0 + 0 + + + + + 371 + 151 + + + + Raw Transmit + + + + + 10 + 100 + 87 + 25 + + + + Send Single + + + + + + 110 + 100 + 95 + 25 + + + + Send Repeat + + + true + + + + + + 300 + 100 + 31 + 26 + + + + ms + + + + + + 10 + 30 + 72 + 20 + + + + hhhhhhhh + + + 00 + + + + + + 10 + 10 + 55 + 17 + + + + Address + + + + + + 90 + 30 + 31 + 20 + + + + 0 + + + 8 + + + 8 + + + + + + 90 + 10 + 28 + 17 + + + + DLC + + + + + + 130 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 130 + 50 + 21 + 16 + + + + 1 + + + Qt::AlignCenter + + + + + + 128 + -1 + 231 + 31 + + + + Payload + + + Qt::AlignCenter + + + + + + 160 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 190 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 220 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 250 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 280 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 310 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 340 + 30 + 21 + 20 + + + + hh + + + 00 + + + 2 + + + + + + 160 + 50 + 21 + 16 + + + + 2 + + + Qt::AlignCenter + + + + + + 190 + 50 + 21 + 16 + + + + 3 + + + Qt::AlignCenter + + + + + + 220 + 50 + 21 + 16 + + + + 4 + + + Qt::AlignCenter + + + + + + 250 + 50 + 21 + 16 + + + + 5 + + + Qt::AlignCenter + + + + + + 280 + 50 + 21 + 16 + + + + 6 + + + Qt::AlignCenter + + + + + + 310 + 50 + 21 + 16 + + + + 7 + + + Qt::AlignCenter + + + + + + 340 + 50 + 21 + 16 + + + + 8 + + + Qt::AlignCenter + + + + + + 220 + 100 + 74 + 26 + + + + 10000 + + + 1000 + + + + + + 140 + 70 + 54 + 23 + + + + RTR + + + + + + 10 + 70 + 109 + 23 + + + + Extended ID + + + + + + 230 + 70 + 106 + 23 + + + + Error Frame + + + + + + diff --git a/src/window/SetupDialog/SetupDialog.cpp b/src/window/SetupDialog/SetupDialog.cpp index 0a4dba1e..3810e4f0 100644 --- a/src/window/SetupDialog/SetupDialog.cpp +++ b/src/window/SetupDialog/SetupDialog.cpp @@ -51,6 +51,7 @@ SetupDialog::SetupDialog(Backend &backend, QWidget *parent) : _actionDeleteInterface = new QAction("Delete", this); _actionAddCanDb = new QAction("Add...", this); _actionDeleteCanDb = new QAction("Delete", this); + _actionReloadCanDbs = new QAction("Reload", this); model = new SetupDialogTreeModel(_backend, this); @@ -80,12 +81,15 @@ SetupDialog::SetupDialog(Backend &backend, QWidget *parent) : connect(ui->candbsTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateButtons())); connect(ui->interfacesTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateButtons())); + connect(ui->btReloadDatabases, SIGNAL (released()), this, SLOT(executeReloadCanDbs())); + connect(_actionAddCanDb, SIGNAL(triggered()), this, SLOT(executeAddCanDb())); connect(_actionDeleteCanDb, SIGNAL(triggered()), this, SLOT(executeDeleteCanDb())); connect(_actionAddInterface, SIGNAL(triggered()), this, SLOT(executeAddInterface())); connect(_actionDeleteInterface, SIGNAL(triggered()), this, SLOT(executeDeleteInterface())); + emit backend.onSetupDialogCreated(*this); } @@ -209,6 +213,7 @@ void SetupDialog::treeViewContextMenu(const QPoint &pos) break; case SetupDialogTreeItem::type_candb: contextMenu.addAction(_actionDeleteCanDb); + contextMenu.addAction(_actionReloadCanDbs); break; default: break; @@ -269,11 +274,24 @@ void SetupDialog::addCanDb(const QModelIndex &parent) } } +void SetupDialog::reloadCanDbs(const QModelIndex &parent) +{ + SetupDialogTreeItem *parentItem = static_cast(parent.internalPointer()); + + parentItem->network->reloadCanDbs(_backend); +} + void SetupDialog::executeAddCanDb() { addCanDb(ui->treeView->selectionModel()->currentIndex()); } + +void SetupDialog::executeReloadCanDbs() +{ + reloadCanDbs(ui->treeView->selectionModel()->currentIndex()); +} + void SetupDialog::on_btAddDatabase_clicked() { addCanDb(ui->treeView->selectionModel()->currentIndex()); @@ -292,6 +310,9 @@ void SetupDialog::on_btRemoveDatabase_clicked() void SetupDialog::updateButtons() { ui->btRemoveDatabase->setEnabled(ui->candbsTreeView->selectionModel()->hasSelection()); + +// ui->btReloadDatabases->setEnabled(ui->candbsTreeView->children.count() > 0); + ui->btRemoveInterface->setEnabled(ui->interfacesTreeView->selectionModel()->hasSelection()); SetupDialogTreeItem *item = getSelectedItem(); diff --git a/src/window/SetupDialog/SetupDialog.h b/src/window/SetupDialog/SetupDialog.h index 3d41e89f..cfdc5be8 100644 --- a/src/window/SetupDialog/SetupDialog.h +++ b/src/window/SetupDialog/SetupDialog.h @@ -66,6 +66,7 @@ private slots: void updateButtons(); void executeAddCanDb(); + void executeReloadCanDbs(); void executeDeleteCanDb(); void executeAddInterface(); @@ -83,6 +84,7 @@ private slots: QAction *_actionDeleteCanDb; QAction *_actionAddInterface; QAction *_actionAddCanDb; + QAction *_actionReloadCanDbs; SetupDialogTreeModel *model; MeasurementNetwork *_currentNetwork; @@ -91,6 +93,7 @@ private slots: SetupDialogTreeItem *getSelectedItem(); void addCanDb(const QModelIndex &parent); + void reloadCanDbs(const QModelIndex &parent); void addInterface(const QModelIndex &parent); }; diff --git a/src/window/SetupDialog/SetupDialog.ui b/src/window/SetupDialog/SetupDialog.ui index 7649471c..4c76af78 100644 --- a/src/window/SetupDialog/SetupDialog.ui +++ b/src/window/SetupDialog/SetupDialog.ui @@ -240,6 +240,13 @@ + + + + Reload Databases + + +
diff --git a/src/window/SetupDialog/SetupDialogTreeItem.h b/src/window/SetupDialog/SetupDialogTreeItem.h index d96aa383..2a131089 100644 --- a/src/window/SetupDialog/SetupDialogTreeItem.h +++ b/src/window/SetupDialog/SetupDialogTreeItem.h @@ -40,7 +40,7 @@ class SetupDialogTreeItem type_interface_root, type_interface, type_candb_root, - type_candb + type_candb, } item_type; public: diff --git a/src/window/TraceWindow/BaseTraceViewModel.cpp b/src/window/TraceWindow/BaseTraceViewModel.cpp index f56af41d..62f77a5e 100644 --- a/src/window/TraceWindow/BaseTraceViewModel.cpp +++ b/src/window/TraceWindow/BaseTraceViewModel.cpp @@ -54,6 +54,8 @@ QVariant BaseTraceViewModel::headerData(int section, Qt::Orientation orientation return QString("Rx/Tx"); case column_canid: return QString("CAN ID"); + case column_sender: + return QString("Sender"); case column_name: return QString("Name"); case column_dlc: @@ -160,6 +162,9 @@ QVariant BaseTraceViewModel::data_DisplayRole_Message(const QModelIndex &index, case column_name: return (dbmsg) ? dbmsg->getName() : ""; + case column_sender: + return (dbmsg) ? dbmsg->getSender()->name() : ""; + case column_dlc: return currentMsg.getLength(); @@ -178,7 +183,7 @@ QVariant BaseTraceViewModel::data_DisplayRole_Message(const QModelIndex &index, QVariant BaseTraceViewModel::data_DisplayRole_Signal(const QModelIndex &index, int role, const CanMessage &msg) const { (void) role; - uint32_t raw_data; + uint64_t raw_data; QString value_name; QString unit; @@ -232,6 +237,7 @@ QVariant BaseTraceViewModel::data_TextAlignmentRole(const QModelIndex &index, in case column_channel: return Qt::AlignCenter + Qt::AlignVCenter; case column_direction: return Qt::AlignCenter + Qt::AlignVCenter; case column_canid: return Qt::AlignRight + Qt::AlignVCenter; + case column_sender: return Qt::AlignLeft + Qt::AlignVCenter; case column_name: return Qt::AlignLeft + Qt::AlignVCenter; case column_dlc: return Qt::AlignCenter + Qt::AlignVCenter; case column_data: return Qt::AlignLeft + Qt::AlignVCenter; diff --git a/src/window/TraceWindow/BaseTraceViewModel.h b/src/window/TraceWindow/BaseTraceViewModel.h index db21f8c1..3ef60cc6 100644 --- a/src/window/TraceWindow/BaseTraceViewModel.h +++ b/src/window/TraceWindow/BaseTraceViewModel.h @@ -39,6 +39,7 @@ class BaseTraceViewModel : public QAbstractItemModel column_channel, column_direction, column_canid, + column_sender, column_name, column_dlc, column_data, diff --git a/src/window/TraceWindow/TraceWindow.cpp b/src/window/TraceWindow/TraceWindow.cpp index d80d6727..eee02a11 100644 --- a/src/window/TraceWindow/TraceWindow.cpp +++ b/src/window/TraceWindow/TraceWindow.cpp @@ -44,7 +44,7 @@ TraceWindow::TraceWindow(QWidget *parent, Backend &backend) : _aggregatedProxyModel->setSourceModel(_aggregatedTraceViewModel); _aggregatedProxyModel->setDynamicSortFilter(true); - setMode(mode_linear); + setMode(mode_aggregated); setAutoScroll(false); QFont font("Monospace"); @@ -57,14 +57,15 @@ TraceWindow::TraceWindow(QWidget *parent, Backend &backend) : ui->tree->setColumnWidth(2, 50); ui->tree->setColumnWidth(3, 90); ui->tree->setColumnWidth(4, 200); - ui->tree->setColumnWidth(5, 50); - ui->tree->setColumnWidth(6, 200); + ui->tree->setColumnWidth(5, 200); + ui->tree->setColumnWidth(6, 50); + ui->tree->setColumnWidth(7, 200); ui->tree->sortByColumn(BaseTraceViewModel::column_canid, Qt::AscendingOrder); ui->cbTimestampMode->addItem("absolute", 0); ui->cbTimestampMode->addItem("relative", 1); ui->cbTimestampMode->addItem("delta", 2); - setTimestampMode(timestamp_mode_relative); + setTimestampMode(timestamp_mode_delta); connect(_linearTraceViewModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); diff --git a/src/window/TraceWindow/TraceWindow.ui b/src/window/TraceWindow/TraceWindow.ui index cf7cc869..6409b60f 100644 --- a/src/window/TraceWindow/TraceWindow.ui +++ b/src/window/TraceWindow/TraceWindow.ui @@ -44,6 +44,9 @@ aggregate by ID + + false +