blob: 985513bd78835b142459e4950c86354faba5f017 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package com.github.jodersky.flow
package example
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Success
import scala.util.Try
import com.github.jodersky.flow.Serial
import com.github.jodersky.flow.Serial._
import akka.actor.ActorSystem
import akka.actor.Props
import akka.io.IO
import akka.util.ByteString
import com.github.jodersky.flow.internal.InternalSerial
object Main {
def main(args: Array[String]): Unit = {
/*val isInt = Try(args(1).toInt) match { case Success(_) => true; case _ => false }
if (!(args.length == 2 && isInt)) {
println("invalid parameters")
println("parameters: port baud")
println("example: /dev/ttyACM0 115200")
return
}*/
val port = "/dev/ttyACM0"
val baud = 115200
// InternalSerial.debug(true)
implicit val system = ActorSystem("flow")
val serial = system.actorOf(Props(classOf[SerialHandler], port, baud), name = "serial-handler")
readLine()
serial ! ByteString("hello back".getBytes())
readLine()
serial ! "close"
readLine()
system.shutdown()
}
}
|