blob: a0c9e48c2eade84a33d473e1c4bd2b4008d0db0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/*!
* \file plugin_api.h
*
* \author S. Eisenhauer
*
* \date 31.08.2011
*
* \brief Interface of a plugin used by \ref CPluginExecutor
*
* This file defines the interface which must be provided by a plugin to \ref CPluginExecutor
*
*/
#ifndef PLUGIN_API_H_
#define PLUGIN_API_H_
#include "global.h"
/*!
* \brief Definition of a message to be sent on the CAN bus
*/
struct tstCanTxMessage
{
uint32_t u32TxCycleMilliseconds; //!< Interval for sending cyclic message in milliseconds
uint32_t u32MillisecondCounter; //!< Incremented every millisecond, resetted to zero when message is sent
uint32_t u32CanId; //!< CAN ID of the message
uint8_t au8Data[8]; //!< data content of the message
uint8_t u8Dlc; //!< Data Length Code of the message: bytes of au8Data used by the message
};
/*!
* \brief Type for pointer to a tstCanTxMessage
*/
typedef tstCanTxMessage* tpstCanTxMessage;
/*!
* \brief Pure virtual interface of a plugin.
*
* Must be implemented by concrete plugin
*/
class IPlugin
{
public:
/*!
* executed every millisecond
* \warning Keep this method implementation short. It is executed with Real-Time priority.
*/
virtual void vRun( void ) = 0;
/*!
* Get a message to be send on CAN bus from plugin
* \param[in] u32MsgIndex Index of the message. Call u32GetNumOfCanTxMessages before to get the number of available messages
* \return Pointer to the message
*/
virtual tpstCanTxMessage pxGetCanTxMessage( const uint32_t u32MsgIndex ) = 0;
/*!
* Get the number of CAN TX messages defined in the plugin
* \return the number of messages
*/
virtual uint32_t u32GetNumOfCanTxMessages( void ) = 0;
/*!
* Get the number of the used CAN interface
* \return the number of the used CAN interface
*/
virtual int32_t i32GetCanInterfaceHandle( void ) = 0;
/*!
* Should this plugin be automatically loaded when CPluginExecutor starts up
* \return TRUE is the plugin should be autoloaded, FALSE otherwise
*/
virtual bool boAutoload( void ) = 0;
/*!
* Is this plugin the instance of the Log Plugin
* \return TRUE if it is the log plugin, FALSE otherwise
*/
virtual bool boIsLogger( void ) = 0;
/*!
* get a log file
* \param[in] pcRequest pointer to a memory buffer containing the filename of the request
* \param[out] pcResponse pointer to a memory buffer where the filename will be stored
* \return status
*/
virtual tenRetCodes enGetLog(const char* pcRequest, char* pcResponse) = 0;
/*!
* initialize the plugin
*
* \param[in] pvExecutor Pointer to target main application
* \param[in] pvIfMan Pointer to an interface manager object
* \param[in] i32Interface Number of the interface ti be used by the plugin
* \param[in] u32PluginId ID of the Plugin
*/
virtual void vInit(void* pvExecutor, void* pvIfMan, int32_t i32Interface, uint32_t u32PluginId) = 0;
/*!
* Add a message to the log
*
* \param[in] stLogMessage the message to log
*/
virtual void vLogMessage(const tstLogMessage& stLogMessage) = 0;
};
extern "C"
{
/*!
* \brief type for factory function
* \param[in] pvExecutor Pointer to target main application
* \param[in] pvIfMan Pointer to an interface manager object
* \param[in] i32Interface Number of the interface to be used by the plugin
* \param[in] u32PluginId ID of the Plugin
* \return Pointer to the Plugin object
*/
typedef IPlugin* tfctCreatePlugin(
void* pvExecutor,
void* pvIfMan,
int32_t i32Interface,
uint32_t u32PluginId
);
/*!
* \brief type for factory function pointer
*/
typedef tfctCreatePlugin *tpfctCreatePlugin;
/*!
* \brief type for deinitialization function
*
* \param[in] pxPlugin Pointer to the plugin to be deinitialized
*/
typedef void tfctDestroyPlugin(IPlugin* pxPlugin);
/*!
* \brief type for deinitialization function pointer
*
* \param[in] pxPlugin Pointer to the plugin to be deinitialized
*/
typedef tfctDestroyPlugin *tpfctDestroyPlugin;
/*!
* C interface for the factory
*/
tfctCreatePlugin pxCreatePlugin;
/*!
* C interface for the deinitialization
*/
tfctDestroyPlugin vDestroyPlugin;
}
#endif /* PLUGIN_API_H_ */
|