mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.9k stars 1.59k forks source link

setDtr/setRTS is not implemented for FTDI imll #13

Closed mik3y closed 4 years ago

mik3y commented 11 years ago

From d...@antonsmirnov.name on March 16, 2013 23:18:49

What steps will reproduce the problem? 1. invoke setDtr/setRts (true) What is the expected output? What do you see instead? Expected it to set to true, but nothing happens What version of the product are you using? On what operating system? Please provide any additional information below. Just not implemented in FtdiSerialDriver class

Original issue: http://code.google.com/p/usb-serial-for-android/issues/detail?id=13

mik3y commented 11 years ago

From d...@antonsmirnov.name on March 17, 2013 01:00:22

this links can be helpful: http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_147_Java_D2xx_for_Android.pdf http://code.google.com/p/android-ftdi-usb2serial-driver-package/

mik3y commented 11 years ago

From die...@gmail.com on July 05, 2013 14:54:22

I've implemented setDTR to reset my Arduino.

This is how it works for me: public void setDTR(boolean value) throws IOException { int SET_CONTROL_LINE_STATE=0x1; int DTR_HIGH =257; int DTR_LOW=256; int result = mConnection.controlTransfer(FTDI_DEVICE_OUT_REQTYPE, SET_CONTROL_LINE_STATE, value?DTR_HIGH:DTR_LOW, 0 /* index */, null, 0, USB_WRITE_TIMEOUT_MILLIS);

    if (result != 0) {
         throw new IOException("Setting DTR failed: result=" + result);
    }
}
egueli commented 9 years ago

The code above works also for Parallax RFID reader (https://www.parallax.com/product/28340): it needs to be enabled before reading tag IDs.

aroller commented 9 years ago

I would benefit from the setRTS method being implemented when communicating with the iRobot Create 2. See this exchange.

mik3y commented 9 years ago

I'm hoping to spend some time this weekend given this project some much needed love. Help (especially in the form of ready-to-go-PRs) would be very welcome, either on this issue or others!

aroller commented 9 years ago

Mike, that's great. I'm more of a high level programmer, but I'm happy to help where I can. The specs for the iRobot Create 2 is the primary source. I'm just learning it now myself. Here is the excerpt that relates to the BRC pin:

In Passive mode, Roomba will go into power saving mode to conserve battery power after five minutes of inactivity. To disable sleep, pulse the BRC pin low periodically before these five minutes expire. Each pulse resets this five minute counter. (One example that would not cause the baud rate to inadvertently change is to pulse the pin low for one second, every minute, but there are other periods and duty cycles that would work, as well.)

So perhaps pulsing pin 5 (BRC) is capable now without the setRTS feature enabled? If so, please provide some instructions and I will make an attempt with the current library snapshot.

Per Steve on Robotics Stack Exchange, who's profile shows he helped launch the Create 2, I won't need to send a pulse if the Ready to Send state is enabled (since the iRobot provided cable does some magic apparently). So using the RTS would be the preferred method.

My goal is actually to wake it up rather than keep it awake, however, it would seem the RTS feature would assist with that too.

I realize this information may not be that helpful to you mostly due to my lack of understanding serial communications protocol. Steve could provide more insight than me, but once you have a snapshot I'd be happy to test and debug the implementation.

Again, thanks for the very useful library.

kai-morich commented 4 years ago

solved with #118