Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix modbus master exemple #2288

Merged
merged 1 commit into from
Feb 17, 2024
Merged

fix modbus master exemple #2288

merged 1 commit into from
Feb 17, 2024

Conversation

JorgeGzm
Copy link
Contributor

Summary

The modbus master exemplo stop to work before the PR #6038

Impact

Fix modbus master example.

Testing

# config target to use the mosbus master example
$tools/configure.sh stm32f401rc-rs485:modbus_master

# run diagslave app to start a modbus slave
$ sudo diagslave -a 10 -b 38400 /dev/ttyUSB0

# on target execute the modbus master exemple
nsh> modbusmaster
Initializing modbus master...
Creating poll thread.
Sending 100 requests to slave 10
mbmaster_main: Exiting poll thread.
Modbus master statistics:
Requests count:  100
Responses count: 100
Errors count:    0
Deinitializing modbus master...

@xiaoxiang781216
Copy link
Contributor

@JorgeGzm more error need to be fixed:
https://github.com/apache/nuttx/actions/runs/7923388468/job/21633084117?pr=11698
BTW, please fix this warning:

Error: /home/runner/work/nuttx-apps/nuttx-apps/apps/examples/modbusmaster/mbmaster_main.c:300:1: error: Missing blank line after comment

@xiaoxiang781216
Copy link
Contributor

@JorgeGzm you need fix more:

Error: mb_m.c:301:15: error: 4 enumeration values not handled in switch: 'EV_MASTER_PROCESS_SUCCESS', 'EV_MASTER_ERROR_RESPOND_TIMEOUT', 'EV_MASTER_ERROR_RECEIVE_DATA'... [-Werror,-Wswitch]
  301 |       switch (eEvent)
      |               ^~~~~~
1 error generated.
make[2]: *** [/github/workspace/sources/apps/Application.mk:200: mb_m.c.github.workspace.sources.apps.modbus.o] Error 1
Error: mbmaster_main.c:284:15: error: data argument not used by format string [-Werror,-Wformat-extra-args]
  283 |       fprintf(stderr, "mbmaster_main: ",
      |                       ~~~~~~~~~~~~~~~~~
  284 |               "ERROR: mbmaster_initialize failed: %d\n", ret);
      |               ^
Error: mbmaster_main.c:296:15: error: data argument not used by format string [-Werror,-Wformat-extra-args]
  295 |       fprintf(stderr, "mbmaster_main: ",
      |                       ~~~~~~~~~~~~~~~~~
  296 |               "ERROR: mbmaster_pollthread create failed: %d\n", ret);
      |               ^
2 errors generated.
make[2]: *** [/github/workspace/sources/apps/Application.mk:271: mbmaster_main.c.github.workspace.sources.apps.examples.modbusmaster.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:51: /github/workspace/sources/apps/examples/modbusmaster_all] Error 2
Error: rtu/mbrtu_m.c:281:30: error: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'int8_t *' (aka 'signed char *') converts between pointers to integer types with different sign [-Werror,-Wpointer-sign]
  281 |   xMBMasterPortSerialGetByte((uint8_t *) & ucByte);
      |                              ^~~~~~~~~~~~~~~~~~~~
/github/workspace/sources/apps/include/modbus/mbport.h:149:42: note: passing argument to parameter 'pucByte' here
  149 | bool xMBMasterPortSerialGetByte(int8_t * pucByte);
      |                                          ^
Error: rtu/mbrtu_m.c:352:11: error: enumeration value 'STATE_M_TX_XFWR' not handled in switch [-Werror,-Wswitch]
  352 |   switch (eSndState)
      |           ^~~~~~~~~
2 errors generated.
make[2]: *** [/github/workspace/sources/apps/Application.mk:200: mbrtu_m.c.github.workspace.sources.apps.modbus.o] Error 1
Error: nuttx/porttimer_m.c:117:30: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
  117 | void xMBMasterPortTimersClose()
      |                              ^
      |                               void
Error: nuttx/porttimer_m.c:171:32: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
  171 | void vMBMasterPortTimersDisable()
      |                                ^
      |                                 void

@JorgeGzm
Copy link
Contributor Author

JorgeGzm commented Feb 16, 2024

@xiaoxiang781216

What was the make command that you used to show the error message ?

make -j -Wall ?

@xiaoxiang781216 xiaoxiang781216 merged commit 49204e1 into apache:master Feb 17, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modbus Master example was broken by PR #6038
2 participants