aboutsummaryrefslogtreecommitdiff
path: root/scala/jssc/src/main/scala/com/github/jodersky/ace/Main.scala
blob: 55c23b9f674005ef81a7f3e2a2bc38d1adf9bcec (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
package com.github.jodersky.ace

import com.github.jodersky.ace.protocol._

import scala.concurrent.ExecutionContext.Implicits.global

object Main {
  
  def main(args: Array[String]): Unit = {
    import com.github.jodersky.ace.jssc._
    
    val s = serial.Serial.open("/dev/ttyACM0", 9600)
    val framer = new Framer
    val arq = new Arq(200)
    val app = new SimpleActionLayer((s: Seq[Int]) => println(s))
    
    s connect framer connect arq connect app
    s.begin()
    
    while (true) {
      app.send(Console.readLine.getBytes().map(_.toInt)).map(sent => Console.println("> " + sent))
      
    }
      
    
    ()
  }
  

}