Line data Source code
1 : /*
2 : * SPDX license identifier: MPL-2.0
3 : *
4 : * Copyright (C) 2011-2015, BMW AG
5 : *
6 : * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
7 : *
8 : * This Source Code Form is subject to the terms of the
9 : * Mozilla Public License (MPL), v. 2.0.
10 : * If a copy of the MPL was not distributed with this file,
11 : * You can obtain one at http://mozilla.org/MPL/2.0/.
12 : *
13 : * For further information see http://www.covesa.org/.
14 : */
15 :
16 : /*!
17 : * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
18 : *
19 : * \copyright Copyright © 2011-2015 BMW AG. \n
20 : * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
21 : *
22 : * \file dlt_daemon_serial.c
23 : */
24 :
25 : /*******************************************************************************
26 : ** **
27 : ** SRC-MODULE: dlt_daemon_serial.c **
28 : ** **
29 : ** TARGET : linux **
30 : ** **
31 : ** PROJECT : DLT **
32 : ** **
33 : ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
34 : ** **
35 : ** PURPOSE : **
36 : ** **
37 : ** REMARKS : **
38 : ** **
39 : ** PLATFORM DEPENDANT [yes/no]: yes **
40 : ** **
41 : ** TO BE CHANGED BY USER [yes/no]: no **
42 : ** **
43 : *******************************************************************************/
44 :
45 : /*******************************************************************************
46 : ** Author Identity **
47 : ********************************************************************************
48 : ** **
49 : ** Initials Name Company **
50 : ** -------- ------------------------- ---------------------------------- **
51 : ** aw Alexander Wenzel BMW **
52 : *******************************************************************************/
53 :
54 : #include <stdio.h>
55 : #include <stdlib.h>
56 : #include <string.h>
57 : #include <syslog.h>
58 : #include <errno.h>
59 : #include <unistd.h>
60 :
61 : #include <sys/socket.h> /* send() */
62 :
63 : #include "dlt-daemon.h"
64 :
65 : #include "dlt_types.h"
66 :
67 : #include "dlt_daemon_serial.h"
68 :
69 0 : int dlt_daemon_serial_send(int sock, void* data1, int size1, void* data2, int size2, char serialheader)
70 : {
71 : /* Optional: Send serial header, if requested */
72 0 : if (serialheader) {
73 0 : if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader))) {
74 : return DLT_DAEMON_ERROR_SEND_FAILED;
75 : }
76 : }
77 :
78 : /* Send data */
79 :
80 0 : if (data1 && (size1 > 0)) {
81 0 : if (0 > write(sock, data1, (size_t)size1)) {
82 : return DLT_DAEMON_ERROR_SEND_FAILED;
83 : }
84 : }
85 :
86 0 : if (data2 && (size2 > 0)) {
87 0 : if (0 > write(sock, data2, (size_t)size2)) {
88 : return DLT_DAEMON_ERROR_SEND_FAILED;
89 : }
90 : }
91 :
92 : return DLT_DAEMON_ERROR_OK;
93 : }
|