µTasker Forum > MODBUS

MODBUS IP to serial (RTU) gateway

<< < (3/3)

kiryat8:
I found that _HW_TIMER_MODE was not defined. It is used only in ADC_Timers.h fnConfigure_Timer() and in debug.c fnTestTCPServer() in the test project.

A few other questions:
1) When I enable the HTTP server demo together with USE_MODBUS , I can not upload ftp files and the web pages are destroyed. I guess that the fnGetMODBUS_parameters() in modbus_app.c needs to be changed somehow.
I use a SPI_FLASH_SST25VF080B external flash chip which works fine.

2) Our application uses a Modbus RTU slave along with a Modbus TCP slave accessing the exact same data.
My defined Modbus registers are in several address ranges so I guess that I set the second parameter in the fnInitialiseMODBUS_port() function to NULL and I will get notified in the fnMODBUSuserFunction callback?
I must manually send a reply with fnMODBUS_transmit and return zero if all is correct?
Do you have a code snippet example. We use mainly Rd/Wr Holding registers.

Thanks

mark:
Hi

1) I don't understand why enabling the MODBUS module is affecting FTP and the web server. MODBUS adds extra sockets and requires extra memory so it may be an idea to check the memory utilisation (see the command "memory" in command line menu "statistics").
There are extra MODBUS parameters added when the MODBUS operation is enabled but the version number of the parameters is also modified so that a previous unmatching set is reset back to default values, which means that there should be no problems enabling and disabling MODBUS (in that parameter mismatch causes errors).

2) There are several ways to handle MODBUS registers (you could use one address range that is handled automatically and anothers (outside of this) that are handled by the call back (event USER_RECEIVING_MISSED_RANGE). Entering a zero for parameters will mean that all receptions provoke the callback and all handling is also in the user callback (event USER_RECEIVING_ALL_MODBUS_DATA).
fnMODBUSuserFunction() in modbus_app.c shows a few handling cases, such as gatewaying certain register addresses to different ports. It also shows handling the function code MODBUS_READ_COILS and returning a response using the fnMODBUS_transmit() function.
*modbus_rx_function also contains information about the port that the request arrived on so the handing could be made different if there should be certain dependencies (such as one port not having write access rights).
When working with automatic registers multiple ports can access them. Special handling (such as port dependencies) can be performed in fnMODBUSPreFunction() which is a callback just before a register read. The callback fnMODBUSPostFunction() is handled after a MODBUS write has been executed.
If you have various ranges in the registers (rather than a single block of addresses) it may still be possible to define a single (larger) block of registers/memory and use the pre- and post.- callbacks just to signal exceptions if the addresses accessed were not legal addresses (it requires more memory for the complete set of registers but allows the majority of handling to be performed by the function handling in the MODBUS code itself).

Regards

Mark

Navigation

[0] Message Index

[*] Previous page

Go to full version