diff options
author | Jakob Odersky <jodersky@gmail.com> | 2013-06-18 23:55:38 +0200 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2013-06-18 23:55:38 +0200 |
commit | 892bd6053aff21cda2fbabddb824c9710d7baafa (patch) | |
tree | 2cff8af70946110fbb7c6e3a1d695c800b434733 /src/main | |
parent | 98241aa830bedb006ae041dce661afd57c3d90a8 (diff) | |
download | akka-serial-892bd6053aff21cda2fbabddb824c9710d7baafa.tar.gz akka-serial-892bd6053aff21cda2fbabddb824c9710d7baafa.tar.bz2 akka-serial-892bd6053aff21cda2fbabddb824c9710d7baafa.zip |
repair broken example
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/native/flow.c | 1 | ||||
-rw-r--r-- | src/main/scala/com/github/jodersky/flow/Framing.scala (renamed from src/main/scala/com/github/jodersky/flow/Framing.scalac) | 0 | ||||
-rw-r--r-- | src/main/scala/com/github/jodersky/flow/Serial.scala (renamed from src/main/scala/com/github/jodersky/flow/Serial.scalac) | 2 | ||||
-rw-r--r-- | src/main/scala/com/github/jodersky/flow/SerialManager.scala (renamed from src/main/scala/com/github/jodersky/flow/SerialManager.scalac) | 2 | ||||
-rw-r--r-- | src/main/scala/com/github/jodersky/flow/SerialOperator.scala (renamed from src/main/scala/com/github/jodersky/flow/SerialOperator.scalac) | 24 |
5 files changed, 20 insertions, 9 deletions
diff --git a/src/main/native/flow.c b/src/main/native/flow.c index 09ffca6..ca91468 100644 --- a/src/main/native/flow.c +++ b/src/main/native/flow.c @@ -205,6 +205,7 @@ int serial_read(struct serial_config* serial, unsigned char * buffer, size_t siz } return r; } else { + DEBUG(printf("poll pipe result %d\n", pp.revents)); return E_CLOSE; } } diff --git a/src/main/scala/com/github/jodersky/flow/Framing.scalac b/src/main/scala/com/github/jodersky/flow/Framing.scala index f8173a7..f8173a7 100644 --- a/src/main/scala/com/github/jodersky/flow/Framing.scalac +++ b/src/main/scala/com/github/jodersky/flow/Framing.scala diff --git a/src/main/scala/com/github/jodersky/flow/Serial.scalac b/src/main/scala/com/github/jodersky/flow/Serial.scala index 7182425..1eacd6e 100644 --- a/src/main/scala/com/github/jodersky/flow/Serial.scalac +++ b/src/main/scala/com/github/jodersky/flow/Serial.scala @@ -22,7 +22,7 @@ object Serial extends ExtensionKey[SerialExt] { case class Wrote(data: ByteString) extends Event case object Close extends Command - + case object Closed extends Event case class CommandFailed(command: Command, reason: Throwable) extends Event diff --git a/src/main/scala/com/github/jodersky/flow/SerialManager.scalac b/src/main/scala/com/github/jodersky/flow/SerialManager.scala index ca3fc6b..4af2f9a 100644 --- a/src/main/scala/com/github/jodersky/flow/SerialManager.scalac +++ b/src/main/scala/com/github/jodersky/flow/SerialManager.scala @@ -19,7 +19,7 @@ class SerialManager extends Actor { val operator = context.actorOf(Props(classOf[SerialOperator], serial, handler), name = escapePortString(port)) handler ! Opened(operator) } - case Failure(t) => sender ! CommandFailed(command, t) + case Failure(t) => handler ! CommandFailed(command, t) }) } diff --git a/src/main/scala/com/github/jodersky/flow/SerialOperator.scalac b/src/main/scala/com/github/jodersky/flow/SerialOperator.scala index 21d2067..6177188 100644 --- a/src/main/scala/com/github/jodersky/flow/SerialOperator.scalac +++ b/src/main/scala/com/github/jodersky/flow/SerialOperator.scala @@ -13,18 +13,26 @@ import scala.concurrent._ class SerialOperator(serial: LowSerial, handler: ActorRef) extends Actor { import context._ - - context.watch(handler) - class Reader extends Actor { - while (true) { - val data = ByteString(serial.read()) - handler ! Received(data) + object Reader extends Thread { + private var continueReading = true + + override def run() { + while (continueReading) { + println("beginning read") + val data = ByteString(serial.read()) + println("return from read") + handler ! Received(data) + } } } + + Reader.start() + + context.watch(handler) def receive = { - case Write(data) => { + case c @ Write(data) => { val writer = sender future{serial.write(data.toArray)}.onComplete { case Success(data) => writer ! Wrote(ByteString(data)) @@ -33,6 +41,8 @@ class SerialOperator(serial: LowSerial, handler: ActorRef) extends Actor { } case Close => { + serial.close() + sender ! Closed context.stop(self) } } |