SELKIELogger  1.0.0
N2KConnection.h File Reference
#include <stdbool.h>
#include "N2KTypes.h"
#include "SELKIELoggerBase.h"
Include dependency graph for N2KConnection.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define N2K_BUFF   1024
 Default serial buffer allocation size.
 

Functions

int n2k_openConnection (const char *device, const int baud)
 Open connection to an N2K serial device. More...
 
void n2k_closeConnection (int handle)
 Close N2K serial connection. More...
 
bool n2k_act_readMessage (int handle, n2k_act_message *out)
 Static wrapper around n2k_readMessage_buf. More...
 
bool n2k_act_readMessage_buf (int handle, n2k_act_message *out, uint8_t buf[N2K_BUFF], size_t *index, size_t *hw)
 Read data from handle, and parse message if able. More...
 

Detailed Description

N2K connection handling

Definition in file N2KConnection.h.

Function Documentation

◆ n2k_act_readMessage()

bool n2k_act_readMessage ( int  handle,
n2k_act_message out 
)

Static wrapper around n2k_readMessage_buf.

For single threaded development and testing, uses static variables rather than requiring state to be tracked by caller.

See n2k_act_readMessage_buf() for full description.

Parameters
[in]handleFile descriptor from n2k_openConnection()
[out]outPointer to message structure to fill with data
Returns
True if out now contains a valid message, false otherwise.

Definition at line 61 of file N2KConnection.c.

◆ n2k_act_readMessage_buf()

bool n2k_act_readMessage_buf ( int  handle,
n2k_act_message out,
uint8_t  buf[N2K_BUFF],
size_t *  index,
size_t *  hw 
)

Read data from handle, and parse message if able.

Pulls data from handle and stores it in buf, tracking the current search position in index and the current fill level/buffer high water mark in hw

If a valid message is found then it is written to the structure provided as a parameter and the function returns true.

If a message cannot be read, the function returns false

Parameters
[in]handleFile descriptor from n2k_openConnection()
[out]outPointer to message structure to fill with data
[in,out]bufSerial data buffer
[in,out]indexCurrent search position within buf
[in,out]hwEnd of current valid data in buf
Returns
True if out now contains a valid message, false otherwise.

Definition at line 85 of file N2KConnection.c.

◆ n2k_closeConnection()

void n2k_closeConnection ( int  handle)

Close N2K serial connection.

Parameters
[in]handleFile handle from n2k_openConnection()

Definition at line 46 of file N2KConnection.c.

◆ n2k_openConnection()

int n2k_openConnection ( const char *  device,
const int  baud 
)

Open connection to an N2K serial device.

Delegates to openSerialConnection() to open the serial device.

Parameters
[in]devicePath to device to open
[in]baudBaud rate to connect with (as integer)
Returns
Status of openSerialConnection() call

Definition at line 38 of file N2KConnection.c.