Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Library for configuring and listing serial ports.

## What version of Zig to use

Zig 0.15.1
Zig 0.15.2

## Example

Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.name = .serial,
.version = "0.0.1",
.minimum_zig_version = "0.15.1",
.minimum_zig_version = "0.15.2",
.fingerprint = 0xd374c9dccc91873e,
.paths = .{
"src", // all files in src directory
Expand Down
3 changes: 2 additions & 1 deletion examples/echo.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const std = @import("std");
const builtin = @import("builtin");
const zig_serial = @import("serial");

pub fn main() !u8 {
const port_name = if (@import("builtin").os.tag == .windows) "\\\\.\\COM1" else "/dev/ttyUSB0";
const port_name = if (builtin.os.tag == .windows) "\\\\.\\COM1" else "/dev/ttyUSB0";

var serial = std.fs.cwd().openFile(port_name, .{ .mode = .read_write }) catch |err| switch (err) {
error.FileNotFound => {
Expand Down
8 changes: 7 additions & 1 deletion src/serial.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const std = @import("std");
const builtin = @import("builtin");
const c = @cImport(@cInclude("termios.h"));
// note: inf: POSIX specific
const c = switch (builtin.target.os.tag) {
.linux, .macos => @cImport({
@cInclude("termios.h");
}),
else => struct {},
};
const Io = std.Io;

pub fn list() !PortIterator {
Expand Down