Skip to content

switched to modbus_new_tcp_pi - #50

Open
v-zhuravlev wants to merge 4 commits into
masterfrom
dns
Open

switched to modbus_new_tcp_pi#50
v-zhuravlev wants to merge 4 commits into
masterfrom
dns

Conversation

@v-zhuravlev

Copy link
Copy Markdown
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

v-zhuravlev commented Sep 24, 2018

Copy link
Copy Markdown
Owner Author

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

Comment thread README.md
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Trailing spaces. :)

Comment thread src/modbus.c

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

Copy link
Copy Markdown
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.

Comment thread src/modbus.c
{
*lock_required_out = 1;
con_string += strlen("enc://");
sscanf(con_string, "%99[^:]:%99d[^\n]", host, &port);

Copy link
Copy Markdown
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