summaryrefslogtreecommitdiff
path: root/src/lib
Commit message (Collapse)AuthorAgeFilesLines
* fixes compilation issue with clangSebastien RAILLET2021-10-131-2/+2
| | | | | | | * function atomic_compare_exchange_strong expect a pointer to an _Atomic type. dlt_user_initialised is now an atomic_bool * function dlt_set_filesize_max returned a DLT_LOG_ERROR which isn't a DltReturnValue. This commit replaces DLT_LOG_ERROR by DLT_RETURN_ERROR which is the expected return type Signed-off-by: Sebastien RAILLET <sebastien.raillet@marelli.com>
* lib: Fix wrong type alert from lgtmSaya Sugiura2021-10-051-2/+2
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: generate dlt library internal log fileLe-Tin2021-10-051-0/+10
| | | | | | | Extern logging_mode and logging_handle variables from commom.c Reusing dlt_log_init() in cases dlt library internal log file is not opened and logging_mode is DLT_LOG_TO_FILE Signed-off-by: Le-Tin <Tin.Le@vn.bosch.com>
* dlt_user: Make dlt_init thread safeDarian Biastoch2021-10-051-5/+21
| | | | | | | | | | | | | This commit introduces the use of atomic_compare_exchange at beginning of both dlt_init functions. This function checks in an atomic way, if 'dlt_user_initialised' is 'false' (first run through dlt_init) and directly sets it 'true'. If a second thread also entered dlt-init at this point of time, its call of atomic_compare_exchange will return false and dlt_init will be immediately left due to that. This is only interesting for startup, because before each call of dlt_init, there is a check on 'dlt_user_initialised' that will fail for all later executions. Signed-off-by: Darian Biastoch <dbiastoch@de.adit-jv.com>
* remove clang-tidy analyzer warnings: incompatible pointer typeDarian Biastoch2021-10-051-50/+35
| | | | | | | | | | Removed duplicate "payload" pointer in dlt_client_send functions inside dlt_client.c. This pointer was only needed to avoid one cast within a function call. Now this cast is performed to get rid of clang-tidy analyzer warnings. In addition to that, malloc calls were replaced through calloc to avoid a subsequent memset with zero. Signed-off-by: Darian Biastoch <dbiastoch@de.adit-jv.com>
* lib: Add SOCK_CLOEXEC to socketSaya Sugiura2021-10-051-1/+1
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* header: Adapt to DLT_DISABLE_MACROSaya Sugiura2021-10-051-0/+1
| | | | | | | | | If dlt.h is included in external application, it needed to include -DDLT_DISABLE_MACRO to make ifdef switch work. This commit adds DLT_DISABLE_MACRO in dlt_user.h so that no additional definition is needed in application. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: Add new interfaces with given bufferSaya Sugiura2021-10-051-30/+92
| | | | | | | | | | | | This commit adds new interfaces: - dlt_user_log_write_start_w_given_buffer(): accepts a log buffer as an input. - dlt_user_log_write_finish_w_given_buffer(): finalizes logging and send the message to corresponding output This is to reduce DLT API calls in DLT application as much as possible and avoid allocating dynamic memory within DLT library. The log buffer has to be prepared in DLT application in order to use these interfaces. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* lib: Add MaxFileSize handlingNarasimhaiah Suprathik (RBEI/ECF3)2021-10-051-6/+58
| | | | Signed-Off By: Saya Sugiura <ssugiura@jp.adit-jv.com>
* console: provides args option to enable send/receive serial headerVo Trung Chi2021-10-051-5/+62
| | | | | | | Provides argument option to enable send and resync serial header via command line. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* fix malformed printf format strings (#295)Radek Kaczorowski2021-10-051-9/+9
| | | Co-authored-by: Saya Sugiura <39760799+ssugiura@users.noreply.github.com>
* Make the legacy include path a CMake option (#332)Martin Willers2021-10-051-1/+7
| | | Signed-off-by: Martin Willers <M.Willers@gmx.net>
* dlt_user: Use pthread_setname_np() if available (#326)Sebastian Lipponer2021-09-141-5/+13
| | | | | | | Use POSIX thread API to rename the housekeeper and segmented threads. The currently used prctl() function is Linux specific and in general not available on other platforms (e.g. QNX). Signed-off-by: Sebastian Lipponer <mail@sebastianlipponer.de>
* libdlt: Add legacy include path in exported CMake config file (#327)Sebastian Lipponer2021-09-141-0/+1
| | | | | | | | | | | | | Previously the generated .pc file was changed to export an additional include path such that '#include <dlt.h>' and '#include <dlt/dlt.h>' can be used. However the exported CMake config file only supports the latter include statement. Consequently code that uses the other legacy include statement does not compile with the exported CMake config file. This change fixes this inconsistency. It lets users compile existing code with either the pkg-config .pc file or the CMake config file and avoids code clutter that is currently necessary to make this work. Signed-off-by: Sebastian Lipponer <mail@sebastianlipponer.de>
* lib: Set TYLE to 1 for BOOL type (#320)TomiZet2021-08-301-2/+2
| | | According to AUTOSAR standard the TYLE for the BOOL type shall be set to 1. So I propose to initialize type_info variable for the BOOL type the same way as for uint8 type.
* file-transfer: Abort file transfer if get serial number failedAlexander Mohr2021-08-061-0/+6
| | | | | | | | | | | If a file is deleted while a file transfer is ongoing, the file transfer tries to seek through the whole file. This is due to the fact the the file handle is held open. getFileSerialNumber is already validating the file by using stat. If this call returns a negative value, we know that a stat to the file is not possible anymore, therefore further reading can be aborted.
* dlt_user.c: fixing casting wrong typeDinh Cong Toan2021-08-061-3/+3
| | | | | | Fixing casting incorrect type Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* Update document and fix conversion warningDinh Cong Toan2021-06-301-2/+0
| | | | Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* Using dlt_vlog in verbose option in dlt_client.cDinh Cong Toan2021-06-301-47/+113
| | | | | | | Several verbose condition in dlt_client.c are using printf() and fprintf() that not print consistent logs to console. These are replaced by dlt-vlog(). Signed-off-by: KHANH LUONG HONG DUY khanh.luonghongduy@vn.bosch.com
* dlt_user: correct handling return valueDinh Cong Toan2021-06-301-14/+18
| | | | | | | | When processing dlt_user_log_send_log() function, message logs will be stored in internal buffer in error case. Then, the error value is needed to handle correctly before exiting. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* Alternative solutions for json-c dependencyBiastoch, Darian (ADITG/ESM)2021-06-301-1/+1
| | | | | | | json-c dependency was removed from libdlt ('dlt_common') and shifted into 'dlt-control-common'. By this only the command line tools have a dependency on json-c. dlt-control-common is now built as a static library, so that it can be linked against json-c. Command line tools that included only the .c file of dlt-control-common before, are now linked against this static libarary (see console/CMakeLists.txt). Signed-off-by: dbiastoch <dbiastoch@de.adit-jv.com>
* Apply uncrustify for src/daemon/* and src/lib/*Dinh Cong Toan2021-06-304-121/+186
| | | | | | Apply uncrustify for src/daemon/* and src/lib/* Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* dlt-receive: Enabled more filtering by using json filter filesdbiastoch2021-06-301-1/+1
| | | | | | | | | | | | | | | -Added '-j' flag to dlt-receive for reading a json filter file -Added more attributes to DltFilter (LogLevel, MaxPayload, MinPayload) for extended message filtering, when using old filters these values are set to default. Same behaviour, when they are not defined in json filter file. -extended dlt_common.c to support json filter files and new DltFilter attributes +add dlt_json_filter_load to parse a json filter file into a DltFilter +add dlt_json_filter_save to print a DltFilter into a json file -Two new libraries are used to parse the json filter files: json-c for Linux based systems and the QNX internal libjson for QNX systems -gtest_dlt_common was modified to test the new function 'dlt_json_filter_load' +add testfile_extended.dlt that contains a bigger varity of messages (different context/app IDs, lengths and log levels) +add testfilter.json which is a valid json filter file -New dependency on library was added to related CMakeLists and is described in README.md Signed-off-by: dbiastoch <dbiastoch@de.adit-jv.com>
* dlt message header brokenDinh Cong Toan2021-06-302-20/+20
| | | | | | | | | | | | | This commit is to revert the following commits: - de4a4234 - fb9ff078 - db9917b3 - e4467f0e - a567e01d Those commits are from improvement but they seem to break the dlt message header in some cases. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* Add missing string functions (#309)Martin Willers2021-05-311-0/+24
| | | Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Make nonverbose mode non exclusive (#300)Martin Willers2021-05-171-38/+60
| | | | | | | | | | | | | | | | * Make Non-Verbose mode non-exclusive Switching to global Non-Verbose mode now does not force Verbose messages to also be sent as Non-Verbose ones anymore. That would not make any sense, because Verbose messages don't have a MessageId and thus are all getting the same MessageId of 65535. Instead, setting global "Non-Verbose" mode will allow both Verbose and Non-Verbose messages to be sent in a single session. The "Verbose-APIs" (e.g. dlt_user_log_write_start()) will then only write Verbose messages, whereas the "Non-Verbose APIs" (e.g. dlt_user_log_write_start_id()) will then only write Non-Verbose messages. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Export cmake config file (#289)Martin Willers2021-05-101-2/+36
| | | | | | | | | | | | | | Create and install proper CMake *-target.cmake and *-config.cmake files, for use by other CMake-using projects. It installs a file called automotive-dlt-targets.cmake into a common location for such files, namely <prefix>/lib/cmake/automotive-dlt/automotive-dlt-targets.cmake They can now call find_package(automotive-dlt) and obtain a target called Genivi::dlt that they can link against with target_link_libraries(), by which they automatically gain all necessary attributes, including libdlt's include directories. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* fix bad funcion cast in dlt_user_log_out_error_handling (#294)Radek Kaczorowski2021-03-261-5/+5
| | | Co-authored-by: FIXED-TERM Kaczorowski Radoslaw (BSOT/PJ-ES21) <Fixed-Term.Radoslaw.Kaczorowski@bosch-softtec.com>
* Add verbose mode attribute handling (#292)Martin Willers2021-03-161-502/+357
| | | | | | dlt_user_log_write_*_attr() enables to writing these types, but also support adding "attributes" for them, i.e. a "name" and a "unit". Signed-off-by: Martin Willers <M.Willers@gmx.net>
* dlt_client_main_loop running in an infinite loop restricts graceful exit of ↵Sreeharsha Ramanavarapu2021-01-081-1/+10
| | | | | | | | | | | | | | | | | | | | | | | DLT Client code (#284) Issue: ------ dlt_client_main_loop currently uses an infinite loop ("while (1)"). This creates problems when a DLT client is running in a thread as part of a larger application. Graceful exit (for example: during object destruction) is not possible because a thread is running dlt_client_main_loop in the background. It is also not possible to exit the client, if we want it to fetch only a pre-decided number of messages. Solution: --------- Allow user to define a callback function to check whether the next message should be fetched. dlt-test-client.c has a new option to fetch a pre-decided number of messages, after which the client will exit. Signed-off-by: Sreeharsha Ramanavarapu <sreeharsha.r@gmail.com>
* other: fix remaining conversion warningsDinh Cong Toan2021-01-063-25/+25
| | | | | | | | | | | - Converting datatype to the correct one. - As macro do not perform type-checking before, so these functions used it with different datatype could create a lot of conversion warnings. For this reason, these warnings could be consider as normal information and will not be fixed. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* library: fix conversion warningsDinh Cong Toan(RBVH/ECM12)2021-01-064-84/+87
| | | | | | | | | | | | - Change the data type of variable 'size' in DltContextData struct (dlt_user.h.in). Variable 'size' was used repeated with function 'sizeof()' many time, so change type to 'size_t' can avoid a lot of warnings. - Adding temporary variable to calculate the datasize header (define in dlt_common.h) in 'dlt_common.c' file. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* gateway: fix compile warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-6/+6
| | | | | | | | | - Correct the data type of 'headersize' and 'datasize' variables in header 'dlt_common.h', then config those functions using this library. - Explicit the data type. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* libdlt: Use SIGUSR1 for thread on AndroidBui Nguyen Quoc Thanh2021-01-062-5/+36
| | | | | | | Since bionic does not support pthread_cancel(), try to terminate housekeeper thread via SIGUSR1. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: Use poll to avoid CPU high loadBui Nguyen Quoc Thanh2021-01-061-29/+49
| | | | | | | | | | | | | Use timeout of polling as time for retry. In case of timeout or failure of polling, continue to close the socket. It could take some times to get the socket is shutdown So it means there could be some data available to read. Try to consume the data and poll the socket again. If read fails, time to close the socket then. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: Flush all data in atexit_handlerSaya Sugiura2021-01-061-13/+43
| | | | | | | | | | | | | | | | | Current implementation had two issues: - Remaining data in startup_buffer wasn't able to be sent to daemon even dlt_user.timeout_at_exit_handler was set to more than 0 - Socket could be closed before all the data was sent to daemon To solve this: - dlt_unregister_app_flush_buffered_logs() won't clean appIDs if any data is remaining in startup_buffer. atexit_handler will be in charge of cleaning them - Socket won't be closed if data wasn't sent due to errno EAGAIN or EWOULDBLOCK. It retries until execution count reaches to maximum DLT_USER_MAX_RETRY_COUNT (1000 as default) Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* libdlt: support short versionBui Nguyen Quoc Thanh2021-01-061-1/+6
| | | | | | Use cmake option to support version with major number only. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* libdlt: disable injection msg via env varBui Nguyen Quoc Thanh2021-01-062-3/+13
| | | | | | | | | | | | | | In order to disable injection message at dlt user, set DLT_DISABLE_INJECTION_MSG_AT_USER to any value. When injection message is disabled, libdlt won't poll any data from receiver. It means libdlt will ignore all data/messages from dlt-daemon. By default, variable is unset so that dlt users are able to handle data/messages from dlt-daemon. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* dlt_user: fix invalid poll timeoutAlexander Mohr2021-01-062-7/+5
| | | | | | | | | | | | | | The poll timeout was only set for fifo. TCP connections require this timeout as well. dlt_user_log_check_user_message also validated the file descriptor to be greater 0. Because 0 is a valid file descriptor this check has been changed to greater or equal 0. poll receives a timeout in milliseconds. The given paramter was in nanoseconds. An additional define takes adds the delay in miliseconds. Signed-off-by: Alexander Mohr <alexander.m.mohr@daimler.com>
* Add support for logging with VSOCK (#255)Martin Ejdestig2020-12-142-39/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
* dlt_client.c: remove misleading error message (#258)Moritz Warning2020-11-171-3/+3
| | | | | | Several IP address might be tested for connect. Only output an error if no address succeeds at all. Signed-off-by: Moritz Warning <moritzwarning@web.de>
* Make it easier to use libdlt when building DLT as a CMake subproject (#254)Martin Ejdestig2020-10-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By calling target_include_directories() for the dlt target in src/lib/. CMake filters out duplicate include paths. So even if the include directories are already added with include_directories() in the top-level CMakeLists.txt, they are not duplicated when the compiler is invoked. For example, with this patch, the following works: [~/Source/foo]$ ls bar CMakeLists.txt dlt-daemon [~/Source/foo]$ cat CMakeLists.txt cmake_minimum_required(VERSION 3.3 FATAL_ERROR) project(foo) add_subdirectory(dlt-daemon) add_subdirectory(bar) [~/Source/foo]$ cat bar/CMakeLists.txt cmake_minimum_required(VERSION 3.3 FATAL_ERROR) project(bar) add_executable(bar main.cpp) target_link_libraries(bar dlt) install(TARGETS bar RUNTIME DESTINATION bin) bar/main.cpp contains the example from the top of doc/dlt_for_developers.md that does "#include <dlt.h>" and then uses the DLT logging macros. Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
* Implement DLTClient for UDP multicast (#240)João Sousa2020-08-311-1/+81
| | | | | | | | | * Add UDP multicast support on client side UDP multicast support is already present on server side. This patch add seemless support for UDP multicast on client side in dlt-receive. Signed-off-by: Joao Sousa <joao.sa.sousa@ctw.bmwgroup.com>
* dlt_user.c: fix the lack of DLT_NETWORK_TRACE_ENABLE definitionKHANH LUONG HONG DUY2020-08-031-0/+2
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* network trace: Fix macro usageKHANH LUONG HONG DUY2020-07-061-1/+1
| | | | Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* update cmake VERSION variablesFelix Herrmann2020-07-061-1/+1
| | | | | | | align variable names with cmake 3.3 change. => DLT_VERSION* -> PROJECT_VERSION* Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com>
* libdlt: Relocate dltFifoBaseDir settingLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-3/+0
| | | | | | | Relocate the setting of dltFifoBaseDir variable from dlt_init() to dlt_check_envvar() Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* network trace: Add mqueue verificationSaya Sugiura2020-07-061-18/+29
| | | | | | | | | | There is some OS (e.g. Android) which doesn't support message queue. Since network trace uses it as IPC, we need to disable it if following calls are not available: mq_open, mq_close, mq_unlink, mq_send, mq_receive Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* relocation dlt_check_envvar() and update dlt_init() functionsLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-6/+6
| | | | Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* fix some gcc9 compiler warningsFelix Herrmann2020-07-061-31/+30
| | | | | | | | | Many stringop-truncation and stringop-overflow warnings are still there (so many). https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>