NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
ActisenseReader.h
Go to the documentation of this file.
1/*
2 * ActisenseReader.h
3 *
4 * Copyright (c) 2015-2024 Timo Lappalainen, Kave Oy, www.kave.fi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22*/
23
24/**************************************************************************/
37#ifndef _ACTISENSE_READER_H_
38#define _ACTISENSE_READER_H_
39
40#include "N2kMsg.h"
41#include "N2kStream.h"
42
43/************************************************************************/
58{
59protected:
61 #define MAX_STREAM_MSG_BUF_LEN 300
75 unsigned char DefaultSource;
76
77protected:
80 // Handler callback
81 void (*MsgHandler)(const tN2kMsg &N2kMsg);
82
83protected:
84 /********************************************************************/
91 bool AddByteToBuffer(char NewByte);
92 /********************************************************************/
95 void ClearBuffer();
96
97 /********************************************************************/
104 bool CheckMessage(tN2kMsg &N2kMsg);
105
106public:
107
108 /********************************************************************/
113
114 /********************************************************************/
123 void SetReadStream(N2kStream* _stream) { ReadStream=_stream; }
124
125 /********************************************************************/
134 void SetDefaultSource(unsigned char source) { DefaultSource=source; }
135
136 /********************************************************************/
153 bool GetMessageFromStream(tN2kMsg &N2kMsg, bool ReadOut=true);
154
155 /********* **********************************************************/
164 bool IsStart(char ch);
165
166 /********************************************************************/
176 void ParseMessages();
177
178 /********************************************************************/
186 void SetMsgHandler(void (*_MsgHandler)(const tN2kMsg &N2kMsg)) { MsgHandler=_MsgHandler; }
187
197};
198
199#endif
#define MAX_STREAM_MSG_BUF_LEN
Maximum length of the stream message buffer.
This File contains the class tN2kMsg and all necessary functions to handle a NMEA2000 Message.
This File contains an I/O stream used in the NMEA2000 libraries.
Streaming Class to handle all Streams generated by the Library.
Definition: N2kStream.h:60
Class for reading Actisense format messages.
bool EscapeReceived
Escape character has been received.
bool Handling() const
Indicates if still message handling is needed.
void SetDefaultSource(unsigned char source)
Set the default source address for the messages.
bool GetMessageFromStream(tN2kMsg &N2kMsg, bool ReadOut=true)
Read Actisense formatted NMEA2000 message from stream.
tActisenseReader()
Constructor for the class Initialize all class attributes and clear the buffer.
void SetReadStream(N2kStream *_stream)
Set the Read Stream object.
void SetMsgHandler(void(*_MsgHandler)(const tN2kMsg &N2kMsg))
Set the Msg Handler object.
int byteSum
Sum of all bytes is used as kind of check sum.
bool IsStart(char ch)
Checks if character is start of Actisense format.
void ParseMessages()
Parse messages from stream.
unsigned char DefaultSource
Default source of the N2k message.
bool AddByteToBuffer(char NewByte)
Adds a new Byte to the buffer.
void ClearBuffer()
Clears the buffer.
unsigned char MsgBuf[MAX_STREAM_MSG_BUF_LEN]
Buffer for incoming messages from stream.
int MsgWritePos
Current write position inside the buffer.
bool CheckMessage(tN2kMsg &N2kMsg)
Checks is Actisense message read from stream valid and builds tN2kMsg message from it.
bool MsgIsComing
A Message is coming.
bool StartOfTextReceived
Start of text has been received.
void(* MsgHandler)(const tN2kMsg &N2kMsg)
N2kStream * ReadStream
Stream to read from.
This class contains all the data of an NMEA2000 message.
Definition: N2kMsg.h:656