Solar panel
Loading...
Searching...
No Matches
modbus.h File Reference

Modbus serial library. More...

#include <stdint.h>

Go to the source code of this file.

Functions

void modbus_init (uint8_t address)
 
uint8_t modbus_analyse_and_answer (void)
 
void modbus_send (uint8_t length)
 
void modbus_char_recvd (void)
 
void modbus_timer (void)
 

Variables

uint8_t modbusAddress
 
uint16_t input_registers [2]
 
uint16_t holding_registers [2]
 

Detailed Description

Modbus serial library.

Definition in file modbus.h.

Function Documentation

◆ 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.

Variable Documentation

◆ holding_registers

uint16_t holding_registers[2]
extern

Definition at line 14 of file modbus.c.

◆ input_registers

uint16_t input_registers[2]
extern

Definition at line 13 of file modbus.c.

◆ modbusAddress

uint8_t modbusAddress
extern

Definition at line 12 of file modbus.c.