Giter VIP home page Giter VIP logo

ioctl-rs's Introduction

IOCTL

The ioctl-rs crate provides raw definitions as well as safe bindings for system ioctl calls on Unix operating systems. The ioctl constants, e.g., TIOCEXCL, are exported as constants that are usable with the unsafe ioctl() function. Wrapper functions are provided for some ioctls that handle input and output parameters and convert return values to io::Result. The wrapper functions are named after the ioctl that they implement. For example, TIOCEXCL is implemented in a wrapper function named tiocexcl().

Usage

Add ioctl-rs as a dependency in Cargo.toml:

[dependencies]
ioctl-rs = "0.2"

Import the ioctl_rs crate. You may also need std::os::unix::io::RawFd for file descriptors and std::io::Result to propagate errors.

extern crate ioctl_rs as ioctl;

use std::io
use std::os::unix::io::RawFd;

fn setup_serial_port(fd: RawFd) -> io::Result<()> {
    // put file descriptor in exclusive mode
    try!(ioctl::tiocexcl(fd));

    // clear all the modem pins
    ioctl::tiocmset(fd, 0)
}

Contributing

This repository includes a C++ program called ioctl_list, which generates Rust definitions for ioctl constants. To contribute ioctl definitions for a new platform or to add new ioctl definitions, please follow the instructions in the ioctl_list README.

Contributors

License

Copyright © 2015 David Cuddeback

Distributed under the MIT License.

ioctl-rs's People

Contributors

dcuddeback avatar dcz-purism avatar mneumann avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.