Hi! Im using Arduino Uno port /dev/ttyACM0, but when i write in Serial this error appears.
fun main(args: Array<String>) {
val arduinoController = ArduinoController("/dev/ttyACM0", 9600)
arduinoController.init()
arduinoController.write(1)
}
import com.fazecast.jSerialComm.SerialPort
import java.io.OutputStream
class ArduinoController (private val port: String, private val taxTransfer: Int) {
private lateinit var serialPort: SerialPort
private lateinit var serialOut: OutputStream
fun init() {
serialPort = SerialPort.getCommPort(port)
serialPort.openPort()
serialPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0)
serialOut = serialPort.outputStream
}
fun write(int: Int) {
println("Writted $port")
serialOut.write(int)
}
}
Error:
lms5413@LM /m/n/C/A/b/libs [1]> java -jar ArduinoKt.jar
Writted /dev/ttyACM0
Exception in thread "main" com.fazecast.jSerialComm.SerialPortIOException: This port appears to have been shutdown or disconnected.
at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:2060)
at ArduinoController.write(ArduinoController.kt:17)
at MainKt.main(Main.kt:4)
Hi! Im using Arduino Uno port /dev/ttyACM0, but when i write in Serial this error appears.
Error:
In Arduino IDE, this port appears.