-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCANPeak.h
48 lines (46 loc) · 1.36 KB
/
CANPeak.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
#pragma once
#ifndef __CANBase_Peak_H
#define __CANBase_Peak_H
#include "CANBase.h"
#ifdef __APPLE__
#include <PCBUSB.h>
#else
#include <PCANBasic.h>
#endif
#include <thread>
namespace ZCANBus {
class CANPeak : public CANBase {
private:
std::thread* th;
TPCANHandle channel;
bool loopOn;
public:
CANPeak();
~CANPeak();
/**
* @param channel
* @param type Indicates HwType
* @see <PCANBasic.h> CAN_Initialize
*/
CANStatus OpenChannel(int channel, CANRate baudRate, int type = 0) override;
/**
* @param channel
* @param argv Indicates HwType, IOPort, Interrupt in CAN_Initialize.
* Default 0.
* @see <PCANBasic.h> CAN_Initialize
*/
CANStatus OpenChannel(int channel, CANRate baudRate, int argc,
void* argv[]) override;
void ReadLoop(
std::function<void(const CANMessage* msg, CANStatus status)> callback,
uint64_t interval) override;
void EndReadLoop() override;
CANStatus ReadOnce(CANMessage& msg, uint64_t timeout) override;
CANStatus Write(const CANMessage& msg) override;
CANStatus Write(CANMessage* msg, int count) override;
CANStatus CloseChannel() override;
CANStatus FlushQueue() override;
std::string GetErrorText(CANStatus& status) override;
};
} // namespace ZCANBus
#endif