#include "modbus.h"
#include "crc.h"
Go to the source code of this file.
◆ ILLEGAL_DATA_ADDRESS
      
        
          | #define ILLEGAL_DATA_ADDRESS   2 | 
      
 
 
◆ ILLEGAL_DATA_VALUE
      
        
          | #define ILLEGAL_DATA_VALUE   3 | 
      
 
 
◆ ILLEGAL_FUNCTION
      
        
          | #define ILLEGAL_FUNCTION   1 | 
      
 
 
◆ READ_HOLDING_REGISTERS
      
        
          | #define READ_HOLDING_REGISTERS   0x03 | 
      
 
Modbus function for read holding register = 03. 
Definition at line 8 of file modbus.c.
 
 
◆ READ_INPUT_REGISTERS
      
        
          | #define READ_INPUT_REGISTERS   0x04 | 
      
 
Modbus function for read input register = 04. 
Definition at line 7 of file modbus.c.
 
 
◆ SLAVE_DEVICE_FAILURE
      
        
          | #define SLAVE_DEVICE_FAILURE   4 | 
      
 
 
◆ WRITE_SINGLE_REGISTER
      
        
          | #define WRITE_SINGLE_REGISTER   0x06 | 
      
 
Modbus function for write a single register = 06. 
Definition at line 9 of file modbus.c.
 
 
◆ measure_voltage()
      
        
          | uint16_t measure_voltage | ( |  | ) |  | 
      
 
Measure the voltage on the channel for the current. This function is expected to do some filtering.
- Returns
- The offset 
Definition at line 37 of file measure.c.
 
 
◆ modbus_analyse_and_answer()
      
        
          | uint8_t modbus_analyse_and_answer | ( | void |  | ) |  | 
      
 
Analyses the received frame and answer to server
- Returns
- an error code if frame not valid 
Definition at line 40 of file modbus.c.
 
 
◆ modbus_char_recvd()
      
        
          | void modbus_char_recvd | ( | void |  | ) |  | 
      
 
This function will be called every time a character has been received on the Modbus serial port. It is called from the interrupt hander.
- Parameters
- 
  
    | c | : the received char // removed ! |  
 
- See also
- interrupts.c. 
Definition at line 85 of file modbus.c.
 
 
◆ modbus_init()
      
        
          | void modbus_init | ( | uint8_t | address | ) |  | 
      
 
Initializes this Modbus library.
Initialize pins, timer, serial port and variables. Interrupts MUST be initialized for the timer and the serial port.
- Parameters
- 
  
    | address | : the Modbus address of this device |  
 
- See also
- modbus_char_recvd 
- 
modbus_timer 
- 
interrupts.c 
Definition at line 108 of file modbus.c.
 
 
◆ modbus_send()
      
        
          | void modbus_send | ( | uint8_t | length | ) |  | 
      
 
Send the Modbus frame on tx_buf with CRC added
- Parameters
- 
  
    | length | : length of the frame without the CRC |  
 
Definition at line 92 of file modbus.c.
 
 
◆ modbus_timer()
      
        
          | void modbus_timer | ( | void |  | ) |  | 
      
 
Modbus timer finished. This function is called by the interrupt handler when a MODBUS frame is finished. It must analyse the received packet and reply if required.
- See also
- interrupts.c 
Definition at line 33 of file modbus.c.
 
 
◆ holding_registers
      
        
          | uint16_t holding_registers[2] | 
      
 
 
◆ input_registers
      
        
          | uint16_t input_registers[2] | 
      
 
 
◆ modbusAddress
◆ recPtr
◆ rx_buf
Buffers for serial receive and send operations which are more than one byte long 
Definition at line 27 of file modbus.c.
 
 
◆ tx_buf