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

resolve segment fault and Error on modbus connection #62

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/linux/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void disconnect(void* conn) {
// Read/write/sleep platform functions

int32_t read_fd_linux(uint8_t* buf, uint16_t count, int32_t timeout_ms, void* arg) {
if(!arg) return -1;
int fd = *(int*) arg;

uint16_t total = 0;
Expand All @@ -192,7 +193,7 @@ int32_t read_fd_linux(uint8_t* buf, uint16_t count, int32_t timeout_ms, void* ar
ssize_t r = read(fd, buf + total, 1);
if (r == 0) {
disconnect(arg);
return -1;
return 0;
}

if (r < 0)
Expand Down
2 changes: 2 additions & 0 deletions examples/linux/server-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ int main(int argc, char* argv[]) {
if (conn) {
// Set the next connection handler used by the read/write platform functions
nmbs_set_platform_arg(&nmbs, conn);
}else{
continue;
}

err = nmbs_server_poll(&nmbs);
Expand Down
Loading