- moved lib_memory to hal project

pull/72/head
Michael Zillgith 7 years ago
parent 7d890b7450
commit de04f3630b

@ -42,7 +42,7 @@ option(CONFIG_IEC61850_REPORT_SERVICE "Build with support for IEC 61850 reportin
option(CONFIG_IEC61850_LOG_SERVICE "Build with support for IEC 61850 logging services" ON)
option(CONFIG_IEC61850_SETTING_GROUPS "Build with support for IEC 61850 setting group services" ON)
set(CONFIG_REPORTING_DEFAULT_REPORT_BUFFER_SIZE "8000" CACHE STRING "Default buffer size for buffered reports in byte" )
set(CONFIG_REPORTING_DEFAULT_REPORT_BUFFER_SIZE "65536" CACHE STRING "Default buffer size for buffered reports in byte" )
# advanced options
option(DEBUG "Enable debugging mode (include assertions)" OFF)
@ -60,22 +60,6 @@ option(DEBUG_SV_SUBSCRIBER "Enable Sampled Values subscriber debugging" ${DEBUG}
option(DEBUG_SV_PUBLISHER "Enable Sampled Values publisher debugging" ${DEBUG})
option(DEBUG_HAL_ETHERNET "Enable Ethernet HAL printf debugging" ${DEBUG})
#mark_as_advanced(
# DEBUG_SOCKET
# DEBUG_COTP
# DEBUG_ISO_SERVER
# DEBUG_ISO_CLIENT
# DEBUG_IED_SERVER
# DEBUG_IED_CLIENT
# DEBUG_MMS_SERVER
# DEBUG_MMS_CLIENT
# DEBUG_GOOSE_SUBSCRIBER
# DEBUG_GOOSE_PUBLISHER
# DEBUG_SV_SUBSCRIBER
# DEBUG_SV_PUBLISHER
# DEBUG_HAL_ETHERNET
#)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/config
${CMAKE_CURRENT_LIST_DIR}/src/common/inc
@ -161,7 +145,12 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/config/stack_config.h
)
include("${CMAKE_CURRENT_LIST_DIR}/hal/CMakeLists.txt")
#include("${CMAKE_CURRENT_LIST_DIR}/hal/CMakeLists.txt")
include_directories(
${CMAKE_CURRENT_LIST_DIR}/hal/inc
)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/hal")
if(BUILD_EXAMPLES)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/examples)

@ -24,6 +24,7 @@ set (libhal_linux_SRCS
${CMAKE_CURRENT_LIST_DIR}/filesystem/linux/file_provider_linux.c
${CMAKE_CURRENT_LIST_DIR}/time/unix/time.c
${CMAKE_CURRENT_LIST_DIR}/serial/linux/serial_port_linux.c
${CMAKE_CURRENT_LIST_DIR}/memory/lib_memory.c
)
set (libhal_windows_SRCS
@ -33,6 +34,7 @@ set (libhal_windows_SRCS
${CMAKE_CURRENT_LIST_DIR}/filesystem/win32/file_provider_win32.c
${CMAKE_CURRENT_LIST_DIR}/time/win32/time.c
${CMAKE_CURRENT_LIST_DIR}/serial/win32/serial_port_win32.c
${CMAKE_CURRENT_LIST_DIR}/memory/lib_memory.c
)
set (libhal_bsd_SRCS
@ -41,6 +43,7 @@ set (libhal_bsd_SRCS
${CMAKE_CURRENT_LIST_DIR}/thread/bsd/thread_bsd.c
${CMAKE_CURRENT_LIST_DIR}/filesystem/linux/file_provider_linux.c
${CMAKE_CURRENT_LIST_DIR}/time/unix/time.c
${CMAKE_CURRENT_LIST_DIR}/memory/lib_memory.c
)
IF(WIN32)

@ -35,7 +35,7 @@
#include <stdbool.h>
#include <fcntl.h>
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
#include "hal_ethernet.h"
struct sEthernetSocket {

@ -29,10 +29,11 @@
#include <linux/if_arp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
#include "hal_ethernet.h"
struct sEthernetSocket {

@ -24,10 +24,10 @@
#include "stack_config.h"
#include <string.h>
#include <stdio.h>
#include "hal_ethernet.h"
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
#ifndef DEBUG_HAL_ETHERNET
#define DEBUG_HAL_ETHERNET 1

@ -1,7 +1,7 @@
/*
* file_provider_linux.c
*
* Copyright 2014 Michael Zillgith
* Copyright 2014-2018 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -23,16 +23,16 @@
#include <string.h>
#include <dirent.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "libiec61850_platform_includes.h"
#include "hal_filesystem.h"
#include "stack_config.h"
#include "lib_memory.h"
struct sDirectoryHandle {
DIR* handle;

@ -30,8 +30,9 @@
#include "hal_filesystem.h"
#include "libiec61850_platform_includes.h"
#include "platform_endian.h"
#include "stack_config.h"
#include "lib_memory.h"
#include <malloc.h>

@ -0,0 +1,155 @@
/*
* hal_serial.h
*
* Copyright 2017 MZ Automation GmbH
*
* This file is part of lib60870-C
*
* lib60870-C is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* lib60870-C is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with lib60870-C. If not, see <http://www.gnu.org/licenses/>.
*
* See COPYING file for the complete license text.
*/
#ifndef SRC_IEC60870_LINK_LAYER_SERIAL_PORT_H_
#define SRC_IEC60870_LINK_LAYER_SERIAL_PORT_H_
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file hal_serial.h
* \brief Abstraction layer for serial ports.
* Has to be implemented for the serial link layer of CS 101.
*/
/*! \addtogroup hal Platform (Hardware/OS) abstraction layer
*
* @{
*/
/**
* @defgroup HAL_SERIAL Access to serial interfaces
*
* Serial interface abstraction layer. This functions have to be implemented to
* port lib60870 to new platforms when the serial link layers are required.
*
* @{
*/
typedef struct sSerialPort* SerialPort;
typedef enum {
SERIAL_PORT_ERROR_NONE = 0,
SERIAL_PORT_ERROR_INVALID_ARGUMENT = 1,
SERIAL_PORT_ERROR_INVALID_BAUDRATE = 2,
SERIAL_PORT_ERROR_OPEN_FAILED = 3,
SERIAL_PORT_ERROR_UNKNOWN = 99
} SerialPortError;
/**
* \brief Create a new SerialPort instance
*
* \param interfaceName identifier or name of the serial interface (e.g. "/dev/ttyS1" or "COM4")
* \param baudRate the baud rate in baud (e.g. 9600)
* \param dataBits the number of data bits (usually 8)
* \param parity defines what kind of parity to use ('E' - even parity, 'O' - odd parity, 'N' - no parity)
* \param stopBits the number of stop buts (usually 1)
*
* \return the new SerialPort instance
*/
SerialPort
SerialPort_create(const char* interfaceName, int baudRate, uint8_t dataBits, char parity, uint8_t stopBits);
/**
* \brief Destroy the SerialPort instance and release all resources
*/
void
SerialPort_destroy(SerialPort self);
/**
* \brief Open the serial interface
*
* \return true in case of success, false otherwise (use \ref SerialPort_getLastError for a detailed error code)
*/
bool
SerialPort_open(SerialPort self);
/**
* \brief Close (release) the serial interface
*/
void
SerialPort_close(SerialPort self);
/**
* \brief Get the baudrate used by the serial interface
*
* \return the baud rate in baud
*/
int
SerialPort_getBaudRate(SerialPort self);
/**
* \brief Set the timeout used for message reception
*
* \param timeout the timeout value in ms.
*/
void
SerialPort_setTimeout(SerialPort self, int timeout);
/**
* \brief Discard all data in the input buffer of the serial interface
*/
void
SerialPort_discardInBuffer(SerialPort self);
/**
* \brief Read a byte from the interface
*
* \return number of read bytes of -1 in case of an error
*/
int
SerialPort_readByte(SerialPort self);
/**
* \brief Write the number of bytes from the buffer to the serial interface
*
* \param buffer the buffer containing the data to write
* \param startPos start position in the buffer of the data to write
* \param numberOfBytes number of bytes to write
*
* \return number of bytes written, or -1 in case of an error
*/
int
SerialPort_write(SerialPort self, uint8_t* buffer, int startPos, int numberOfBytes);
/**
* \brief Get the error code of the last operation
*/
SerialPortError
SerialPort_getLastError(SerialPort self);
/*! @} */
/*! @} */
#ifdef __cplusplus
}
#endif
#endif /* SRC_IEC60870_LINK_LAYER_SERIAL_PORT_H_ */

@ -1,5 +1,5 @@
/*
* memory.h
* lib_memory.h
*
* Copyright 2014 Michael Zillgith
*

@ -1,7 +1,7 @@
/*
* lib_memory.c
*
* Copyright 2014 Michael Zillgith
* Copyright 2014-2018 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -21,7 +21,8 @@
* See COPYING file for the complete license text.
*/
#include "libiec61850_platform_includes.h"
#include <stdlib.h>
#include "lib_memory.h"
static MemoryExceptionHandler exceptionHandler = NULL;
static void* exceptionHandlerParameter = NULL;

@ -1,7 +1,7 @@
/*
* socket_linux.c
*
* Copyright 2013, 2014 Michael Zillgith
* Copyright 2013-2018 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -31,6 +31,7 @@
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
@ -38,7 +39,8 @@
#include "hal_thread.h"
#include "libiec61850_platform_includes.h"
#include "stack_config.h"
#include "lib_memory.h"
#ifndef DEBUG_SOCKET
#define DEBUG_SOCKET 0

@ -25,10 +25,11 @@
#include <ws2tcpip.h>
#include <windows.h>
#include <stdbool.h>
#include <stdio.h>
#pragma comment (lib, "Ws2_32.lib")
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
#include "hal_socket.h"
#include "stack_config.h"

@ -26,7 +26,7 @@
#include <unistd.h>
#include "hal_thread.h"
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
struct sThread {
ThreadExecutionFunction function;

@ -27,7 +27,7 @@
#include <unistd.h>
#include "hal_thread.h"
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
struct sThread {
ThreadExecutionFunction function;

@ -22,7 +22,7 @@
*/
#include <windows.h>
#include "libiec61850_platform_includes.h"
#include "lib_memory.h"
#include "hal_thread.h"
struct sThread {

@ -5,7 +5,6 @@ set (lib_common_SRCS
./common/map.c
./common/linked_list.c
./common/byte_buffer.c
./common/lib_memory.c
./common/string_utilities.c
./common/buffer_chain.c
./common/conversions.c

Loading…
Cancel
Save