File tree Expand file tree Collapse file tree 3 files changed +399
-1
lines changed Expand file tree Collapse file tree 3 files changed +399
-1
lines changed Original file line number Diff line number Diff line change @@ -25,4 +25,17 @@ pub fn build(b: *std.build.Builder) void {
25
25
});
26
26
list_exe .addModule ("serial" , serial_mod );
27
27
b .installArtifact (list_exe );
28
+
29
+ // TODO: Linux and MacOS port info support
30
+ const os_tag = list_exe .target_info .target .os .tag ;
31
+ if (os_tag == .windows ) {
32
+ const port_info_exe = b .addExecutable (.{
33
+ .name = "serial-list-info" ,
34
+ .root_source_file = .{ .path = "examples/list_port_info.zig" },
35
+ .target = target ,
36
+ .optimize = optimize ,
37
+ });
38
+ port_info_exe .addModule ("serial" , serial_mod );
39
+ b .installArtifact (port_info_exe );
40
+ }
28
41
}
Original file line number Diff line number Diff line change
1
+ const std = @import ("std" );
2
+ const zig_serial = @import ("serial" );
3
+
4
+ pub fn main () ! u8 {
5
+ var iterator = try zig_serial .list_info ();
6
+ defer iterator .deinit ();
7
+
8
+ while (try iterator .next ()) | info | {
9
+ std .debug .print ("\n Port name: {s}\n " , .{info .port_name });
10
+ std .debug .print (" - System location: {s}\n " , .{info .system_location });
11
+ std .debug .print (" - Friendly name: {s}\n " , .{info .friendly_name });
12
+ std .debug .print (" - Description: {s}\n " , .{info .description });
13
+ std .debug .print (" - Manufacturer: {s}\n " , .{info .manufacturer });
14
+ std .debug .print (" - Serial #: {s}\n " , .{info .serial_number });
15
+ std .debug .print (" - HW ID: {s}\n " , .{info .hw_id });
16
+ std .debug .print (" - VID: 0x{X:0>4} PID: 0x{X:0>4}\n " , .{ info .vid , info .pid });
17
+ }
18
+
19
+ return 0 ;
20
+ }
You can’t perform that action at this time.
0 commit comments