[libamb] - added value quality, removed deprecated GetFoo call, made updateFrequency...
[profile/ivi/automotive-message-broker.git] / plugins / common / canframeinfo.h
1 /*
2 Copyright (C) 2015 Cogent Embedded Inc.
3 Copyright (C) 2015 Renesas Electronics Corporation
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20 #ifndef CANFRAMEINFO_H
21 #define CANFRAMEINFO_H
22
23 /**
24  *  \addtogroup libcanbus
25  *  @{
26  */
27
28 #include <stdlib.h>
29 #include <linux/can.h>
30
31 #include "timestamp.h"
32
33 /**
34  * CAN frame with additional information
35  */
36 struct CANFrameInfo
37 {
38     CANFrameInfo(const can_frame &frame)
39     {
40         this->status = CANFrameInfo::CANMessageStatus::GOOD;
41         this->frame = frame;
42         this->timestamp = amb::currentTime();
43     }
44
45     CANFrameInfo() { }
46
47     enum CANMessageStatus {
48         TIMEOUT = -2,
49         EMPTY = 0,
50         GOOD = 1,
51     };
52
53     /**
54      * The actual frame written or read from socket
55      */
56     struct can_frame frame;
57
58     /**
59      * Status of the message.
60      */
61     CANFrameInfo::CANMessageStatus status;
62
63     /**
64      * Timestamp of sending or receiving action
65      */
66     double timestamp;
67 };
68
69 #endif // CANFRAMEINFO_H
70
71 /** @} */
72