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,
70 : void *data1,
71 : int size1,
72 : void *data2,
73 : int size2,
74 : char serialheader)
75 : {
76 : /* Optional: Send serial header, if requested */
77 0 : if (serialheader) {
78 0 : if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader))) {
79 : return DLT_DAEMON_ERROR_SEND_FAILED;
80 : }
81 : }
82 :
83 : /* Send data */
84 :
85 0 : if (data1 && (size1 > 0)) {
86 0 : if (0 > write(sock, data1, size1)) {
87 : return DLT_DAEMON_ERROR_SEND_FAILED;
88 : }
89 : }
90 :
91 0 : if (data2 && (size2 > 0)) {
92 0 : if (0 > write(sock, data2, size2)) {
93 : return DLT_DAEMON_ERROR_SEND_FAILED;
94 : }
95 : }
96 :
97 : return DLT_DAEMON_ERROR_OK;
98 : }
|