add default callback on read (just print bytes). fixed closing write stream after first write

This commit is contained in:
MaximZaitsev
2016-08-16 17:06:06 +03:00
parent 4c24366c54
commit 65baf23daa
2 changed files with 6 additions and 1 deletions
+3 -1
View File
@@ -10,9 +10,10 @@ class McTransport() {
private var callback: (bytes: ByteArray) -> Unit = {}
fun writeToFile(bytes: ByteArray) {
println("writewrite uiii!")
val bytesT = bytes
writeStream.write(js("new Buffer(bytesT)"));
writeStream.end();
// writeStream.end();
}
fun writeToFile(byte: Byte) {
@@ -45,6 +46,7 @@ class McTransport() {
}
fun closeStreams() {
writeStream.end()
writeStream = null
readStream = null
}
+3
View File
@@ -37,6 +37,9 @@ class MicroController private constructor() {
this.transportFilePath = "./testTtyAcm"//todo need init
mcTransport.initStreams(transportFilePath)
mcTransport.setCallBack { bytes ->
println("read: " + bytes.toString())
}
setInterval({ this.car.refreshLocation(deltaTimeLocationRefresh) }, deltaTimeLocationRefresh);
setInterval({