-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: master
Are you sure you want to change the base?
Conversation
48274bc
to
ec48acc
Compare
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. |
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` |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
would implement #48 when done