This file implements the base interface for all Serial and Ethernet ports. More...
#include <sbgCommon.h>
Go to the source code of this file.
Classes | |
struct | _SbgInterface |
Typedefs | |
typedef struct _SbgInterface | SbgInterface |
typedef void * | SbgInterfaceHandle |
typedef bool(* | SbgInterfaceIsValidFunc) (SbgInterface *pHandle) |
typedef SbgErrorCode(* | SbgInterfaceReadFunc) (SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead) |
typedef enum _SbgInterfaceType | SbgInterfaceType |
typedef SbgErrorCode(* | SbgInterfaceWriteFunc) (SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite) |
Enumerations | |
enum | _SbgInterfaceType { SBG_IF_TYPE_UNKNOW, SBG_IF_TYPE_SERIAL, SBG_IF_TYPE_ETH_UDP, SBG_IF_TYPE_ETH_TCP_IP, SBG_IF_TYPE_FILE } |
Functions | |
SBG_INLINE bool | sbgInterfaceIsValid (SbgInterface *pHandle) |
SBG_INLINE SbgErrorCode | sbgInterfaceRead (SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead) |
SBG_INLINE SbgErrorCode | sbgInterfaceWrite (SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite) |
SBG_INLINE void | sbgInterfaceZeroInit (SbgInterface *pHandle) |
This file implements the base interface for all Serial and Ethernet ports.
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 (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.
typedef struct _SbgInterface SbgInterface |
Interface structure pre-definition.
Definition at line 59 of file sbgInterface.h.
typedef void* SbgInterfaceHandle |
Handle that stores the internal interface handle (ie Serial or Ethernet)
Definition at line 64 of file sbgInterface.h.
typedef bool(* SbgInterfaceIsValidFunc) (SbgInterface *pHandle) |
Returns true if the interface is working correctly.
[in] | pHandle | Valid handle on an initialized interface. |
Definition at line 94 of file sbgInterface.h.
typedef SbgErrorCode(* SbgInterfaceReadFunc) (SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead) |
Try to read some data from an interface.
[in] | pHandle | Valid handle on an initialized interface. |
[in] | pBuffer | Pointer on an allocated buffer that can hold at least bytesToRead bytes of data. |
[out] | pReadBytes | Pointer on an uint32 used to return the number of read bytes. |
[in] | bytesToRead | Number of bytes we would like to read. |
Definition at line 87 of file sbgInterface.h.
typedef enum _SbgInterfaceType SbgInterfaceType |
Define the interface type.
typedef SbgErrorCode(* SbgInterfaceWriteFunc) (SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite) |
Try to write some data to an interface.
[in] | pHandle | Valid handle on an initialized interface. |
[in] | pBuffer | Pointer on an allocated buffer that contains the data to write |
[in] | bytesToWrite | Number of bytes we would like to write. |
Definition at line 77 of file sbgInterface.h.
enum _SbgInterfaceType |
Define the interface type.
Definition at line 43 of file sbgInterface.h.
SBG_INLINE bool sbgInterfaceIsValid | ( | SbgInterface * | pHandle | ) |
Returns true if this interface seems to be up and running.
[in] | pHandle | Handle on an interface to test (if pHandle == NULL, retruns false). |
Definition at line 143 of file sbgInterface.h.
SBG_INLINE SbgErrorCode sbgInterfaceRead | ( | SbgInterface * | pHandle, |
void * | pBuffer, | ||
size_t * | pReadBytes, | ||
size_t | bytesToRead | ||
) |
Try to read some data from an interface.
[in] | pHandle | Valid handle on an initialized interface. |
[in] | pBuffer | Pointer on an allocated buffer that can hold at least bytesToRead bytes of data. |
[out] | pReadBytes | Pointer on an uint32 used to return the number of read bytes. |
[in] | bytesToRead | Number of bytes we would like to read. |
Definition at line 212 of file sbgInterface.h.
SBG_INLINE SbgErrorCode sbgInterfaceWrite | ( | SbgInterface * | pHandle, |
const void * | pBuffer, | ||
size_t | bytesToWrite | ||
) |
Try to write some data to an interface.
[in] | pHandle | Valid handle on an initialized interface. |
[in] | pBuffer | Pointer on an allocated buffer that contains the data to write |
[in] | bytesToWrite | Number of bytes we would like to write. |
Definition at line 190 of file sbgInterface.h.
SBG_INLINE void sbgInterfaceZeroInit | ( | SbgInterface * | pHandle | ) |
Initialize an interface strcture to zero.
[in] | pHandle | Handle on an allocated interface to initialize to zero. |
Definition at line 121 of file sbgInterface.h.