Callback function used if a Coil Register value is read or written by the protocol stack. If you is going to use this function you might use the Functions xmbutilsetbits ( ) and xmbutilgetbits () for working with Bitfields. If the protocol stack needs to read and write to the coil status register, the callback function needs to be called. If the user uses this feature, the user may use xmbutilsetbits () and xmbutilgetbits () to handle bit fields. Parameters: parameters
|
Pucregbuffer |
The bits was packed in bytes where the first coil starting at address usaddress was stored in the LSB of the first byte in The buffer pucregbuffer. If the buffer should be written by the callback function unused coil values (i.e. if not a multiple of eight coils ) should is set to zero. Bits make up one byte, and the corresponding bits of the starting register are in the lowest bit lsb of the byte pucregbuffer. If the callback function is to write this buffer, the number of bits that are not used in the coil (for example, the coil state of the 8 group) must be set to bit 0. |
|
USAddress |
The first coil number. First Coil Address |
|
Usncoils |
Number of coil values requested. Number of coils requested |
|
Emode |
If embregistermode::mb_reg_write The application values should is updated from the values supplied in the buffer Pucregbuffer. If Embregistermode::mb_reg_read The application should store the current values in the buffer pucregbuffer. If this parameter is embregistermode::mb_reg_write, the user's app value will be updated from Pucregbuffer. If the parameter is embregistermode::mb_reg_read, the user needs to store the current app data in Pucregbuffer. |
Returns: back The function must return one of the following error codes: This function will return the following error code: · Emberrorcode::mb_enoerr If no error occurred. In this case a normal Modbus response is sent. Emberrorcode::mb_enoerr If no error occurs. In this case, send a normal modbus response. · Emberrorcode::mb_enoreg If the application does not a map an coils within the requested address range. A illegal DATA ADDRESS is sent as a response. Emberrorcode::mb_enoreg If there is no coil status register in the requested address range, in this case a illegal DATA address response is sent. · Emberrorcode::mb_etimedout If The requested register block is currently isn't available and the application dependent response timeout would be violate D. In the case a SLAVE DEVICE BUSY exception is sent as a response. Emberrorcode::mb_etimedout If the requested register area is currently invalid and the application related should time out. In this case, send a SLAVE DEVICE BUSY answer. · Emberrorcode::mb_eio If an unrecoverable error occurred. In the case a SLAVE DEVICE FAILURE exception is sent as a response. Emberrorcode::mb_eio If a different error occurs. In this case, send a SLAVE DEVICE FAILURE answer. Examples: Example at91sam7x_rowley/demo.c, avr/demo.c, linux/demo.c, |