diff options
author | Jakob Odersky <jodersky@gmail.com> | 2013-02-26 17:14:53 +0100 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2013-02-26 17:14:53 +0100 |
commit | 77db2136559ccef7d84cf6c0fd0166a970224680 (patch) | |
tree | 4addef09cfaa1567a952ed3b0522ecd26f96df75 /scala/ace/src/main/scala/com/github/jodersky/ace/protocol/SecureSerial.scala | |
parent | 03edd62b745f225075fab0d96e0ec93f96c3466c (diff) | |
download | ace-77db2136559ccef7d84cf6c0fd0166a970224680.tar.gz ace-77db2136559ccef7d84cf6c0fd0166a970224680.tar.bz2 ace-77db2136559ccef7d84cf6c0fd0166a970224680.zip |
restructure scala directory in view of providing seperate projects for serial implementations
Diffstat (limited to 'scala/ace/src/main/scala/com/github/jodersky/ace/protocol/SecureSerial.scala')
-rw-r--r-- | scala/ace/src/main/scala/com/github/jodersky/ace/protocol/SecureSerial.scala | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/scala/ace/src/main/scala/com/github/jodersky/ace/protocol/SecureSerial.scala b/scala/ace/src/main/scala/com/github/jodersky/ace/protocol/SecureSerial.scala new file mode 100644 index 0000000..e229b82 --- /dev/null +++ b/scala/ace/src/main/scala/com/github/jodersky/ace/protocol/SecureSerial.scala @@ -0,0 +1,22 @@ +package com.github.jodersky.ace.protocol + +import jssc.SerialPort +import scala.concurrent.ExecutionContext.Implicits.global +import scala.util.Try + +class SecureSerial(port: SerialPort) { self => + val physical = new PhysicalLayer(port) + val link = new LinkLayer + val transport = new TransportLayer + + val application = new ReactiveLayer[Message, String] { + def receive(message: Message) = Console.println(message.data.mkString("")) + def write(s: String) = writeToLower(Message(s.map(_.toInt))).map(x => s) + } + + def send(s: String) = application.write(s) + def close() = Try(port.closePort()) + + physical connect link connect transport connect application + physical.begin() +}
\ No newline at end of file |