car_fmw: add route response, blink in start and end task

This commit is contained in:
e5l
2016-08-19 17:00:01 +03:00
parent 6b18367692
commit 02f1c05599
3 changed files with 12 additions and 2 deletions
+10
View File
@@ -7,6 +7,8 @@ enum class RouteType(val id: Int) {
} }
object Control { object Control {
val BLINK_DURATION = 1000
fun run() { fun run() {
Memory.setHeap(Memory.DYNAMIC_HEAP) Memory.setHeap(Memory.DYNAMIC_HEAP)
while (true) { while (true) {
@@ -17,10 +19,16 @@ object Control {
fun executeCommand() { fun executeCommand() {
val task = Reader.readTask() val task = Reader.readTask()
Leds.blink()
Time.wait(BLINK_DURATION)
when (task.type.id) { when (task.type.id) {
TaskRequest.Type.DEBUG.id -> debugTask() TaskRequest.Type.DEBUG.id -> debugTask()
TaskRequest.Type.ROUTE.id -> routeTask() TaskRequest.Type.ROUTE.id -> routeTask()
} }
Leds.blink()
Time.wait(BLINK_DURATION)
} }
fun debugTask() { fun debugTask() {
@@ -54,6 +62,8 @@ object Control {
j++ j++
} }
val response = RouteResponse.BuilderRouteResponse(0).build()
Writer.writeRoute(response)
} }
fun sendMemoryStats() { fun sendMemoryStats() {
+1 -1
View File
@@ -21,7 +21,7 @@ object Reader {
} }
object Writer { object Writer {
fun writeRoute(route: RouteRequest) { fun writeRoute(route: RouteResponse) {
val stream = makeOutputStream(route.getSizeNoTag()) val stream = makeOutputStream(route.getSizeNoTag())
route.writeTo(stream) route.writeTo(stream)
Connection.sendByteArray(stream.buffer) Connection.sendByteArray(stream.buffer)
+1 -1
View File
@@ -39,6 +39,6 @@ object Connection {
fun sendByteArray(array: ByteArray) { fun sendByteArray(array: ByteArray) {
car_conn_snd_int(array.size) car_conn_snd_int(array.size)
car_conn_rcv_buf(array.size, array.data) car_conn_snd_buf(array.size, array.data)
} }
} }