Petit Modbus 2.0
|
#include "PetitModbus.h"
Go to the source code of this file.
Macros | |
#define | PETITMODBUS_READ_COILS (1) |
#define | PETITMODBUS_READ_DISCRETE_INPUTS (2) |
#define | PETITMODBUS_READ_HOLDING_REGISTERS (3) |
#define | PETITMODBUS_READ_INPUT_REGISTERS (4) |
#define | PETITMODBUS_WRITE_SINGLE_COIL (5) |
#define | PETITMODBUS_WRITE_SINGLE_REGISTER (6) |
#define | PETITMODBUS_WRITE_MULTIPLE_COILS (15) |
#define | PETITMODBUS_WRITE_MULTIPLE_REGISTERS (16) |
#define | PETIT_FALSE_FUNCTION (0) |
#define | PETIT_FALSE_SLAVE_ADDRESS (1) |
#define | PETIT_DATA_NOT_READY (2) |
#define | PETIT_DATA_READY (3) |
#define | PETIT_ERROR_CODE_01 (0x01) |
#define | PETIT_ERROR_CODE_02 (0x02) |
#define | PETIT_ERROR_CODE_03 (0X03) |
#define | PETIT_ERROR_CODE_04 (0x04) |
#define | PETIT_BUF_FN_CODE_I (1) |
#define | PETIT_BUF_BYTE_CNT_I (6) |
#define | PETIT_BUF_DAT_M(Idx) |
Functions | |
void | PetitRxBufferReset () |
pb_t | PetitRxBufferInsert (pu8_t rcvd) |
pb_t | PetitTxBufferPop (pu8_t *tx) |
void | Petit_CRC16_Calc (const pu16_t Data) |
pb_t | PetitSendMessage (void) |
void | HandlePetitModbusError (pu8_t ErrorCode) |
pu8_t | CheckPetitModbusBufferComplete (void) |
void | Petit_RxRTU (void) |
void | Petit_TxRTU (void) |
void | Petit_ResponseProcess (void) |
void | ProcessPetitModbus (void) |
Variables | |
PETIT_RXTX_STATE | Petit_RxTx_State = PETIT_RXTX_RX |
pu8_t | PetitBuffer [PETITMODBUS_RXTX_BUFFER_SIZE] |
pu16_t | Petit_CRC16 = 0xFFFF |
pu16_t | PetitBufI = 0 |
pu16_t | PetitBufJ = 0 |
pu8_t * | Petit_Ptr = &PetitBuffer[0] |
pu16_t | Petit_Tx_Delay = 0 |
pu16_t | PetitExpectedReceiveCount = 0 |
This file contains the core of PetitModbus.
Definition in file PetitModbus.c.
#define PETIT_BUF_BYTE_CNT_I (6) |
Definition at line 31 of file PetitModbus.c.
#define PETIT_BUF_DAT_M | ( | Idx | ) |
This macro extracts the contents of the buffer at index as a 16-bit unsigned integer
Definition at line 36 of file PetitModbus.c.
#define PETIT_BUF_FN_CODE_I (1) |
Definition at line 30 of file PetitModbus.c.
#define PETIT_DATA_NOT_READY (2) |
Definition at line 22 of file PetitModbus.c.
#define PETIT_DATA_READY (3) |
Definition at line 23 of file PetitModbus.c.
#define PETIT_ERROR_CODE_01 (0x01) |
Definition at line 25 of file PetitModbus.c.
#define PETIT_ERROR_CODE_02 (0x02) |
Definition at line 26 of file PetitModbus.c.
#define PETIT_ERROR_CODE_03 (0X03) |
Definition at line 27 of file PetitModbus.c.
#define PETIT_ERROR_CODE_04 (0x04) |
Definition at line 28 of file PetitModbus.c.
#define PETIT_FALSE_FUNCTION (0) |
Definition at line 20 of file PetitModbus.c.
#define PETIT_FALSE_SLAVE_ADDRESS (1) |
Definition at line 21 of file PetitModbus.c.
#define PETITMODBUS_READ_COILS (1) |
Definition at line 10 of file PetitModbus.c.
#define PETITMODBUS_READ_DISCRETE_INPUTS (2) |
Definition at line 11 of file PetitModbus.c.
#define PETITMODBUS_READ_HOLDING_REGISTERS (3) |
Definition at line 12 of file PetitModbus.c.
#define PETITMODBUS_READ_INPUT_REGISTERS (4) |
Definition at line 13 of file PetitModbus.c.
#define PETITMODBUS_WRITE_MULTIPLE_COILS (15) |
Definition at line 16 of file PetitModbus.c.
#define PETITMODBUS_WRITE_MULTIPLE_REGISTERS (16) |
Definition at line 17 of file PetitModbus.c.
#define PETITMODBUS_WRITE_SINGLE_COIL (5) |
Definition at line 14 of file PetitModbus.c.
#define PETITMODBUS_WRITE_SINGLE_REGISTER (6) |
Definition at line 15 of file PetitModbus.c.
CheckPetitModbusBufferComplete | ( | void | ) |
Definition at line 586 of file PetitModbus.c.
void HandlePetitModbusError | ( | pu8_t | ErrorCode | ) |
Definition at line 172 of file PetitModbus.c.
void Petit_CRC16_Calc | ( | const pu16_t | Data | ) |
Definition at line 126 of file PetitModbus.c.
Petit_ResponseProcess | ( | void | ) |
This function processes the modbus response once it has been determined that the message is for this node and the length is correct.
Definition at line 696 of file PetitModbus.c.
Petit_RxRTU | ( | void | ) |
Check for data ready, if it is good return answer
Definition at line 630 of file PetitModbus.c.
Petit_TxRTU | ( | void | ) |
If data is ready send answers!
Definition at line 672 of file PetitModbus.c.
Inserts bits into the buffer on device receive.
[in] | rcvd | the byte to insert into the buffer |
Definition at line 75 of file PetitModbus.c.
void PetitRxBufferReset | ( | void | ) |
Reset the modbus buffer.
This function is called by the interrupt code that handles byte to byte time overrun. It is also called by the validation function to reject data that is not for this device before more system resources are taken.
Definition at line 62 of file PetitModbus.c.
PetitSendMessage | ( | void | ) |
This function starts to send messages.
Definition at line 157 of file PetitModbus.c.
This function removes a byte from the buffer and places it on "tx" to be sent over rs485.
[out] | tx |
Definition at line 94 of file PetitModbus.c.
ProcessPetitModbus | ( | void | ) |
ModBus main core! Call this function into main!
Definition at line 750 of file PetitModbus.c.
pu16_t Petit_CRC16 = 0xFFFF |
Definition at line 42 of file PetitModbus.c.
pu8_t* Petit_Ptr = &PetitBuffer[0] |
Definition at line 48 of file PetitModbus.c.
PETIT_RXTX_STATE Petit_RxTx_State = PETIT_RXTX_RX |
Definition at line 40 of file PetitModbus.c.
pu16_t Petit_Tx_Delay = 0 |
Definition at line 50 of file PetitModbus.c.
pu8_t PetitBuffer[PETITMODBUS_RXTX_BUFFER_SIZE] |
Definition at line 41 of file PetitModbus.c.
pu16_t PetitBufI = 0 |
Definition at line 45 of file PetitModbus.c.
pu16_t PetitBufJ = 0 |
Definition at line 46 of file PetitModbus.c.
pu16_t PetitExpectedReceiveCount = 0 |
Definition at line 52 of file PetitModbus.c.