msousa@0: /*
msousa@0: * Copyright (c) 2002,2016 Mario de Sousa (msousa@fe.up.pt)
msousa@0: *
msousa@0: * This file is part of the Modbus library for Beremiz and matiec.
msousa@0: *
msousa@0: * This Modbus library is free software: you can redistribute it and/or modify
msousa@0: * it under the terms of the GNU Lesser General Public License as published by
msousa@0: * the Free Software Foundation, either version 3 of the License, or
msousa@0: * (at your option) any later version.
msousa@0: *
msousa@0: * This program is distributed in the hope that it will be useful, but
msousa@0: * WITHOUT ANY WARRANTY; without even the implied warranty of
msousa@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
msousa@0: * General Public License for more details.
msousa@0: *
msousa@0: * You should have received a copy of the GNU Lesser General Public License
msousa@0: * along with this Modbus library. If not, see .
msousa@0: *
msousa@0: * This code is made available on the understanding that it will not be
msousa@0: * used in safety-critical situations without a full and competent review.
msousa@0: */
msousa@0:
msousa@0:
msousa@0: #ifndef MODBUS_LAYER2_H
msousa@0: #define MODBUS_LAYER2_H
msousa@0:
msousa@0: #include /* struct timespec data type */
msousa@0:
msousa@0: //#include
msousa@0: //#include
msousa@0: #include /* superset of previous */ // Required for INADDR_ANY
msousa@0:
msousa@0:
msousa@0: /* Library Error codes */
msousa@0: #define PORT_FAILURE -101
msousa@0: #define INTERNAL_ERROR -102
msousa@0: #define TIMEOUT -103
msousa@0: #define INVALID_FRAME -104
msousa@0: #define MODBUS_ERROR -105
msousa@0:
msousa@0: /* NOTE: Modbus error codes are defined in mb_util.h */
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0: typedef enum {optimize_speed, optimize_size} optimization_t;
msousa@0:
msousa@0:
msousa@0: typedef enum {
msousa@0: naf_ascii,
msousa@0: naf_rtu,
msousa@0: naf_tcp,
msousa@0: } node_addr_family_t;
msousa@0:
msousa@0: typedef struct {
msousa@0: const char *host;
msousa@0: const char *service;
msousa@0: int close_on_silence;
msousa@0: } node_addr_tcp_t;
msousa@0:
msousa@0: typedef struct {
msousa@0: const char *device;
msousa@0: int baud; /* plain baud rate, eg 2400; zero for the default 9600 */
msousa@0: int parity; /* 0 for none, 1 for odd, 2 for even */
msousa@0: int data_bits;
msousa@0: int stop_bits;
msousa@0: int ignore_echo; /* 1 => ignore echo; 0 => do not ignore echo */
msousa@0: } node_addr_rtu_t;
msousa@0:
msousa@0: typedef node_addr_rtu_t node_addr_ascii_t;
msousa@0:
msousa@0: typedef union {
msousa@0: node_addr_ascii_t ascii;
msousa@0: node_addr_rtu_t rtu;
msousa@0: node_addr_tcp_t tcp;
msousa@0: } node_addr_common_t;
msousa@0:
msousa@0: typedef struct {
msousa@0: node_addr_family_t naf;
msousa@0: node_addr_common_t addr;
msousa@0: } node_addr_t;
msousa@0:
msousa@0: #endif /* MODBUS_LAYER2_H */
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0: