VLCB
Toggle main menu visibility
Loading...
Searching...
No Matches
CanService.h
Go to the documentation of this file.
1
// Copyright (C) Sven Rosvall (sven@rosvall.ie)
2
// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3
// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4
// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0
5
6
#pragma once
7
8
#include "
Service.h
"
9
#include "
CanTransport.h
"
10
#include <
vlcbdefs.hpp
>
11
12
namespace
VLCB
13
{
14
15
struct
VlcbMessage
;
16
28
class
CanService
:
public
Service
29
{
30
31
public
:
34
CanService
(
CanTransport
* tpt) :
canTransport
(tpt) {}
35
37
virtual
VlcbServiceTypes
getServiceID
()
const override
{
return
SERVICE_ID_CAN
; }
38
virtual
byte
getServiceVersionID
()
const override
{
return
2; }
39
virtual
Data
getServiceData
();
40
41
virtual
void
process
()
override
;
42
virtual
void
processAction
(
const
Action
&action)
override
;
43
44
protected
:
45
CanTransport
*
canTransport
;
47
48
private
:
49
void
handleCanServiceMessage(
const
VlcbMessage
*msg);
50
void
handleEnumeration(
unsigned
int
nn);
51
void
handleSetCANID(
const
VlcbMessage
*msg,
unsigned
int
nn);
52
53
bool
sendMessage(
const
VlcbMessage
*msg);
54
bool
sendRtrFrame();
55
bool
sendEmptyFrame(
bool
rtr =
false
);
56
bool
sendCanFrame(
CANFrame
*msg) {
return
canTransport
->
sendCanFrame
(msg); }
57
void
startCANenumeration(
bool
fromENUM =
false
);
58
59
void
checkIncomingCanFrame();
60
void
checkCANenumTimout();
61
byte
findFreeCanId();
62
63
bool
enumeration_required =
false
;
64
bool
bCANenum =
false
;
65
bool
startedFromEnumMessage =
false
;
66
unsigned
long
CANenumTime;
67
byte
enum_responses[16];
// 128 bits for storing CAN ID enumeration results
68
};
69
70
}
CanTransport.h
Service.h
VLCB::CanService::getServiceVersionID
virtual byte getServiceVersionID() const override
Return the version of the service specification implemented by this service.
Definition
CanService.h:38
VLCB::CanService::CanService
CanService(CanTransport *tpt)
Definition
CanService.h:34
VLCB::CanService::processAction
virtual void processAction(const Action &action) override
Called when there is an action available.
Definition
CanService.cpp:36
VLCB::CanService::canTransport
CanTransport * canTransport
Definition
CanService.h:45
VLCB::CanService::getServiceID
virtual VlcbServiceTypes getServiceID() const override
Return a unique ID for this service.
Definition
CanService.h:37
VLCB::CanService::getServiceData
virtual Data getServiceData()
Return Data bytes specific for the implementing service. The meaning of each data byte is defined in ...
Definition
CanService.cpp:16
VLCB::CanTransport
Interface base class for CAN transport implementations.
Definition
CanTransport.h:35
VLCB::CanTransport::sendCanFrame
virtual bool sendCanFrame(CANFrame *msg)=0
Send a CAN frame to the CAN bus.
VLCB::Service
Interface base class for all VLCB services.
Definition
Service.h:25
VLCB
Definition
AbstractEventTeachingService.cpp:13
VLCB::process
void process()
Definition
VLCB.cpp:192
VLCB::Action
An action to be performed.
Definition
Controller.h:86
VLCB::CANFrame
Represents a CAN frame sent on the CAN bus.
Definition
CanTransport.h:21
VLCB::VlcbMessage
VLCB message type.
Definition
Controller.h:38
vlcbdefs.hpp
VlcbServiceTypes
VlcbServiceTypes
Definition
vlcbdefs.hpp:487
SERVICE_ID_CAN
@ SERVICE_ID_CAN
Definition
vlcbdefs.hpp:494
src
CanService.h
Generated by
1.18.0