diff options
Diffstat (limited to 'flow-main/src/main')
4 files changed, 11 insertions, 3 deletions
diff --git a/flow-main/src/main/scala/com/github/jodersky/flow/Parity.scala b/flow-main/src/main/scala/com/github/jodersky/flow/Parity.scala new file mode 100644 index 0000000..9a0d3ac --- /dev/null +++ b/flow-main/src/main/scala/com/github/jodersky/flow/Parity.scala @@ -0,0 +1,8 @@ +package com.github.jodersky.flow + +object Parity extends Enumeration { + type Parity = Value + val None = Value(0) + val Odd = Value(1) + val Even = Value(2) +}
\ No newline at end of file diff --git a/flow-main/src/main/scala/com/github/jodersky/flow/Serial.scala b/flow-main/src/main/scala/com/github/jodersky/flow/Serial.scala index 6e4aefb..bff0ad0 100644 --- a/flow-main/src/main/scala/com/github/jodersky/flow/Serial.scala +++ b/flow-main/src/main/scala/com/github/jodersky/flow/Serial.scala @@ -10,7 +10,7 @@ object Serial extends ExtensionKey[SerialExt] { trait Command trait Event - case class Open(handler: ActorRef, port: String, baud: Int) extends Command + case class Open(handler: ActorRef, port: String, baud: Int, characterSize: Int = 8, twoStopBits: Boolean = false, parity: Parity.Parity = Parity.None) extends Command case class Opened(port: String) extends Event case class OpenFailed(port: String, reason: Throwable) extends Event diff --git a/flow-main/src/main/scala/com/github/jodersky/flow/SerialManager.scala b/flow-main/src/main/scala/com/github/jodersky/flow/SerialManager.scala index 688ae3c..1a38ef5 100644 --- a/flow-main/src/main/scala/com/github/jodersky/flow/SerialManager.scala +++ b/flow-main/src/main/scala/com/github/jodersky/flow/SerialManager.scala @@ -29,7 +29,7 @@ class SerialManager extends Actor with ActorLogging { } def receive = { - case Open(handler, port, baud) => Try { InternalSerial.open(port, baud) } match { + case Open(handler, port, baud, cs, tsb, parity) => Try { InternalSerial.open(port, baud, cs, tsb, parity.id) } match { case Failure(t) => { log.debug(s"failed to open low serial port at ${port}, baud ${baud}, reason: " + t.getMessage()) handler ! OpenFailed(port, t) diff --git a/flow-main/src/main/scala/com/github/jodersky/flow/internal/InternalSerial.scala b/flow-main/src/main/scala/com/github/jodersky/flow/internal/InternalSerial.scala index f3e08b8..fd5aaa4 100644 --- a/flow-main/src/main/scala/com/github/jodersky/flow/internal/InternalSerial.scala +++ b/flow-main/src/main/scala/com/github/jodersky/flow/internal/InternalSerial.scala @@ -76,7 +76,7 @@ object InternalSerial { } /** Open a new connection to a serial port. */ - def open(port: String, baud: Int, characterSize: Int = 8, twoStopBits: Boolean = false, parity: Int = 0): InternalSerial = synchronized { + def open(port: String, baud: Int, characterSize: Int, twoStopBits: Boolean, parity: Int): InternalSerial = synchronized { val pointer = new Array[Long](1) except(NativeSerial.open(port, baud, characterSize, twoStopBits, parity, pointer), port) new InternalSerial(port, pointer(0)) |