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

switched to modbus_new_tcp_pi #50

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

switched to modbus_new_tcp_pi #50

wants to merge 4 commits into from

Conversation

v-zhuravlev
Copy link
Owner

would implement #48 when done

@v-zhuravlev v-zhuravlev force-pushed the dns branch 14 times, most recently from 48274bc to ec48acc Compare September 24, 2018 09:53
@v-zhuravlev
Copy link
Owner Author

v-zhuravlev commented Sep 24, 2018

DNS is now supported in both TCP and RTU over TCP modes. Latter is supported thanks to @myssta version of the patch I merged into v-zhuravlev/libmodbus.
Here are the tests that checks that DNS resolution is working:

https://github.com/v-zhuravlev/libzbxmodbus/blob/dns/tests/test_00modbus_connection_string.py#L23-L31

TCP port may also be redefined (from Modbus default 502) if needed: `enc://192.168.1.1:5000`

Note: DNS names are not supported for TCP and RTU over TCP
TCP port may also be redefined (from Modbus default 502) if needed: `enc://192.168.1.1:5000`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces. :)

@@ -449,30 +454,34 @@ void create_modbus_context(char *con_string, modbus_t **ctx_out, int *lock_requi

char host[100];
int port = MODBUS_TCP_DEFAULT_PORT;
char port_str[10];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sprintf()ing MAX_INT can overflow this buffer.

@@ -449,30 +454,34 @@ void create_modbus_context(char *con_string, modbus_t **ctx_out, int *lock_requi

char host[100];
int port = MODBUS_TCP_DEFAULT_PORT;
char port_str[10];

if (strncmp(con_string, "enc://", strlen("enc://")) == 0)
{
*lock_required_out = 1;
con_string += strlen("enc://");
sscanf(con_string, "%99[^:]:%99d[^\n]", host, &port);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just read port as %s?

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.

2 participants