11/****************************************************************************
2- * apps/examples/modbus/main .c
2+ * apps/examples/modbus/modbus_main .c
33 *
44 * Licensed to the Apache Software Foundation (ASF) under one or more
55 * contributor license agreements. See the NOTICE file distributed with
@@ -140,7 +140,10 @@ static void modbus_showusage(FAR const char *progname, int exitcode);
140140 ****************************************************************************/
141141
142142static struct modbus_state_s g_modbus ;
143- static const uint8_t g_slaveid [] = { 0xaa , 0xbb , 0xcc };
143+ static const uint8_t g_slaveid [] =
144+ {
145+ 0xaa , 0xbb , 0xcc
146+ };
144147
145148/****************************************************************************
146149 * Private Functions
@@ -191,7 +194,8 @@ static inline int modbus_initialize(void)
191194 */
192195
193196 mberr = eMBInit (MB_RTU , 0x0a , CONFIG_EXAMPLES_MODBUS_PORT ,
194- CONFIG_EXAMPLES_MODBUS_BAUD , CONFIG_EXAMPLES_MODBUS_PARITY );
197+ CONFIG_EXAMPLES_MODBUS_BAUD ,
198+ CONFIG_EXAMPLES_MODBUS_PARITY );
195199 if (mberr != MB_ENOERR )
196200 {
197201 fprintf (stderr , "modbus_main: "
@@ -231,6 +235,7 @@ static inline int modbus_initialize(void)
231235 return OK ;
232236
233237errout_with_modbus :
238+
234239 /* Release hardware resources. */
235240
236241 eMBClose ();
@@ -376,7 +381,8 @@ static inline int modbus_create_pollthread(void)
376381
377382 if (g_modbus .threadstate == STOPPED )
378383 {
379- ret = pthread_create (& g_modbus .threadid , NULL , modbus_pollthread , NULL );
384+ ret = pthread_create (& g_modbus .threadid , NULL ,
385+ modbus_pollthread , NULL );
380386 }
381387 else
382388 {
@@ -444,7 +450,8 @@ int main(int argc, FAR char *argv[])
444450 if (ret != OK )
445451 {
446452 fprintf (stderr , "modbus_main: "
447- "ERROR: modbus_create_pollthread failed: %d\n" , ret );
453+ "ERROR: modbus_create_pollthread failed: %d\n" ,
454+ ret );
448455 exit (EXIT_FAILURE );
449456 }
450457 }
@@ -536,8 +543,8 @@ eMBErrorCode eMBRegInputCB(uint8_t *buffer, uint16_t address, uint16_t nregs)
536543 *
537544 ****************************************************************************/
538545
539- eMBErrorCode eMBRegHoldingCB (uint8_t * buffer , uint16_t address , uint16_t nregs ,
540- eMBRegisterMode mode )
546+ eMBErrorCode eMBRegHoldingCB (uint8_t * buffer , uint16_t address ,
547+ uint16_t nregs , eMBRegisterMode mode )
541548{
542549 eMBErrorCode mberr = MB_ENOERR ;
543550 int index ;
@@ -551,6 +558,7 @@ eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address, uint16_t nregs,
551558 switch (mode )
552559 {
553560 /* Pass current register values to the protocol stack. */
561+
554562 case MB_REG_READ :
555563 while (nregs > 0 )
556564 {
@@ -592,8 +600,8 @@ eMBErrorCode eMBRegHoldingCB(uint8_t *buffer, uint16_t address, uint16_t nregs,
592600 *
593601 ****************************************************************************/
594602
595- eMBErrorCode eMBRegCoilsCB (uint8_t * buffer , uint16_t address , uint16_t ncoils ,
596- eMBRegisterMode mode )
603+ eMBErrorCode eMBRegCoilsCB (uint8_t * buffer , uint16_t address ,
604+ uint16_t ncoils , eMBRegisterMode mode )
597605{
598606 eMBErrorCode mberr = MB_ENOERR ;
599607 int index ;
@@ -649,7 +657,8 @@ eMBErrorCode eMBRegCoilsCB(uint8_t *buffer, uint16_t address, uint16_t ncoils,
649657 *
650658 ****************************************************************************/
651659
652- eMBErrorCode eMBRegDiscreteCB (uint8_t * buffer , uint16_t address , uint16_t ndiscrete )
660+ eMBErrorCode eMBRegDiscreteCB (uint8_t * buffer , uint16_t address ,
661+ uint16_t ndiscrete )
653662{
654663 return MB_ENOREG ;
655664}
0 commit comments