Permalink
Browse files

Change indent level from 8 to 4

  • Loading branch information...
1 parent 5ab6c0e commit 66c59d6f852811900f4b7730d0d5d8f321f2226f @stephane committed Jul 19, 2010
Showing with 2,588 additions and 2,590 deletions.
  1. +1 −1 .dir-locals.el
  2. +1,566 −1,567 src/modbus.c
  3. +64 −65 src/modbus.h.in
  4. +111 −111 tests/bandwidth-master.c
  5. +82 −82 tests/bandwidth-slave-many-up.c
  6. +27 −27 tests/bandwidth-slave-one.c
  7. +163 −163 tests/random-test-master.c
  8. +30 −30 tests/random-test-slave.c
  9. +482 −482 tests/unit-test-master.c
  10. +55 −55 tests/unit-test-slave.c
  11. +7 −7 tests/version.c
View
@@ -1,4 +1,4 @@
((nil . ((indent-tabs-mode . nil)
- (c-basic-offset . 8)
+ (c-basic-offset . 4)
(fill-column . 80))))
View
3,133 src/modbus.c

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -59,7 +59,7 @@ extern "C" {
* Maximum between :
* - HEADER_LENGTH_TCP (7) + function (1) + address (2) + number (2)
* - HEADER_LENGTH_RTU (1) + function (1) + address (2) + number (2) + CRC (2)
-*/
+ */
#define MIN_QUERY_LENGTH 12
/* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5:
@@ -123,20 +123,20 @@ extern "C" {
#define MODBUS_ENOBASE 112345678
/* Protocol exceptions */
-enum {
- MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 0x01,
- MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS,
- MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE,
- MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE,
- MODBUS_EXCEPTION_ACKNOWLEDGE,
- MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY,
- MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE,
- MODBUS_EXCEPTION_MEMORY_PARITY,
- MODBUS_EXCEPTION_NOT_DEFINED,
- MODBUS_EXCEPTION_GATEWAY_PATH,
- MODBUS_EXCEPTION_GATEWAY_TARGET,
- MODBUS_EXCEPTION_MAX
-};
+typedef enum {
+ MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 0x01,
+ MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS,
+ MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE,
+ MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE,
+ MODBUS_EXCEPTION_ACKNOWLEDGE,
+ MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY,
+ MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE,
+ MODBUS_EXCEPTION_MEMORY_PARITY,
+ MODBUS_EXCEPTION_NOT_DEFINED,
+ MODBUS_EXCEPTION_GATEWAY_PATH,
+ MODBUS_EXCEPTION_GATEWAY_TARGET,
+ MODBUS_EXCEPTION_MAX
+} modbus_exception_t;
#define EMBXILFUN (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_FUNCTION)
#define EMBXILADD (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS)
@@ -177,20 +177,20 @@ enum {
#define LIBMODBUS_VERSION_STRING "@LIBMODBUS_VERSION@"
/* Numerically encoded version libmb, like 0x010203 */
-#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_MAJOR_VERSION << 24) | \
- (LIBMODBUS_MINOR_VERSION << 16) | \
+#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_MAJOR_VERSION << 24) | \
+ (LIBMODBUS_MINOR_VERSION << 16) | \
(LIBMODBUS_MICRO_VERSION << 8))
/* Evaluates to True if the version of libmb is greater than @major, @minor and
* @micro
*/
-#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \
- (LIBMODBUS_VERSION_MAJOR > (major) || \
- (LIBMODBUS_VERSION_MAJOR == (major) && \
- LIBMODBUS_VERSION_MINOR > (minor)) || \
- (LIBMODBUS_VERSION_MAJOR == (major) && \
- LIBMODBUS_VERSION_MINOR == (minor) && \
- LIBMODBUS_VERSION_MICRO >= (micro)))
+#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \
+ (LIBMODBUS_VERSION_MAJOR > (major) || \
+ (LIBMODBUS_VERSION_MAJOR == (major) && \
+ LIBMODBUS_VERSION_MINOR > (minor)) || \
+ (LIBMODBUS_VERSION_MAJOR == (major) && \
+ LIBMODBUS_VERSION_MINOR == (minor) && \
+ LIBMODBUS_VERSION_MICRO >= (micro)))
extern const unsigned int libmodbus_version_major;
extern const unsigned int libmodbus_version_minor;
@@ -200,54 +200,53 @@ typedef enum { RTU=0, TCP } type_com_t;
/* This structure is byte-aligned */
typedef struct {
- /* Slave address */
- int slave;
- /* Descriptor (tty or socket) */
- int fd;
- /* Communication mode: RTU or TCP */
- type_com_t type_com;
- /* Flag debug */
- int debug;
- /* TCP port */
- int port;
- /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*"
- on Mac OS X for KeySpan USB<->Serial adapters this string
- had to be made bigger on OS X as the directory+file name
- was bigger than 19 bytes. Making it 67 bytes for now, but
- OS X does support 256 byte file names. May become a problem
- in the future. */
+ /* Slave address */
+ int slave;
+ /* Descriptor (tty or socket) */
+ int fd;
+ /* Communication mode: RTU or TCP */
+ type_com_t type_com;
+ /* Flag debug */
+ int debug;
+ /* TCP port */
+ int port;
+ /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*" on Mac OS X for
+ KeySpan USB<->Serial adapters this string had to be made bigger on OS X
+ as the directory+file name was bigger than 19 bytes. Making it 67 bytes
+ for now, but OS X does support 256 byte file names. May become a problem
+ in the future. */
#ifdef __APPLE_CC__
- char device[64];
+ char device[64];
#else
- char device[16];
+ char device[16];
#endif
- /* Bauds: 9600, 19200, 57600, 115200, etc */
- int baud;
- /* Data bit */
- uint8_t data_bit;
- /* Stop bit */
- uint8_t stop_bit;
- /* Parity: 'N', 'O', 'E' */
- char parity;
- /* In error_treat with TCP, do a reconnect or just dump the error */
- uint8_t error_recovery;
+ /* Bauds: 9600, 19200, 57600, 115200, etc */
+ int baud;
+ /* Data bit */
+ uint8_t data_bit;
+ /* Stop bit */
+ uint8_t stop_bit;
+ /* Parity: 'N', 'O', 'E' */
+ char parity;
+ /* In error_treat with TCP, do a reconnect or just dump the error */
+ uint8_t error_recovery;
/* IP address */
- char ip[16];
- /* Save old termios settings */
- struct termios old_tios;
- struct timeval timeout_begin;
- struct timeval timeout_end;
+ char ip[16];
+ /* Save old termios settings */
+ struct termios old_tios;
+ struct timeval timeout_begin;
+ struct timeval timeout_end;
} modbus_param_t;
typedef struct {
- int nb_coil_status;
- int nb_input_status;
- int nb_input_registers;
- int nb_holding_registers;
- uint8_t *tab_coil_status;
- uint8_t *tab_input_status;
- uint16_t *tab_input_registers;
- uint16_t *tab_holding_registers;
+ int nb_coil_status;
+ int nb_input_status;
+ int nb_input_registers;
+ int nb_holding_registers;
+ uint8_t *tab_coil_status;
+ uint8_t *tab_input_status;
+ uint16_t *tab_input_registers;
+ uint16_t *tab_holding_registers;
} modbus_mapping_t;
int modbus_init_rtu(modbus_param_t *mb_param, const char *device,
Oops, something went wrong.

0 comments on commit 66c59d6

Please sign in to comment.