/
can_layer.h
75 lines (63 loc) · 1.94 KB
/
can_layer.h
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
#ifndef VITROIO_SDK_CAN_LAYER
#define VITROIO_SDK_CAN_LAYER
#include <mbed.h>
#include "transport_layer.h"
#include <vitroio-sdk/communication/canbus.h>
namespace vitroio {
namespace sdk {
/**
* @addtogroup communication
* @{
*/
/**
* @brief This class implements CAN bus transport layer for IoT Blockss
*
*/
class Can_layer: public Transport_layer {
Canbus *bus_;
uint32_t timestamp_;
/**
* @brief Callback on frame receive
*
* @param frame Received frame
*/
void frameReceivedCallback(const CanbusFrame& frame);
public:
/**
* @brief Construct a new Can_layer object
*
* @param bus Pointer to Canbus object
* @param nodeId nodeId value
*/
Can_layer(Canbus *bus, uint32_t nodeId);
/**
* @brief Function sends given data
*
* @param parameterId Id of parameter sent
* @param iov Pointer to first IoVec with data to be sent @ref IoVec
* @param iovcnt Count of IoVects to read
* @return int Status of sending
*/
int send(uint32_t parameterId, const IoVec* iov, int iovcnt);
/**
* @brief Function sends timestamp request and returns timestamp value
*
* @return uint32_t Received timestamp
*/
uint32_t getTimestamp();
/**
* @brief Function computes CRC of data send via CAN bus to Crystal
*
* @param iov Chunks of data
* @param iovcnt Count of chunks
* @param crc_value Pointer to save CRC
* @return int Status
*/
int computeCRC(const IoVec *iov, int iovcnt, uint32_t *crc_value);
};
/**
* @}
*/
}
}
#endif // VITROIO_SDK_CAN_LAYER