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

see issue #131 (problem talking to sigrok over tcp) #133

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

folkertvanheusden
Copy link
Contributor

The problem of the fragmented *IDN? response can be mitigated somewhat by enabling nagle during the response to that command.

by enabling nagle during the response to that command.
@folkertvanheusden folkertvanheusden changed the title see issue #17 see issue #133 Nov 18, 2021
@folkertvanheusden folkertvanheusden changed the title see issue #133 see issue #131 (problem talking to sigrok over tcp) Nov 18, 2021
@j123b567
Copy link
Owner

I can't test it in now, but isn't it also necessary to explicitly flush the output so we are sure, that the concatenated message is send immediately?

https://stackoverflow.com/questions/855544/is-there-a-way-to-flush-a-posix-socket

Also in case of Linux, TCP_CORK would be probably a better choice. (And subsequent toggeling in flush callback)

@folkertvanheusden
Copy link
Contributor Author

folkertvanheusden commented Nov 19, 2021

I've tested in a toy-project of mine, and TCP_CORK also solves it:

size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
        if (context->user_context != NULL) {
                int fd = ((audio_dev_t *)context->user_context)->fd;

                int state = 1;
                setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));

                return write(fd, data, len);
        }

        return 0;
}

scpi_result_t SCPI_Flush(scpi_t * context) {
        if (context->user_context != NULL) {
                int fd = ((audio_dev_t *)context->user_context)->fd;

                int state = 0;
                setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
        }

        return SCPI_RES_OK;
}

Thanks for the help!

@j123b567 j123b567 merged commit 97a4bf6 into j123b567:master Jan 16, 2023
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