add default callback on read (just print bytes). fixed closing write stream after first write
This commit is contained in:
@@ -10,9 +10,10 @@ class McTransport() {
|
|||||||
private var callback: (bytes: ByteArray) -> Unit = {}
|
private var callback: (bytes: ByteArray) -> Unit = {}
|
||||||
|
|
||||||
fun writeToFile(bytes: ByteArray) {
|
fun writeToFile(bytes: ByteArray) {
|
||||||
|
println("writewrite uiii!")
|
||||||
val bytesT = bytes
|
val bytesT = bytes
|
||||||
writeStream.write(js("new Buffer(bytesT)"));
|
writeStream.write(js("new Buffer(bytesT)"));
|
||||||
writeStream.end();
|
// writeStream.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
fun writeToFile(byte: Byte) {
|
fun writeToFile(byte: Byte) {
|
||||||
@@ -45,6 +46,7 @@ class McTransport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun closeStreams() {
|
fun closeStreams() {
|
||||||
|
writeStream.end()
|
||||||
writeStream = null
|
writeStream = null
|
||||||
readStream = null
|
readStream = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ class MicroController private constructor() {
|
|||||||
|
|
||||||
this.transportFilePath = "./testTtyAcm"//todo need init
|
this.transportFilePath = "./testTtyAcm"//todo need init
|
||||||
mcTransport.initStreams(transportFilePath)
|
mcTransport.initStreams(transportFilePath)
|
||||||
|
mcTransport.setCallBack { bytes ->
|
||||||
|
println("read: " + bytes.toString())
|
||||||
|
}
|
||||||
|
|
||||||
setInterval({ this.car.refreshLocation(deltaTimeLocationRefresh) }, deltaTimeLocationRefresh);
|
setInterval({ this.car.refreshLocation(deltaTimeLocationRefresh) }, deltaTimeLocationRefresh);
|
||||||
setInterval({
|
setInterval({
|
||||||
|
|||||||
Reference in New Issue
Block a user