manual:modbus_rtu_demo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
manual:modbus_rtu_demo [2023/12/04 21:32]
voorburg created
manual:modbus_rtu_demo [2023/12/04 22:07] (current)
voorburg
Line 75: Line 75:
 The example assumes that the S-record of the demo user program is located in the same directory as where the BootCommander executable itself resides. If not, then simply prepend the absolute (or relative) directory to the name of the S-record firmware file. The example assumes that the S-record of the demo user program is located in the same directory as where the BootCommander executable itself resides. If not, then simply prepend the absolute (or relative) directory to the name of the S-record firmware file.
  
 +===== RS485 transceiver management =====
 +
 +You can use RS232 or RS485 as the physical communication link for firmware updates via Modbus RTU. In the case of RS485, your system will feature an RS485 transceiver. Most RS485 transceivers require you to explicitly enable and disable the transmitter/​receiver using a microcontroller digital output.
 +
 +You can implement this logic in hook-function ''​MbRtuDriverOutputControlHook()''​ in "​hooks.c"​. You can copy-paste this template function as a starting point:
 +
 +<code c>
 +/​************************************************************************************//​**
 +** \brief ​    ​Controls the state of the DE/NRE GPIO pin on an RS485 transceiver.
 +** \param ​    ​enable When enable is BLT_TRUE, the pin should go logic high to enable the
 +**            driver output. When enable is BLT_FALSE, the pin should go logic low to
 +**            enable the receiver input.
 +** \return ​   none.
 +**
 +****************************************************************************************/​
 +void MbRtuDriverOutputControlHook(blt_bool enable)
 +{
 +  /* Should the driver output be enabled (transmit)? */
 +  if (enable == BLT_TRUE)
 +  {
 +    /* TODO If needed, set DE and NRE pins to high to enable the driver output. */
 +  }
 +  /* The receiver output should be enabled (receive). */
 +  else
 +  {
 +    /* TODO If needed, set DE and NRE pins to low to enable the receiver input. */
 +  }
 +} /*** end of MbRtuDriverOutputControlHook ***/
 +</​code>​
 +
 +Note that when using RS232 as the communication link, you still need to implement this function to prevent a linker error. Yet, you can use the empty template as specified above.
  
 ===== Notes ===== ===== Notes =====
manual/modbus_rtu_demo.1701721969.txt.gz · Last modified: 2023/12/04 21:32 by voorburg