From 1e123c3670209132fa82cf02e95b8425a0c070aa Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Thu, 28 Jun 2012 19:59:55 +0200 Subject: implement atmostripe motor controller --- hw/serial-device.vala | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/serial-device.vala b/hw/serial-device.vala index bbd7698..cff68b9 100644 --- a/hw/serial-device.vala +++ b/hw/serial-device.vala @@ -13,8 +13,33 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +public errordomain SerialError { + IO_ERROR, + ERRNO, +} + public class SerialDevice : Device { + private int fd; + + public void setup(string device) throws SerialError { + fd = Posix.open(device, Posix.O_RDWR); + + if(fd < 0) + throw new SerialError.IO_ERROR("Could not open device!"); + + /* TODO */ + } + + ~I2CDevice() { + Posix.close(fd); + } - /* TODO */ + protected ssize_t read(void *buf, size_t count) { + return Posix.read(fd, buf, count); + } + protected ssize_t write(void *buf, size_t count) { + ssize_t size = Posix.write(fd, buf, count); + return size; + } } -- cgit v1.2.3