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

implementation of 'rtu_set_custom_rts' #18

Open
fel115 opened this issue Jul 3, 2023 · 2 comments
Open

implementation of 'rtu_set_custom_rts' #18

fel115 opened this issue Jul 3, 2023 · 2 comments

Comments

@fel115
Copy link

fel115 commented Jul 3, 2023

I require the activation of 2 pins in the high state during transmission, and in the low state for receiving. To achieve this, I need to utilize the 'rtu_set_custom_rts' function. Alternatively, is there another approach to accomplish the same task?

@fel115
Copy link
Author

fel115 commented Jul 5, 2023

This is the link to the documentation

@fel115
Copy link
Author

fel115 commented Jul 6, 2023

our custom rts-function should look like the following code. fd_273 and fd_272 are the file-descriptor to our PINs which should be set.

void set_rts_custom(modbus_t *ctx, int on){
    if (on){
        if (write(fd_272, "1", 1) != 1) {
            perror("Error writing to /sys/class/gpio/gpio272/value");
            exit(1);
        }
        if (write(fd_273, "1", 1) != 1) {
            perror("Error writing to /sys/class/gpio/gpio273/value");
            exit(1);
        }
    }else{
        if (write(fd_272, "0", 1) != 1) {
            perror("Error writing to /sys/class/gpio/gpio272/value");
            exit(1);
        }
        if (write(fd_273, "0", 1) != 1) {
            perror("Error writing to /sys/class/gpio/gpio273/value");
            exit(1);
        }
    }
}

This works fine in C, but we would like to use this function also in Rust

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

No branches or pull requests

1 participant