# HG changeset patch # User Andrey Skvortsov # Date 1489851964 0 # Node ID 59783e8ee3d2983d76466b420624e4b87d166f47 # Parent ae252e0fd9b8512708c07a2b533590c2fa5342dc Remove incorrect inlines diff -r ae252e0fd9b8 -r 59783e8ee3d2 mb_master.c --- a/mb_master.c Sun Mar 05 00:05:46 2017 +0000 +++ b/mb_master.c Sat Mar 18 15:46:04 2017 +0000 @@ -374,16 +374,16 @@ /* FUNCTION 0x01 - Read Coils * Bits are stored on an int array, one bit per int. */ -inline int read_output_bits(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex) { +int read_output_bits(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex) { if( count > MAX_READ_BITS ) { count = MAX_READ_BITS; #ifdef DEBUG @@ -402,14 +402,14 @@ * Bits are stored on an u32 array, 32 bits per u32. * Unused bits in last u32 are set to 0. */ -inline int read_output_bits_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout) { +int read_output_bits_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout) { if( count > MAX_READ_BITS ) { count = MAX_READ_BITS; #ifdef DEBUG @@ -426,16 +426,16 @@ /* FUNCTION 0x02 - Read Discrete Inputs * Bits are stored on an int array, one bit per int. */ -inline int read_input_bits(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex) { +int read_input_bits(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex) { if( count > MAX_READ_BITS ) { count = MAX_READ_BITS; #ifdef DEBUG @@ -454,14 +454,14 @@ * Bits are stored on an u32 array, 32 bits per u32. * Unused bits in last u32 are set to 0. */ -inline int read_input_bits_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout) { +int read_input_bits_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout) { if( count > MAX_READ_BITS ) { count = MAX_READ_BITS; #ifdef DEBUG @@ -657,146 +657,146 @@ /* FUNCTION 0x03 - Read Holding Registers */ -inline int read_output_words(u8 slave, +int read_output_words(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex) { + if( count > MAX_READ_REGS ) { + count = MAX_READ_REGS; + #ifdef DEBUG + fprintf( stderr, "Too many registers requested.\n" ); + #endif + } + + return read_registers(0x03 /* function */, + slave, start_addr, count, dest, dest_size, ttyfd, + send_retries, error_code, response_timeout, data_access_mutex); +} + + + + +/* FUNCTION 0x03 - Read Holding Registers + * u16 registers are stored in array of u32, two registers per u32. + * Unused bits of last u32 element are set to 0. + */ +int read_output_words_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout) { + if( count > MAX_READ_REGS ) { + count = MAX_READ_REGS; + #ifdef DEBUG + fprintf( stderr, "Too many registers requested.\n" ); + #endif + } + + return read_registers_u32(0x03 /* function */, + slave, start_addr, count, dest, ttyfd, + send_retries, error_code, response_timeout); +} + + + + +/* FUNCTION 0x03 - Read Holding Registers + * return the array with the data to the calling function + */ +int read_output_words_u16_ref(u8 slave, + u16 start_addr, + u16 count, + u16 **dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout) { + if( count > MAX_READ_REGS ) { + count = MAX_READ_REGS; + #ifdef DEBUG + fprintf( stderr, "Too many registers requested.\n" ); + #endif + } + + return read_registers_u16_ref(0x03 /* function */, + slave, start_addr, count, dest, ttyfd, send_retries, + error_code, response_timeout); +} + + + + +/* FUNCTION 0x04 - Read Input Registers */ +int read_input_words(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex) { + if( count > MAX_READ_REGS ) { + count = MAX_READ_REGS; + #ifdef DEBUG + fprintf( stderr, "Too many input registers requested.\n" ); + #endif + } + + return read_registers(0x04 /* function */, + slave, start_addr, count, dest, dest_size, ttyfd, send_retries, + error_code, response_timeout, data_access_mutex); +} + + +/* FUNCTION 0x04 - Read Input Registers + * u16 registers are stored in array of u32, two registers per u32. + * Unused bits of last u32 element are set to 0. + */ +int read_input_words_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout) { + if( count > MAX_READ_REGS ) { + count = MAX_READ_REGS; + #ifdef DEBUG + fprintf( stderr, "Too many input registers requested.\n" ); + #endif + } + + return read_registers_u32(0x04 /* function */, + slave, start_addr, count, dest, ttyfd, send_retries, + error_code, response_timeout); +} + + + + +/* FUNCTION 0x04 - Read Input Registers + * return the array with the data to the calling function + */ +int read_input_words_u16_ref(u8 slave, u16 start_addr, u16 count, - u16 *dest, - int dest_size, + u16 **dest, int ttyfd, int send_retries, u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex) { - if( count > MAX_READ_REGS ) { - count = MAX_READ_REGS; - #ifdef DEBUG - fprintf( stderr, "Too many registers requested.\n" ); - #endif - } - - return read_registers(0x03 /* function */, - slave, start_addr, count, dest, dest_size, ttyfd, - send_retries, error_code, response_timeout, data_access_mutex); -} - - - - -/* FUNCTION 0x03 - Read Holding Registers - * u16 registers are stored in array of u32, two registers per u32. - * Unused bits of last u32 element are set to 0. - */ -inline int read_output_words_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout) { - if( count > MAX_READ_REGS ) { - count = MAX_READ_REGS; - #ifdef DEBUG - fprintf( stderr, "Too many registers requested.\n" ); - #endif - } - - return read_registers_u32(0x03 /* function */, - slave, start_addr, count, dest, ttyfd, - send_retries, error_code, response_timeout); -} - - - - -/* FUNCTION 0x03 - Read Holding Registers - * return the array with the data to the calling function - */ -inline int read_output_words_u16_ref(u8 slave, - u16 start_addr, - u16 count, - u16 **dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout) { - if( count > MAX_READ_REGS ) { - count = MAX_READ_REGS; - #ifdef DEBUG - fprintf( stderr, "Too many registers requested.\n" ); - #endif - } - - return read_registers_u16_ref(0x03 /* function */, - slave, start_addr, count, dest, ttyfd, send_retries, - error_code, response_timeout); -} - - - - -/* FUNCTION 0x04 - Read Input Registers */ -inline int read_input_words(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex) { - if( count > MAX_READ_REGS ) { - count = MAX_READ_REGS; - #ifdef DEBUG - fprintf( stderr, "Too many input registers requested.\n" ); - #endif - } - - return read_registers(0x04 /* function */, - slave, start_addr, count, dest, dest_size, ttyfd, send_retries, - error_code, response_timeout, data_access_mutex); -} - - -/* FUNCTION 0x04 - Read Input Registers - * u16 registers are stored in array of u32, two registers per u32. - * Unused bits of last u32 element are set to 0. - */ -inline int read_input_words_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout) { - if( count > MAX_READ_REGS ) { - count = MAX_READ_REGS; - #ifdef DEBUG - fprintf( stderr, "Too many input registers requested.\n" ); - #endif - } - - return read_registers_u32(0x04 /* function */, - slave, start_addr, count, dest, ttyfd, send_retries, - error_code, response_timeout); -} - - - - -/* FUNCTION 0x04 - Read Input Registers - * return the array with the data to the calling function - */ -inline int read_input_words_u16_ref(u8 slave, - u16 start_addr, - u16 count, - u16 **dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout) { + const struct timespec *response_timeout) { if( count > MAX_READ_REGS ) { count = MAX_READ_REGS; #ifdef DEBUG @@ -852,14 +852,14 @@ /* FUNCTION 0x05 - Force Single Coil */ -inline int write_output_bit(u8 slave, - u16 coil_addr, - u16 state, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex) { +int write_output_bit(u8 slave, + u16 coil_addr, + u16 state, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex) { if (state) state = 0xFF00; return set_single(0x05 /* function */, @@ -872,14 +872,14 @@ /* FUNCTION 0x06 - Write Single Register */ -inline int write_output_word(u8 slave, - u16 reg_addr, - u16 value, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex) { +int write_output_word(u8 slave, + u16 reg_addr, + u16 value, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex) { return set_single(0x06 /* function */, slave, reg_addr, value, fd, send_retries, error_code, response_timeout, data_access_mutex); diff -r ae252e0fd9b8 -r 59783e8ee3d2 mb_master.h --- a/mb_master.h Sun Mar 05 00:05:46 2017 +0000 +++ b/mb_master.h Sat Mar 18 15:46:04 2017 +0000 @@ -53,16 +53,16 @@ /* FUNCTION 0x01 - Read Coils * Bits are stored on an int array, one bit per int. */ -inline int read_output_bits(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex); +int read_output_bits(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex); #define read_coils(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \ read_output_bits(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) @@ -71,14 +71,14 @@ * Bits are stored on an u32 array, 32 bits per u32. * Unused bits in last u32 are set to 0. */ -inline int read_output_bits_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout); +int read_output_bits_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout); #define read_coils_u32(p1,p2,p3,p4,p5,p6,p7,p8) \ read_output_bits_u32(p1,p2,p3,p4,p5,p6,p7,p8) @@ -88,16 +88,16 @@ /* FUNCTION 0x02 - Read Discrete Inputs * Bits are stored on an int array, one bit per int. */ -inline int read_input_bits(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex); +int read_input_bits(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex); #define read_discrete_inputs(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \ read_input_bits (p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) @@ -106,14 +106,14 @@ * Bits are stored on an u32 array, 32 bits per u32. * Unused bits in last u32 are set to 0. */ -inline int read_input_bits_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout); +int read_input_bits_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout); #define read_discrete_inputs_u32(p1,p2,p3,p4,p5,p6,p7,p8) \ read_input_bits_u32 (p1,p2,p3,p4,p5,p6,p7,p8) @@ -121,16 +121,16 @@ /* FUNCTION 0x03 - Read Holding Registers */ -inline int read_output_words(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex); +int read_output_words(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex); #define read_holding_registers(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \ read_output_words (p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) @@ -139,14 +139,14 @@ * u16 registers are stored in array of u32, two registers per u32. * Unused bits of last u32 element are set to 0. */ -inline int read_output_words_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout); +int read_output_words_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout); #define read_holding_registers_u32(p1,p2,p3,p4,p5,p6,p7,p8) \ read_output_words_u32 (p1,p2,p3,p4,p5,p6,p7,p8) @@ -154,30 +154,30 @@ /* FUNCTION 0x03 - Read Holding Registers * return the array with the data to the calling function */ -inline int read_output_words_u16_ref(u8 slave, - u16 start_addr, - u16 count, - u16 **dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout); +int read_output_words_u16_ref(u8 slave, + u16 start_addr, + u16 count, + u16 **dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout); #define read_holding_registers_u16_ref(p1,p2,p3,p4,p5,p6,p7,p8) \ read_output_words_u16_ref (p1,p2,p3,p4,p5,p6,p7,p8) /* FUNCTION 0x04 - Read Input Registers */ -inline int read_input_words(u8 slave, - u16 start_addr, - u16 count, - u16 *dest, - int dest_size, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex); +int read_input_words(u8 slave, + u16 start_addr, + u16 count, + u16 *dest, + int dest_size, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex); #define read_input_registers(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \ read_input_words (p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) @@ -187,14 +187,14 @@ * u16 registers are stored in array of u32, two registers per u32. * Unused bits of last u32 element are set to 0. */ -inline int read_input_words_u32(u8 slave, - u16 start_addr, - u16 count, - u32 *dest, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout); +int read_input_words_u32(u8 slave, + u16 start_addr, + u16 count, + u32 *dest, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout); #define read_input_registers_u32(p1,p2,p3,p4,p5,p6,p7,p8) \ read_input_words_u32 (p1,p2,p3,p4,p5,p6,p7,p8) @@ -203,14 +203,14 @@ /* FUNCTION 0x04 - Read Input Registers * return the array with the data to the calling function */ -inline int read_input_words_u16_ref(u8 slave, - u16 start_addr, - u16 count, - u16 **dest, - int ttyfd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout); +int read_input_words_u16_ref(u8 slave, + u16 start_addr, + u16 count, + u16 **dest, + int ttyfd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout); #define read_input_registers_u16_ref(p1,p2,p3,p4,p5,p6,p7,p8) \ read_input_words_u16_ref (p1,p2,p3,p4,p5,p6,p7,p8) @@ -218,14 +218,14 @@ /* FUNCTION 0x05 - Force Single Coil */ -inline int write_output_bit(u8 slave, - u16 coil_addr, - u16 state, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex); +int write_output_bit(u8 slave, + u16 coil_addr, + u16 state, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex); #define force_single_coil(p1,p2,p3,p4,p5,p6,p7,p8) \ write_output_bit (p1,p2,p3,p4,p5,p6,p7,p8) @@ -235,14 +235,14 @@ /* FUNCTION 0x06 - Write Single Register */ -inline int write_output_word(u8 slave, - u16 reg_addr, - u16 value, - int fd, - int send_retries, - u8 *error_code, - const struct timespec *response_timeout, - pthread_mutex_t *data_access_mutex); +int write_output_word(u8 slave, + u16 reg_addr, + u16 value, + int fd, + int send_retries, + u8 *error_code, + const struct timespec *response_timeout, + pthread_mutex_t *data_access_mutex); #define write_single_register(p1,p2,p3,p4,p5,p6,p7,p8) \ write_output_word (p1,p2,p3,p4,p5,p6,p7,p8)