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

Odd parity not available for Modbus RTU slave (IDFGH-4560) #6377

Closed
devward opened this issue Jan 10, 2021 · 4 comments
Closed

Odd parity not available for Modbus RTU slave (IDFGH-4560) #6377

devward opened this issue Jan 10, 2021 · 4 comments

Comments

@devward
Copy link

devward commented Jan 10, 2021

Hi,

Odd parity is not supported in slave rtu mode (maybe master as well, I didn't check). When trying to set the parity to UART_PARITY_ODD the esp32 fails:
MB_CONTROLLER_SLAVE: mbc_serial_slave_setup(79): mb wrong parity option = (0x3)

I saw in the last commit of the files esp-idf/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.c and esp-idf/components/freemodbus/port/portserial.c the code checks that the parity is not higher than UART_PARITY_EVEN which would be 0x02 in lines 78 and 187 respectively. I modified the checks and ran the app again, got no error but it wouldn't work with odd parity.

Commit: 66fb5a29bbdc2482d67c52e6f66b303378c9b789

What is the reason for no odd parity?

@github-actions github-actions bot changed the title Odd parity not available for Modbus RTU slave Odd parity not available for Modbus RTU slave (IDFGH-4560) Jan 10, 2021
@alisitsyn
Copy link
Collaborator

Hi @devward,

Thank you for this issue. This happens because of incorrect propagation of parity options from modbus controller to xMBMasterPortSerialInit() (xMBPortSerialInit) function due to changes in the UART driver. In order to keep compatibility with previous code and fix this issue I propose the patch attached:

0002_fix_mb_controller_parity_ussue.patch.log

Please check if this fixes the issue. Thanks.

@alisitsyn
Copy link
Collaborator

Hi @DevArd,

Could you check the fix and confirm that it works in your case?
The MR is reviwed and will be ready to be merged as soon as you confirm the result.

@devward
Copy link
Author

devward commented Jan 26, 2021

Hi @alisitsyn

Sorry for my late reply, I only tested it on one device and it worked but as we remove odd parity from our latest release we haven't tested it properly.

Cheers

@alisitsyn
Copy link
Collaborator

@devward ,
Thank you for update.

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

No branches or pull requests

2 participants