aromajoin / controller-sdk-java

Enable developers to connect and control Aroma Shooter.
https://aromajoin.com/software/sdk
Apache License 2.0
4 stars 0 forks source link

Example hangs if Arduino is connected to computer #2

Open danielle-h opened 2 years ago

danielle-h commented 2 years ago

I have an Arduino Leonardo connected to my computer. If the Arduino is connected but there is no program that is currently communicating with it, the example program will hang.

It seems to hang at String serial = SerialReader.query(ASConnection.USB, serialPort); (USBAController, line 74) It queries the serial port and waits indefinitely for an answer.

If there is a program that is communicating with the Arduino in parallel to running the example program, the example program runs without issue.

I am using VSCode 1.63.2 On Windows 10 Pro 10.0.19042. Arduino board is Arduino Leonardo java version "1.8.0_321" Using AromaShooter ASN2A00306

danielle-h commented 2 years ago

Additional information: When running on a Raspberry Pi with an Arduino Due connected, the program doesn't hang but outputs the following error:

com.fazecast.jSerialComm.SerialPortTimeoutException: The write operation timed out before all data was written.
        at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:1470)
        at com.fazecast.jSerialComm.SerialPort$SerialPortOutputStream.write(SerialPort.java:1449)
        at com.aromajoin.sdk.jvm.SerialReader.query(SerialReader.java:33)
        at com.aromajoin.sdk.jvm.usb.USBASController.scanAndConnect(USBASController.java:74)
        at com.example.App.main(App.java:22)

And the program continues, connecting to the the Aroma Shooter successfully.

hanh-aj commented 2 years ago

Hi @danielle-h,

Thanks for reporting the issue. It seems like the SDK sent UART command too soon when Arduino is not ready. Could you check if it's related to this link? https://forum.arduino.cc/t/jserialcomm-serial-communication-with-arduino-uno-fails/589181/11

danielle-h commented 2 years ago

I did a few more trials on the Windows computer. If at the beginning the Arduino is physically connected (with a cable) but no program has opened a connection to the Arduino, then your SDK, in ScanAndConnect, opens a connection to the Arduino and the program runs to completion (so it doesn't look connected to the link). The second time the program is run (after your program has already opened a connection and closed it) the program will hang. I assume it's because the Arduino now expects some other input. But why is your program opening a connection to the Arduino in the first place? Is there a way to direct the usbController to connect only to the Aroma Shooter? using the serial number or the COM port? I couldn't find a function that does this.

danielle-h commented 2 years ago

On Windows, Bluetooth serial link also causes example to hang. Temporary workaround is to go to Device Manager --> Ports and disable any ports called "Standard Serial over Bluetooth Link"