34 #define BUS_MESSAGE_COUNTER 0 35 #define BUS_COMMUNICATION_ERROR_COUNTER 4 36 #define EXCEPTION_ERROR_COUNTER 8 37 #define SLAVE_MESSAGE_COUNTER 12 38 #define BUS_CHARACTER_OVERRUN_COUNTER 16 42 #define FIRST_START_INDICATOR 16 43 #define BOOT_COUNTER 20 46 #define MAX_LENGTH_OF_MESSAGE 128 47 #define MAX_LENGTH_OF_BUFFER MAX_LENGTH_OF_MESSAGE*2 50 #define QUANTITY_MEASUREMENT_REGISTERS 8 51 #define QUANTITY_OF_COUNTER_REGISTERS 3 54 #define START_OF_MEDIAN_REGISTERS 0 55 #define END_OF_MEDIAN_REGISTERS 8 56 #define START_OF_REAL_TIME_REGISTERS 100 57 #define END_OF_REAL_TIME_REGISTERS 108 58 #define START_OF_COUNTER_REGISTERS 200 59 #define END_OF_COUNTER_REGISTERS 203 62 #define PLACE_OF_BOOT_COUNTER_HIGH 3 63 #define PLACE_OF_BOOT_COUNTER_LOW 4 64 #define PLACE_OF_EXCEPTION_ERROR_COUNTER_HIGH 5 65 #define PLACE_OF_EXCEPTION_ERROR_COUNTER_LOW 6 66 #define PLACE_OF_BUS_COMMUNICATION_ERROR_COUNTER_HIGH 7 67 #define PLACE_OF_BUS_COMMUNICATION_ERROR_COUNTER_LOW 8 70 #define MEDIAN_MEASUREMENT 1 71 #define REAL_TIME_MEASUREMENT 2 72 #define COUNTER_QUERY 3 74 #define LENGTH_OF_CLEAR_COUNTERS_QUERY 7 184 void error (
unsigned char error_code );
unsigned int sub_function
Definition: mittari_jumapohja.c:43
unsigned char * send_pointer
void Fatal_error(unsigned char error_code)
On fatal error executin comes here and watch dog will handle the reset.
Definition: util.c:27
unsigned char message[MAX_LENGTH_OF_MESSAGE]
Definition: mittari_jumapohja.c:28
void create_echo_of_query(unsigned char *message, unsigned char *length_of_response_hex)
Creates an echo of the received ModBus query.
Definition: modbus.c:364
unsigned char hex_to_ascii_hex(unsigned char *response, unsigned char length)
void clear_receive_buffer(void)
Clears the receive buffer.
Definition: modbus.c:499
unsigned int start_address
Definition: mittari_jumapohja.c:43
unsigned char length_of_message
Definition: mittari_jumapohja.c:32
unsigned int get_sub_function(unsigned char *message)
Retrieves the sub function code from the received ModBus message. Is called only if function code is ...
Definition: modbus.c:92
void error_getting_message(unsigned char *message, unsigned char error_code)
Sends a debug message based on a specific error.
Definition: modbus.c:383
void create_and_send_exception_response(unsigned char function, unsigned char error_condition)
void error(unsigned char error_code)
unsigned int get_start_address_of_holding_registers(unsigned char *message)
Retrieves the Start Address value for Holding Register reading.
Definition: modbus.c:116
unsigned char check_own_address(unsigned char *message)
unsigned char response[MAX_LENGTH_OF_MESSAGE]
Definition: mittari_jumapohja.c:29
void create_diagnostic_response(unsigned int sub_function, unsigned int diagnostic_counter_value)
Creates a response for ModBus Diagnostic query.
Definition: modbus.c:334
unsigned int get_number_of_points(unsigned char *message)
Retrieves the Number of Points value for Holding Register reading.
Definition: modbus.c:139
unsigned char ascii_hex_to_hex(unsigned char *start_address)
Converts two ASCII-Hex characters into one Hex-character.
Definition: modbus.c:191
void create_exception_response(unsigned char function, unsigned char error_condition)
Creates a ModBus Exceprion Response message. Described in page 95 Modicon Modbus Protocol Reference G...
Definition: modbus.c:314
void transmit_response(unsigned char *send_pointer, unsigned char length)
Transmits the response to a ModBus query.
Definition: modbus.c:482
unsigned char create_response_message(unsigned char *response)
Creates a response message.Not in use.
Definition: modbus.c:293
unsigned char calculate_LRC(unsigned char *message, unsigned char nro_characters)
Calculates LRC checksum from received ModBus message.
Definition: modbus.c:218
unsigned char check_LRC(unsigned char *response, unsigned char length_of_message)
Check the LRC in the received ModBus message.
Definition: modbus.c:268
unsigned char get_function(unsigned char *message)
Retrieves the function code from the received ModBus message.
Definition: modbus.c:74
unsigned char error_condition
Definition: mittari_jumapohja.c:67
unsigned char calculate_response_LRC(unsigned char *message, unsigned char nro_characters)
Calculates LRC checksum for the response to be sended. Called only once.
Definition: modbus.c:245
void clear_response_buffer(void)
Clears the response buffer.
Definition: modbus.c:522