Добавление флага write в MB_DefineRegistersAddress
И рефакторинг дефайнов размеров сообщения
This commit is contained in:
@@ -40,7 +40,7 @@ MB_ExceptionTypeDef MB_Holding_Write_Global(uint16_t Addr, uint16_t WriteVal)
|
||||
uint16_t *pHoldRegs;
|
||||
|
||||
//------------WRITE COIL-------------
|
||||
Exception = MB_DefineRegistersAddress(&pHoldRegs, Addr, 1, RegisterType_Holding);
|
||||
Exception = MB_DefineRegistersAddress(&pHoldRegs, Addr, 1, RegisterType_Holding, 1);
|
||||
if(Exception == ET_NO_ERRORS)
|
||||
{
|
||||
*(pHoldRegs) = WriteVal;
|
||||
@@ -66,7 +66,7 @@ uint16_t MB_Holding_Read_Global(uint16_t Addr, MB_ExceptionTypeDef *Exception)
|
||||
uint16_t *pHoldRegs;
|
||||
|
||||
//------------READ COIL--------------
|
||||
Exception_tmp = MB_DefineRegistersAddress(&pHoldRegs, Addr, 1, RegisterType_Holding);
|
||||
Exception_tmp = MB_DefineRegistersAddress(&pHoldRegs, Addr, 1, RegisterType_Holding, 0);
|
||||
|
||||
if(Exception) // if exception is not given to func fill it
|
||||
*Exception = Exception_tmp;
|
||||
@@ -94,7 +94,7 @@ uint8_t MB_Process_Read_Hold_Regs(RS_MsgTypeDef *modbus_msg)
|
||||
//---------CHECK FOR ERRORS----------
|
||||
// get origin address for data
|
||||
uint16_t *pHoldRegs;
|
||||
modbus_msg->Except_Code = MB_DefineRegistersAddress(&pHoldRegs, modbus_msg->Addr, modbus_msg->Qnt, RegisterType_Holding); // определение адреса регистров
|
||||
modbus_msg->Except_Code = MB_DefineRegistersAddress(&pHoldRegs, modbus_msg->Addr, modbus_msg->Qnt, RegisterType_Holding, 0); // определение адреса регистров
|
||||
if(modbus_msg->Except_Code != ET_NO_ERRORS)
|
||||
return 0;
|
||||
|
||||
@@ -121,7 +121,7 @@ uint8_t MB_Process_Write_Single_Reg(RS_MsgTypeDef *modbus_msg)
|
||||
{
|
||||
// get origin address for data
|
||||
uint16_t *pHoldRegs;
|
||||
modbus_msg->Except_Code = MB_DefineRegistersAddress(&pHoldRegs, modbus_msg->Addr, 1, RegisterType_Holding); // определение адреса регистров
|
||||
modbus_msg->Except_Code = MB_DefineRegistersAddress(&pHoldRegs, modbus_msg->Addr, 1, RegisterType_Holding, 1); // определение адреса регистров
|
||||
if(modbus_msg->Except_Code != ET_NO_ERRORS)
|
||||
return 0;
|
||||
|
||||
@@ -146,7 +146,7 @@ uint8_t MB_Process_Write_Miltuple_Regs(RS_MsgTypeDef *modbus_msg)
|
||||
}
|
||||
// get origin address for data
|
||||
uint16_t *pHoldRegs;
|
||||
modbus_msg->Except_Code = MB_DefineRegistersAddress(&pHoldRegs, modbus_msg->Addr, modbus_msg->Qnt, RegisterType_Holding); // определение адреса регистров
|
||||
modbus_msg->Except_Code = MB_DefineRegistersAddress(&pHoldRegs, modbus_msg->Addr, modbus_msg->Qnt, RegisterType_Holding, 1); // определение адреса регистров
|
||||
if(modbus_msg->Except_Code != ET_NO_ERRORS)
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user