|
MODBUS laajempi esimerkki
|

Go to the source code of this file.
Functions | |
| unsigned char | create_response_message (unsigned char *response) |
| Creates a response message.Not in use. More... | |
| void | clear_receive_buffer (void) |
| Clears the receive buffer. More... | |
| void | clear_response_buffer (void) |
| Clears the response buffer. More... | |
| unsigned char | check_LRC (unsigned char *response, unsigned char length_of_message) |
| Check the LRC in the received ModBus message. More... | |
| unsigned char | calculate_LRC (unsigned char *message, unsigned char nro_characters) |
| Calculates LRC checksum from received ModBus message. More... | |
| unsigned char | calculate_response_LRC (unsigned char *message, unsigned char nro_characters) |
| Calculates LRC checksum for the response to be sended. Called only once. More... | |
| unsigned char | ascii_hex_to_hex (unsigned char *start_address) |
| Converts two ASCII-Hex characters into one Hex-character. More... | |
| unsigned char | get_function (unsigned char *message) |
| Retrieves the function code from the received ModBus message. More... | |
| unsigned char | check_own_address (unsigned char *message) |
| void | create_echo_of_query (unsigned char *message, unsigned char *length_of_response_hex) |
| Creates an echo of the received ModBus query. More... | |
| void | create_diagnostic_response (unsigned int sub_function, unsigned int diagnostic_counter_value) |
| Creates a response for ModBus Diagnostic query. More... | |
| 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 Guide. More... | |
| unsigned int | get_start_address_of_holding_registers (unsigned char *message) |
| Retrieves the Start Address value for Holding Register reading. More... | |
| unsigned int | get_number_of_points (unsigned char *message) |
| Retrieves the Number of Points value for Holding Register reading. More... | |
| void | create_and_send_exception_response (unsigned char function, unsigned char error_condition) |
| 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 0x08. More... | |
| void | transmit_response (unsigned char *send_pointer, unsigned char length) |
| Transmits the response to a ModBus query. More... | |
| unsigned char | hex_to_ascii_hex (unsigned char *response, unsigned char length) |
| void | Fatal_error (unsigned char error_code) |
| On fatal error executin comes here and watch dog will handle the reset. More... | |
| void | error (unsigned char error_code) |
| void | error_getting_message (unsigned char *message, unsigned char error_code) |
| Sends a debug message based on a specific error. More... | |
Header for modbus.c.
| #define BOOT_COUNTER 20 |
| #define BUS_CHARACTER_OVERRUN_COUNTER 16 |
| #define BUS_COMMUNICATION_ERROR_COUNTER 4 |
| #define BUS_MESSAGE_COUNTER 0 |
| #define COUNTER_QUERY 3 |
| #define END_OF_COUNTER_REGISTERS 203 |
| #define END_OF_MEDIAN_REGISTERS 8 |
| #define END_OF_REAL_TIME_REGISTERS 108 |
| #define EXCEPTION_ERROR_COUNTER 8 |
| #define FIRST_START_INDICATOR 16 |
| #define LENGTH_OF_CLEAR_COUNTERS_QUERY 7 |
| #define MAX_LENGTH_OF_BUFFER MAX_LENGTH_OF_MESSAGE*2 |
| #define MAX_LENGTH_OF_MESSAGE 128 |
| #define MEDIAN_MEASUREMENT 1 |
| #define PLACE_OF_BOOT_COUNTER_HIGH 3 |
| #define PLACE_OF_BOOT_COUNTER_LOW 4 |
| #define PLACE_OF_BUS_COMMUNICATION_ERROR_COUNTER_HIGH 7 |
| #define PLACE_OF_BUS_COMMUNICATION_ERROR_COUNTER_LOW 8 |
| #define PLACE_OF_EXCEPTION_ERROR_COUNTER_HIGH 5 |
| #define PLACE_OF_EXCEPTION_ERROR_COUNTER_LOW 6 |
| #define QUANTITY_MEASUREMENT_REGISTERS 8 |
| #define QUANTITY_OF_COUNTER_REGISTERS 3 |
| #define REAL_TIME_MEASUREMENT 2 |
| #define SLAVE_MESSAGE_COUNTER 12 |
| #define START_OF_COUNTER_REGISTERS 200 |
| #define START_OF_MEDIAN_REGISTERS 0 |
| #define START_OF_REAL_TIME_REGISTERS 100 |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| unsigned char ascii_hex_to_hex | ( | unsigned char * | message | ) |
Converts two ASCII-Hex characters into one Hex-character.
| message | Pointer to two ASCII-Hex characters to be converted. |

| unsigned char calculate_LRC | ( | unsigned char * | message, |
| unsigned char | nro_characters | ||
| ) |
Calculates LRC checksum from received ModBus message.
| message | The received ModBus message in ASCII-Hex. |
| nro_characters | Number of characters in the received ModBus message. |


| unsigned char calculate_response_LRC | ( | unsigned char * | message, |
| unsigned char | nro_characters | ||
| ) |
Calculates LRC checksum for the response to be sended. Called only once.
| message | The response message in HEX. |
| nro_characters | Number of characters to be included in the calculation. |

| unsigned char check_LRC | ( | unsigned char * | message, |
| unsigned char | length_of_message | ||
| ) |
Check the LRC in the received ModBus message.
| message | The received ModBus message. |
| length_of_message | Length of the received message. |


| unsigned char check_own_address | ( | unsigned char * | message | ) |
| void clear_receive_buffer | ( | void | ) |
Clears the receive buffer.

| void clear_response_buffer | ( | void | ) |
Clears the response buffer.

| void create_and_send_exception_response | ( | unsigned char | function, |
| unsigned char | error_condition | ||
| ) |
| void create_diagnostic_response | ( | unsigned int | sub_function, |
| unsigned int | diagnostic_counter_value | ||
| ) |
Creates a response for ModBus Diagnostic query.
| sub_function | The sub function value from the received query. |
| diagnostic_counter_value | Diagnostic counter value responding to the received query. |

| void create_echo_of_query | ( | unsigned char * | message, |
| unsigned char * | length_of_response_hex | ||
| ) |
Creates an echo of the received ModBus query.
| message | Pointer to the received ModBus query. |
| length_of_response_hex | Length of the query in Hex. |


| 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 Guide.
| function | The ModBus function where the exception occurred. |
| error_condition | The condition why the error occurred (Standard ModBus Exception Error code). |

| unsigned char create_response_message | ( | unsigned char * | response | ) |
Creates a response message.Not in use.
| response | Pointer to response message. |
| void error | ( | unsigned char | error_code | ) |
| void error_getting_message | ( | unsigned char * | s, |
| unsigned char | error_code | ||
| ) |
Sends a debug message based on a specific error.
| s | Pointer to message that caused the error. |
| error_code | Specific error code. |

| void Fatal_error | ( | unsigned char | error_code | ) |
On fatal error executin comes here and watch dog will handle the reset.
| error_code | Error code for error definition. |

| unsigned char get_function | ( | unsigned char * | message | ) |
Retrieves the function code from the received ModBus message.
| message | Pointer to the received ModBus message. |


| unsigned int get_number_of_points | ( | unsigned char * | message | ) |
Retrieves the Number of Points value for Holding Register reading.
| message | Pointer to the received ModBus message. |


| unsigned int get_start_address_of_holding_registers | ( | unsigned char * | message | ) |
Retrieves the Start Address value for Holding Register reading.
| message | Pointer to the received ModBus message. |


| 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 0x08.
| message | Pointer to the received ModBus message. |


| unsigned char hex_to_ascii_hex | ( | unsigned char * | response, |
| unsigned char | length | ||
| ) |
| void transmit_response | ( | unsigned char * | send_pointer, |
| unsigned char | length | ||
| ) |
Transmits the response to a ModBus query.
| send_pointer | Response in ASCII-Hex without START- and STOP-characters. |
| length | Length of the response. |

