eMBInit() function
Initialize the Modbus protocol stack. This functions initializes the ASCII or RTU module and calls the init functions of the porting layer to prepare the hardware. Please note that the receiver is still disabled and no Modbus frames are processed until eMBEnable( ) has been called.
Arguments
eMode
If ASCII or RTU mode should be used.
ucSlaveAddress
The slave address. Only frames sent to this address or to the broadcast address are processed.
ucPort
The port to use. E.g. 1 for COM1 on windows. This value is platform dependent and some ports simply choose to ignore it.
ulBaudRate
The baudrate. E.g. 19200. Supported baudrates depend on the porting layer.
eParity
Parity used for serial transmission.
Return value
If no error occurs the function returns eMBErrorCode::MB_ENOERR. The protocol is then in the disabled state and ready for activation by calling eMBEnable( ). Otherwise one of the following error codes is returned: - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid slave addresses are in the range 1 - 247. - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error.