NMEA2000 Library  0.1
Library to handle NMEA 2000 Communication written in C++
Seasmart.cpp File Reference
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "Seasmart.h"
Include dependency graph for Seasmart.cpp:

Go to the source code of this file.

Functions

static int append2Bytes (char *s, uint16_t i)
 
static int appendByte (char *s, uint8_t byte)
 
static int appendWord (char *s, uint32_t i)
 
size_t N2kToSeasmart (const tN2kMsg &msg, uint32_t timestamp, char *buffer, size_t size)
 Converts a tN2kMsg into a $PCDIN NMEA sentence. More...
 
static uint8_t nmea_compute_checksum (const char *sentence)
 
static bool readNHexByte (const char *s, unsigned int n, uint32_t &value)
 
bool SeasmartToN2k (const char *buffer, uint32_t &timestamp, tN2kMsg &msg)
 Converts a null terminated $PCDIN NMEA sentence into a tN2kMsg. More...
 

Variables

static const char * hex = "0123456789ABCDEF"
 

Function Documentation

◆ append2Bytes()

static int append2Bytes ( char *  s,
uint16_t  i 
)
static

Definition at line 39 of file Seasmart.cpp.

◆ appendByte()

static int appendByte ( char *  s,
uint8_t  byte 
)
static

Definition at line 33 of file Seasmart.cpp.

◆ appendWord()

static int appendWord ( char *  s,
uint32_t  i 
)
static

Definition at line 45 of file Seasmart.cpp.

◆ N2kToSeasmart()

size_t N2kToSeasmart ( const tN2kMsg msg,
uint32_t  timestamp,
char *  buffer,
size_t  size 
)

Converts a tN2kMsg into a $PCDIN NMEA sentence.

Converts a tN2kMsg into a $PCDIN NMEA sentence, following the Seasmart specification. The buffer must be at least (30 + 2*msg.DataLen) bytes long.

[Seasmart Protocol Reference] (http://www.seasmart.net/pdf/SeaSmart_HTTP_Protocol_RevG_043012.pdf)

If the buffer is not long enough, this function returns 0 and does not do anything.

If the buffer is long enough, this function returns the number of bytes written including the terminating \0 (but this function does not add the NMEA separator \r\n).

Parameters
msgReference to a N2kMsg Object
timestampTimestamp of the message
bufferchar array buffer for seasmart message
sizesize of the char buffer
Returns
size_t

Definition at line 67 of file Seasmart.cpp.

◆ nmea_compute_checksum()

static uint8_t nmea_compute_checksum ( const char *  sentence)
static

Definition at line 51 of file Seasmart.cpp.

◆ readNHexByte()

static bool readNHexByte ( const char *  s,
unsigned int  n,
uint32_t &  value 
)
static

Definition at line 102 of file Seasmart.cpp.

◆ SeasmartToN2k()

bool SeasmartToN2k ( const char *  buffer,
uint32_t &  timestamp,
tN2kMsg msg 
)

Converts a null terminated $PCDIN NMEA sentence into a tN2kMsg.

Converts a null terminated $PCDIN NMEA sentence into a tN2kMsg and updates timestamp with the timestamp of the sentence.

[Seasmart Protocol Reference] (http://www.seasmart.net/pdf/SeaSmart_HTTP_Protocol_RevG_043012.pdf)

The NMEA \r\n terminator is not required.

Parameters
bufferchar array buffer with seasmart message
timestampTimestamp of the message
msgReference to a N2kMsg Object
Returns
true -> Success
false -> an error occurred

Definition at line 121 of file Seasmart.cpp.

Variable Documentation

◆ hex

const char* hex = "0123456789ABCDEF"
static

Definition at line 31 of file Seasmart.cpp.