Classes | Macros | Typedefs | Functions
sbgInterface.h File Reference

This file implements the base interface for all Serial and Ethernet ports. More...

#include <sbgCommon.h>
Include dependency graph for sbgInterface.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SbgInterface
 

Macros

#define SBG_IF_NAME_MAX_SIZE   (48)
 
#define SBG_IF_TYPE_ETH_TCP_IP   (3)
 
#define SBG_IF_TYPE_ETH_UDP   (2)
 
#define SBG_IF_TYPE_FILE   (4)
 
#define SBG_IF_TYPE_LAST_RESERVED   (999)
 
#define SBG_IF_TYPE_SERIAL   (1)
 
#define SBG_IF_TYPE_UNKNOW   (0)
 

Typedefs

typedef struct _SbgInterface SbgInterface
 
typedef SbgErrorCode(* SbgInterfaceFlushFunc) (SbgInterface *pHandle)
 
typedef uint32_t(* SbgInterfaceGetDelayFunc) (SbgInterface *pHandle, size_t numBytes)
 
typedef void * SbgInterfaceHandle
 
typedef SbgErrorCode(* SbgInterfaceReadFunc) (SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead)
 
typedef SbgErrorCode(* SbgInterfaceWriteFunc) (SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite)
 

Functions

SBG_INLINE SbgErrorCode sbgInterfaceFlush (SbgInterface *pHandle)
 
SBG_INLINE uint32_t sbgInterfaceGetDelay (SbgInterface *pHandle, size_t numBytes)
 
SBG_INLINE const char * sbgInterfaceNameGet (const SbgInterface *pInterface)
 
SBG_COMMON_LIB_API void sbgInterfaceNameSet (SbgInterface *pInterface, const char *pName)
 
SBG_INLINE SbgErrorCode sbgInterfaceRead (SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead)
 
SBG_INLINE uint32_t sbgInterfaceTypeGet (const SbgInterface *pInterface)
 
SBG_COMMON_LIB_API const char * sbgInterfaceTypeGetAsString (const SbgInterface *pInterface)
 
SBG_INLINE SbgErrorCode sbgInterfaceWrite (SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite)
 
SBG_COMMON_LIB_API void sbgInterfaceZeroInit (SbgInterface *pHandle)
 

Detailed Description

This file implements the base interface for all Serial and Ethernet ports.

Author
SBG Systems (Raphael Siryani)
Date
10 December 2012

An interface is used to provide a common API for both serial and ethernet ports. An interface can be opened/closed and some data can be written or read from it.

Copyright Notice

Copyright (C) 2007-2013, SBG Systems SAS. All rights reserved.

This source code is intended for use only by SBG Systems SAS and those that have explicit written permission to use it from SBG Systems SAS.

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

Definition in file sbgInterface.h.

Macro Definition Documentation

◆ SBG_IF_NAME_MAX_SIZE

#define SBG_IF_NAME_MAX_SIZE   (48)

Maximum size in bytes for the interface name string

Definition at line 41 of file sbgInterface.h.

◆ SBG_IF_TYPE_ETH_TCP_IP

#define SBG_IF_TYPE_ETH_TCP_IP   (3)

The interface is an TCP/IP one.

Definition at line 49 of file sbgInterface.h.

◆ SBG_IF_TYPE_ETH_UDP

#define SBG_IF_TYPE_ETH_UDP   (2)

The interface is an UDP one.

Definition at line 48 of file sbgInterface.h.

◆ SBG_IF_TYPE_FILE

#define SBG_IF_TYPE_FILE   (4)

The interface is a file.

Definition at line 50 of file sbgInterface.h.

◆ SBG_IF_TYPE_LAST_RESERVED

#define SBG_IF_TYPE_LAST_RESERVED   (999)

Last reserved value for standard types.

Definition at line 51 of file sbgInterface.h.

◆ SBG_IF_TYPE_SERIAL

#define SBG_IF_TYPE_SERIAL   (1)

The interface is a serial com port.

Definition at line 47 of file sbgInterface.h.

◆ SBG_IF_TYPE_UNKNOW

#define SBG_IF_TYPE_UNKNOW   (0)

Type values reserved for standard interface types.The interface type is not defined.

Definition at line 46 of file sbgInterface.h.

Typedef Documentation

◆ SbgInterface

typedef struct _SbgInterface SbgInterface

Interface structure pre-definition.

Definition at line 60 of file sbgInterface.h.

◆ SbgInterfaceFlushFunc

typedef SbgErrorCode(* SbgInterfaceFlushFunc) (SbgInterface *pHandle)

Make an interface flush all pending input or output data.

Parameters
[in]pHandleValid handle on an initialized interface.
Returns
SBG_NO_ERROR if successful.

Definition at line 104 of file sbgInterface.h.

◆ SbgInterfaceGetDelayFunc

typedef uint32_t(* SbgInterfaceGetDelayFunc) (SbgInterface *pHandle, size_t numBytes)

Compute and return the delay needed by the interface to transmit / receive X number of bytes.

This method isn't applicable to all interfaces and as such should return a default delay of zero.

Parameters
[in]pHandleValid handle on an initialized interface.
[in]numBytesThe number of bytes to transmit / receive to evaluate the needed delay.
Returns
The expected delay in us needed to transmit / receive the specified number of bytes or 0 if not applicable.

Definition at line 115 of file sbgInterface.h.

◆ SbgInterfaceHandle

typedef void* SbgInterfaceHandle

Handle that stores the internal interface handle (ie Serial or Ethernet)

Definition at line 65 of file sbgInterface.h.

◆ SbgInterfaceReadFunc

typedef SbgErrorCode(* SbgInterfaceReadFunc) (SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead)

Method to implement to read data from an interface.

This method returns an error only if there is a 'low level' error on the interface. If no byte is read at all or less bytes than bytesToRead, this method returns SBG_NO_ERROR. You have to check pReadBytes field to know the number of bytes actually read.

Parameters
[in]pHandleValid handle on an initialized interface.
[in]pBufferPointer on an allocated buffer that can hold at least bytesToRead bytes of data.
[out]pReadBytesReturns the number of bytes actually read (can be zero and up to bytesToRead).
[in]bytesToReadMaximum number of bytes to try to read on the interface.
Returns
SBG_NO_ERROR if zero or some bytes have been read successfully.

Definition at line 97 of file sbgInterface.h.

◆ SbgInterfaceWriteFunc

typedef SbgErrorCode(* SbgInterfaceWriteFunc) (SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite)

Method to implement to write a buffer to an interface.

This method should return an error only if all bytes were not written successfully. If you try to write zero byte, the method shouldn't return any error.

Parameters
[in]pHandleValid handle on an initialized interface.
[in]pBufferPointer on an allocated buffer that contains the data to write
[in]bytesToWriteNumber of bytes we would like to write (can be zero).
Returns
SBG_NO_ERROR if exactly bytesToWrite have been written successfully.

Definition at line 82 of file sbgInterface.h.

Function Documentation

◆ sbgInterfaceFlush()

SBG_INLINE SbgErrorCode sbgInterfaceFlush ( SbgInterface pHandle)

Make an interface flush all pending input or output data.

This method isn't applicable to all interfaces and as such if no implementation is provided it does nothing.

Parameters
[in]pHandleValid handle on an initialized interface.
Returns
SBG_NO_ERROR if successful.

Definition at line 211 of file sbgInterface.h.

◆ sbgInterfaceGetDelay()

SBG_INLINE uint32_t sbgInterfaceGetDelay ( SbgInterface pHandle,
size_t  numBytes 
)

Compute and return the delay needed by the interface to transmit / receive X number of bytes.

This method isn't applicable to all interfaces and as such if no implementation is provided a default delay of zero.

Parameters
[in]pHandleValid handle on an initialized interface.
[in]numBytesThe number of bytes to transmit / receive to evaluate the needed delay.
Returns
The expected delay in us needed to transmit / receive the specified number of bytes or 0 if not applicable.

Definition at line 244 of file sbgInterface.h.

◆ sbgInterfaceNameGet()

SBG_INLINE const char* sbgInterfaceNameGet ( const SbgInterface pInterface)

Returns the interface name string.

Parameters
[in]pInterfaceInterface instance
Returns
The interface name as a NULL terminated C string.

Definition at line 289 of file sbgInterface.h.

◆ sbgInterfaceNameSet()

SBG_COMMON_LIB_API void sbgInterfaceNameSet ( SbgInterface pInterface,
const char *  pName 
)

Define the interface name as a NULL terminated C string.

This method make sure that the provided string will always fit within the allocated name buffer.

If the interface name you would like to set is too long, only the end of the string will be kept.

Parameters
[in]pInterfaceInterface instance
[in]pNameThe interface name to set as a NULL terminated C string

Definition at line 61 of file sbgInterface.c.

◆ sbgInterfaceRead()

SBG_INLINE SbgErrorCode sbgInterfaceRead ( SbgInterface pHandle,
void *  pBuffer,
size_t *  pReadBytes,
size_t  bytesToRead 
)

Try to read some data from an interface.

This method returns an error only if there is a 'low level' error on the interface. If no byte is read at all or less bytes than bytesToRead, this method returns SBG_NO_ERROR. You have to check pReadBytes field to know the number of bytes actually read.

Parameters
[in]pHandleValid handle on an initialized interface.
[in]pBufferPointer on an allocated buffer that can hold at least bytesToRead bytes of data.
[out]pReadBytesReturns the number of bytes actually read (can be zero and up to bytesToRead).
[in]bytesToReadMaximum number of bytes to try to read on the interface.
Returns
SBG_NO_ERROR if zero or some bytes have been read successfully.

Definition at line 190 of file sbgInterface.h.

◆ sbgInterfaceTypeGet()

SBG_INLINE uint32_t sbgInterfaceTypeGet ( const SbgInterface pInterface)

Returns the interface type.

Parameters
[in]pInterfaceInterface instance
Returns
The interface type.

Definition at line 268 of file sbgInterface.h.

◆ sbgInterfaceTypeGetAsString()

SBG_COMMON_LIB_API const char* sbgInterfaceTypeGetAsString ( const SbgInterface pInterface)

Returns the interface as string.

Parameters
[in]pInterfaceInterface instance
Returns
The interface type.

Definition at line 46 of file sbgInterface.c.

◆ sbgInterfaceWrite()

SBG_INLINE SbgErrorCode sbgInterfaceWrite ( SbgInterface pHandle,
const void *  pBuffer,
size_t  bytesToWrite 
)

Write some data to an interface.

This method should return an error only if all bytes were not written successfully. If you try to write zero byte, the method shouldn't return any error.

Parameters
[in]pHandleValid handle on an initialized interface.
[in]pBufferPointer on an allocated buffer that contains the data to write
[in]bytesToWriteNumber of bytes we would like to write (can be zero).
Returns
SBG_NO_ERROR if exactly bytesToWrite have been written successfully.

Definition at line 165 of file sbgInterface.h.

◆ sbgInterfaceZeroInit()

SBG_COMMON_LIB_API void sbgInterfaceZeroInit ( SbgInterface pHandle)

Initialize an interface instance to zero.

Parameters
[in]pHandleHandle on an allocated interface to initialize to zero.

Definition at line 24 of file sbgInterface.c.



sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:36