Home

Awesome

vserialx

vserialx is a tiny library for serial communication in Linux using V.

Usage

module main

import time
import vserialx as vs

fn main() {
	mut dev := vs.new('/dev/ttyS20', .b9600, .@none, .@none, .one, .char8b)

	mut rc := dev.open()

	if rc != .okay {
		println('Failed to open.\nERROR: ${rc}')
		return
	}
	defer {
		dev.close()
	}

	rc = dev.open()
	if rc != .okay {
		println('Failed to connect.\nERROR: ${rc}')
		return
	}

	for {
		if dev.available_bytes() > 0 {
			len, buff, rt := dev.read(10)
			dump(rt)
			if len > 0 {
				println('BUFF: {${buff.hex()}}')
			}
		}
		time.sleep(time.second)
	}
}

TODO features

TODO testings