GithubHelp home page GithubHelp logo

serial's Introduction

Zig Serial Port Library

Library for configuring and listing serial ports.

Features

  • Basic serial port configuration
    • Baud Rate
    • Parity (none, even, odd, mark, space)
    • Stop Bits (one, two)
    • Handshake (none, hardware, software)
    • Byte Size (5, 6, 7, 8)
  • Flush serial port send/receive buffers
  • List available serial ports
  • API: supports Windows, Linux and Mac

Example

// Port configuration.
// Serial ports are just files, \\.\COM1 for COM1 on Windows:
var serial = try std.fs.cwd().openFile("\\\\.\\COM1", .{ .mode = .read_write }) ;
defer serial.close();

try zig_serial.configureSerialPort(serial, zig_serial.SerialConfig{
    .baud_rate = 19200,
    .word_size = 8,
    .parity = .none,
    .stop_bits = .one,
    .handshake = .none,
});

Usage

Library integration

Integrate the library in your project via the Zig package manager:

  • add serial to your .zig.zon file by providing the URL to the archive of a tag or specific commit of the library
  • to update the hash, run zig fetch --save [URL/to/tag/or/commit.tar.gz]

Running tests

The build.zig file contains a test step that can be called with zig build test. Note that this requires a serial port to be available on the system;

  • Linux: /dev/ttyUSB0
  • Mac: /dev/cu.usbmodem101
  • Windows: COM3

Building the examples

You can build the examples from the ./examples directory by calling zig build examples. Binaries will be generated in ./zig-out/bin by default.

  • Note that the list_port_info example currently only works on Windows

serial's People

Contributors

ikskuh avatar fobersteiner avatar lachlanm-git avatar bogdanthegeek avatar superauguste avatar cohors1316 avatar elpekenin avatar desttinghim avatar mookums avatar sleepywill avatar charlesokwuagwu avatar sergpolkin 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.