summaryrefslogtreecommitdiff
path: root/src/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Android: Enable Android buildFelix Herrmann2020-07-061-5/+31
| | | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* correct errno usage in dlt_stop_threadsVo Trung Chi2020-07-061-11/+6
| | | | | | | | | | | Most pthreads functions return 0 on success, and an error number on failure. Note that the pthreads functions do not set errno. Refer to man page of pthreads for detail. So we have to use the return value as the error number instead of errno variable. Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* FIX: prevent usage of uninitialized message queue handleRudolf Svanda2020-05-181-1/+3
| | | | | | | | | Problem occurs always if application exits and dlt_user.dlt_segmented_queue_read_handle is not initialized. Warning "NWTSegmented: Error while reading queue" is printed on terminal on embedded devices. Signed-off-by: Rudolf Svanda <rudolf.svanda@globallogic.com>
* Minor optimizationMartin Willers2020-05-181-1/+1
| | | | | | | There is no need to have both an array and a pointer to it; just use the array directly. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Add functions for writing strings with known sizesMartin Willers2020-05-181-0/+16
| | | | Signed-off-by: Martin Willers <M.Willers@gmx.net>
* Add helper function for writing strings with known sizesMartin Willers2020-05-181-3/+17
| | | | | | | | | | | This use case is common in C++ code nowadays, due to the usage of e.g. std::string_view, which does not provide a function for retrieving a null-terminated C-string, but which provides quick access to the string length via std::string_view::size(). Such use cases can now avoid an entirely unnecessary strlen() call. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* sys/poll.h: deprecate old sys/poll.h include header, now glibc/musl wants ↵Gianfranco Costamagna2020-01-271-1/+1
| | | | | | | | | poll.h being included directly. This fixes a build failure on musl systems with strict c hardening flags Signed-off-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it> Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
* dlt_user: init DltContextData before usePhong Tran2019-12-111-5/+4
| | | | | | | | for fixing the coverity warnings type Uninitialized scalar variable (UNINIT). Using uninitialized value log.use_timestamp when calling dlt_user_log_send_log. Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* Provide DLT_GET_APPID macro (#187) (#188)Vo Trung Chi2019-11-141-0/+11
| | | Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
* libdlt: reattachment and improvement in dlt thread (#171)Vo Trung Chi2019-10-012-110/+61
| | | | | | | | | | | | | | | | | Improvement: housekeeper thread with poll - Change name receiver thread to housekeeper thread - Use poll() in housekeeper thread to get new received message from DLT Daemon. - Remove resend buffer inside of dlt_user_log_reattach_to_daemon() - Only try to resend buffer if fd is valid. This commit removes the event driven dlt_user_log_reattach_to_daemon() that is called e.g. by DLT_LOG. Now, only the DLT housekeeper thread handles the retrial to attach to daemon. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com> Signed-off-by: Simon Herkenhoff <sherkenhoff@jp.adit-jv.com> Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* dlt-system: Call tzset before localtime_r (#165)Saya Sugiura2019-09-231-0/+1
| | | | | | Since localtime() was calling tzset() internally, it should be used before localtime_r(). Refer to man page of localtime_r() for detail. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* cmake add component for libdlt.soFelix Herrmann2019-09-131-3/+8
| | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com>
* libdlt: calculate resend buffer memoryBui Nguyen Quoc Thanh2019-09-131-19/+29
| | | | | | | | | | | | | | The fix from commit 376bf6c is considered as a workaround. From now, the resend buffer size is calculated based on (dlt_user.log_buf_len + header_size) - Remove the macro DLT_USER_EXTRA_BUFF_SIZE - Use env_disable_extended_header_for_nonverbose instead of env_nonverbose_extended_header Related commit: 376bf6c Size of Resend buffer less than or equal to DLT_USER_BUF_MAX_SIZE res… (#116) Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* lib: Disable extended header in non verbose mode by env varOnkar Palkar2019-09-132-3/+20
| | | | | | | dlt-test-non-verbose test application is also added. Signed-off-by: Onkar Palkar <onkar.palkar@wipro.com> Signed-off-by: S. Hameed <shameed@jp.adit-jv.com>
* shm: Resend dlt msg when client connectVo Trung Chi2019-09-131-7/+0
| | | | | | | | After dlt-client connects to dlt-daemon successfully, all the stored dlt messages in daemon was not flushed to dlt client when using shared memory as IPC. It is harmonized with dlt_daemon_process_user_message_log(). Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* lib: Remove else nothingSaya Sugiura2019-09-131-2/+0
| | | | | | Remove "else nothing" to correct code behavior. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* network trace: Do not allow DLT usage in forked childVo Trung Chi2019-09-131-0/+4
| | | | | | | dlt_user_trace_network_segmented() shall not be used in forked child process. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* lib: Assign fd after it's closedSaya Sugiura2019-09-131-0/+1
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* Add user custom timestamp interfaceSebastian Unger2019-09-131-1/+8
| | | | | | | | | | | | | Two new macros are introduced so that users can use their customized timestamps for DLT messages: - DLT_LOG_TS(CONTEXT, LOGLEVEL, TS, ARGS ...) - DLT_LOG_ID_TS(CONTEXT, LOGLEVEL, MSGID, TS, ARGS ...) Detailed explanations can be found in dlt_for_developers.md. Also a new option is added to dlt-system to use events' timestamps from journald adapter. Signed-off-by: Sebastian Unger <sunger@de.adit-jv.com>
* libdlt: truncate the log message if it is too long (#156) (#157)Vo Trung Chi2019-09-021-90/+147
| | | | | | | | | | | | Change the behavior of dlt_user_log_write_string, dlt_user_log_write_constant_string and dlt_user_log_write_utf8_string so that they truncate the incoming message if it is too big and add "Message truncated, too long" at the end of it. These function should anyway still return an DLT_RETURN_USER_BUFFER_FULL error in this case. Signed-off-by: Nguyen Dinh Thi (RBVH/ENG2) <Thi.NguyenDinh@vn.bosch.com> Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* using POSIX shared memory APIs (#90) (#151)Vo Trung Chi2019-08-011-16/+6
| | | | | Replace all Linux specific shared memory APIs with POSIX alternatives. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* Correct sa findingsSaya Sugiura2019-07-242-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dlt_offline_logstorage.c - Parameter to isdigit is not correct - Handle the size of memset() and strncpy() properly dlt-test-stress-user.c - Parameter d is duplicated dlt_env_ll.c - Parameter env is used before NULL check - Remove redundant line dlt-control-common.c dlt_daemon_event_handler.c - Do not use NULL variable to print log dlt_config_file_parser.c - Remove unnecessary loop dlt_daemon_client.c - Return error in NULL check dlt_user.c - Free allocated memory in error case Related commit: 5c8f88d logstorage: fix compile error Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Align variable for apid and ctidSaya Sugiura2019-07-191-20/+20
| | | | | | | The variables used for application id and context id are aligned with "apid" and "ctid". Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Remove licenceSaya Sugiura2019-07-197-14/+0
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Get rid of warningsSaya Sugiura2019-07-192-2/+10
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* define DLT_PATH_MAX for max path buffer lengthRadoslaw Kaczorowski2019-07-031-10/+12
| | | | | | | | DLT limits the path length and does not do anything else to determine the actual value, because the least that is supported on any system that DLT runs on is 1024 bytes. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* cmake-improvements (#135)Vo Trung Chi2019-07-031-10/+22
| | | | | | | | | | | | | | | 1. Allow building as a subproject of another cmake project (CMAKE_* vs PROJECT_* variables) 2. Do not generate header files within source – bad practice, use build directory for that(e.g. change location where dlt_version.h is being generated) 3. Use add_compile_options() instead of *_C/CXX_FLAGS variables for proper compile environment definition, also bad practice, also see p.2 4. Add WITH_DLT_PKGCONFIG – add generate pkgconfig .pc files as switchable option, should probably be part of headers install routine. Signed-off-by: Radoslaw Kaczorowski <external.radoslaw.kaczorowski@bosch-softtec.com>
* libdlt: Use posix nanosleep (#144)Phong Tran2019-06-271-2/+9
| | | | | Change to use nanosleep instead of usleep. Signed-off-by: Phong Tran <tranmanphong@gmail.com>