|
1 /* |
|
2 * Copyright (c) 2002,2016 Mario de Sousa (msousa@fe.up.pt) |
|
3 * |
|
4 * This file is part of the Modbus library for Beremiz and matiec. |
|
5 * |
|
6 * This Modbus library is free software: you can redistribute it and/or modify |
|
7 * it under the terms of the GNU Lesser General Public License as published by |
|
8 * the Free Software Foundation, either version 3 of the License, or |
|
9 * (at your option) any later version. |
|
10 * |
|
11 * This program is distributed in the hope that it will be useful, but |
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
|
14 * General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public License |
|
17 * along with this Modbus library. If not, see <http://www.gnu.org/licenses/>. |
|
18 * |
|
19 * This code is made available on the understanding that it will not be |
|
20 * used in safety-critical situations without a full and competent review. |
|
21 */ |
|
22 |
|
23 |
|
24 |
|
25 #ifndef MODBUS_ASCII_PRIVATE_H |
|
26 #define MODBUS_ASCII_PRIVATE_H |
|
27 |
|
28 |
|
29 |
|
30 #include "mb_util.h" |
|
31 |
|
32 |
|
33 /* serial port default configuration... */ |
|
34 #define DEF_DATA_BITS 7 |
|
35 #define DEF_STOP_BITS_PAR 1 /* default stop bits if parity is used */ |
|
36 #define DEF_STOP_BITS_NOP 2 /* default stop bits if parity is not used */ |
|
37 #define DEF_BAUD_RATE 9600 |
|
38 |
|
39 |
|
40 /* Send retries of ascii frames... */ |
|
41 #define ASC_FRAME_SEND_RETRY 0 |
|
42 /* NOTES: |
|
43 * - the above are the retries at the layer1 level, |
|
44 * higher layers may decide to retry for themselves! |
|
45 * - For ascii frames, it doesn't make much sense to retry |
|
46 * if the first try failed... |
|
47 */ |
|
48 |
|
49 |
|
50 /* Buffer sizes... */ |
|
51 #define SEND_BUFFER_SIZE_SMALL (MAX_ASC_FRAME_LENGTH / 2) |
|
52 #define SEND_BUFFER_SIZE_LARGE (MAX_ASC_FRAME_LENGTH) |
|
53 #define RECV_BUFFER_SIZE_SMALL (MAX_ASC_FRAME_LENGTH / 2) |
|
54 #define RECV_BUFFER_SIZE_LARGE (MAX_ASC_FRAME_LENGTH) |
|
55 |
|
56 |
|
57 /* Frame lengths... */ |
|
58 |
|
59 /* The smallest element in an ascii frame. |
|
60 * This is used later to define the smallest value of certain buffers... |
|
61 */ |
|
62 #define ASC_FRAME_MIN_ELE_LENGTH ASC_FRAME_HEADER_LENGTH |
|
63 |
|
64 #if ASC_FRAME_MIN_ELE_LENGTH < ASC_FRAME_TAIL_LENGTH |
|
65 #undef ASC_FRAME_MIN_ELE_LENGTH |
|
66 #define ASC_FRAME_MIN_ELE_LENGTH ASC_FRAME_TAIL_LENGTH |
|
67 #endif |
|
68 |
|
69 #if ASC_FRAME_MIN_ELE_LENGTH < ASC_FRAME_LRC_LENGTH |
|
70 #undef ASC_FRAME_MIN_ELE_LENGTH |
|
71 #define ASC_FRAME_MIN_ELE_LENGTH ASC_FRAME_LRC_LENGTH |
|
72 #endif |
|
73 |
|
74 #if ASC_FRAME_MIN_ELE_LENGTH < L2_TO_ASC_CODING |
|
75 #undef ASC_FRAME_MIN_ELE_LENGTH |
|
76 #define ASC_FRAME_MIN_ELE_LENGTH L2_TO_ASC_CODING |
|
77 #endif |
|
78 |
|
79 |
|
80 #endif /* MODBUS_ASCII_PRIVATE_H */ |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |