summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-06-28 19:59:55 +0200
committerSebastian Reichel <sre@ring0.de>2012-06-28 19:59:55 +0200
commit1e123c3670209132fa82cf02e95b8425a0c070aa (patch)
treef424d4f26191ac0fedbfd5416f0835ea6453cf93 /hw
parent8a08b9dce9cfc161494ddb07a1c979c7796780ff (diff)
downloadmicrocopterd-1e123c3670209132fa82cf02e95b8425a0c070aa.tar.bz2
implement atmostripe motor controller
Diffstat (limited to 'hw')
-rw-r--r--hw/serial-device.vala27
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;
+ }
}