car_fmw: add route response, blink in start and end task
This commit is contained in:
@@ -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() {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user