diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-06-28 19:59:55 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-06-28 19:59:55 +0200 |
commit | 1e123c3670209132fa82cf02e95b8425a0c070aa (patch) | |
tree | f424d4f26191ac0fedbfd5416f0835ea6453cf93 /hw | |
parent | 8a08b9dce9cfc161494ddb07a1c979c7796780ff (diff) | |
download | microcopterd-1e123c3670209132fa82cf02e95b8425a0c070aa.tar.bz2 |
implement atmostripe motor controller
Diffstat (limited to 'hw')
-rw-r--r-- | hw/serial-device.vala | 27 |
1 files changed, 26 insertions, 1 deletions
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; + } } |