msousa@0: /*
msousa@0: * Copyright (c) 2001,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:
msousa@0: #ifndef MODBUS_LAYER1_H
msousa@0: #define MODBUS_LAYER1_H
msousa@0:
msousa@0: #include /* struct timespec data type */
msousa@0:
msousa@0: #include "mb_types.h" /* get the data types */
msousa@0: #include "mb_addr.h" /* get definitions of common variable types */
msousa@0:
msousa@0:
msousa@0: /* Define max registers and bits */
msousa@0: #define MAX_READ_BITS 2000 /* Functions 0x01 and 0x02 */
msousa@0: #define MAX_READ_REGS 125 /* Functions 0x03 and 0x04 */
msousa@0: #define MAX_WRITE_COILS 1968 /* Function 0x0F */
msousa@0: #define MAX_WRITE_REGS 123 /* Function 0x10 */
msousa@0:
msousa@0:
msousa@0: /* Declare TCP layer1 functions */
msousa@0: #define modbus_write modbus_tcp_write
msousa@0: #define modbus_read modbus_tcp_read
msousa@0: #define modbus_init modbus_tcp_init
msousa@0: #define modbus_done modbus_tcp_done
msousa@0: #define modbus_connect modbus_tcp_connect
msousa@0: #define modbus_listen modbus_tcp_listen
msousa@0: #define modbus_close modbus_tcp_close
msousa@0: #define modbus_silence_init modbus_tcp_silence_init
msousa@0: #define modbus_get_min_timeout modbus_tcp_get_min_timeout
msousa@0:
msousa@0: #include "mb_layer1_prototypes.h"
msousa@0:
msousa@0: #undef modbus_write
msousa@0: #undef modbus_read
msousa@0: #undef modbus_init
msousa@0: #undef modbus_done
msousa@0: #undef modbus_connect
msousa@0: #undef modbus_listen
msousa@0: #undef modbus_close
msousa@0: #undef modbus_silence_init
msousa@0: #undef modbus_get_min_timeout
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0: /* Declare RTU layer1 functions */
msousa@0: #define modbus_write modbus_rtu_write
msousa@0: #define modbus_read modbus_rtu_read
msousa@0: #define modbus_init modbus_rtu_init
msousa@0: #define modbus_done modbus_rtu_done
msousa@0: #define modbus_connect modbus_rtu_connect
msousa@0: #define modbus_listen modbus_rtu_listen
msousa@0: #define modbus_close modbus_rtu_close
msousa@0: #define modbus_silence_init modbus_rtu_silence_init
msousa@0: #define modbus_get_min_timeout modbus_rtu_get_min_timeout
msousa@0:
msousa@0: #include "mb_layer1_prototypes.h"
msousa@0:
msousa@0: #undef modbus_write
msousa@0: #undef modbus_read
msousa@0: #undef modbus_init
msousa@0: #undef modbus_done
msousa@0: #undef modbus_connect
msousa@0: #undef modbus_listen
msousa@0: #undef modbus_close
msousa@0: #undef modbus_silence_init
msousa@0: #undef modbus_get_min_timeout
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0: /* Declare ASCII layer1 functions */
msousa@0: #define modbus_write modbus_ascii_write
msousa@0: #define modbus_read modbus_ascii_read
msousa@0: #define modbus_init modbus_ascii_init
msousa@0: #define modbus_done modbus_ascii_done
msousa@0: #define modbus_connect modbus_ascii_connect
msousa@0: #define modbus_listen modbus_ascii_listen
msousa@0: #define modbus_close modbus_ascii_close
msousa@0: #define modbus_silence_init modbus_ascii_silence_init
msousa@0: #define modbus_get_min_timeout modbus_ascii_get_min_timeout
msousa@0:
msousa@0: #include "mb_layer1_prototypes.h"
msousa@0:
msousa@0: #undef modbus_write
msousa@0: #undef modbus_read
msousa@0: #undef modbus_init
msousa@0: #undef modbus_done
msousa@0: #undef modbus_connect
msousa@0: #undef modbus_listen
msousa@0: #undef modbus_close
msousa@0: #undef modbus_silence_init
msousa@0: #undef modbus_get_min_timeout
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0: #define modbus_write (*modbus_write )
msousa@0: #define modbus_read (*modbus_read )
msousa@0: #define modbus_init (*modbus_init )
msousa@0: #define modbus_done (*modbus_done )
msousa@0: #define modbus_connect (*modbus_connect )
msousa@0: #define modbus_listen (*modbus_listen )
msousa@0: #define modbus_close (*modbus_close )
msousa@0: #define modbus_silence_init (*modbus_silence_init )
msousa@0: #define modbus_get_min_timeout (*modbus_get_min_timeout)
msousa@0:
msousa@0: typedef struct {
msousa@0: #include "mb_layer1_prototypes.h"
msousa@0: } layer1_funct_ptr_t;
msousa@0:
msousa@0: #undef modbus_write
msousa@0: #undef modbus_read
msousa@0: #undef modbus_init
msousa@0: #undef modbus_done
msousa@0: #undef modbus_connect
msousa@0: #undef modbus_listen
msousa@0: #undef modbus_close
msousa@0: #undef modbus_silence_init
msousa@0: #undef modbus_get_min_timeout
msousa@0:
msousa@0:
msousa@0:
msousa@0: extern layer1_funct_ptr_t fptr_[4];
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0:
msousa@0: #endif /* MODBUS_LAYER1_H */
msousa@0:
msousa@0: