Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds RTS & DTR support to the PL2303 driver #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PL2303SerialDevice extends UsbSerialDevice
(byte) 0x08 // [6] Data Bits (5=5, 6=6, 7=7, 8=8)
};

private int rtsDtrState = 0x0000;

private final UsbInterface mInterface;
private UsbEndpoint inEndpoint;
Expand Down Expand Up @@ -273,13 +274,27 @@ public void setBreak(boolean state)
@Override
public void setRTS(boolean state)
{
//TODO
if(state)
{
rtsDtrState |= (1 << 1);
}else
{
rtsDtrState &= ~(1 << 1);
}
setControlCommand(PL2303_REQTYPE_HOST2DEVICE, PL2303_SET_CONTROL_REQUEST, rtsDtrState, 0, null);
}

@Override
public void setDTR(boolean state)
{
//TODO
if(state)
{
rtsDtrState |= (1 << 0);
}else
{
rtsDtrState &= ~(1 << 0);
}
setControlCommand(PL2303_REQTYPE_HOST2DEVICE, PL2303_SET_CONTROL_REQUEST, rtsDtrState, 0, null);
}

@Override
Expand Down Expand Up @@ -368,10 +383,11 @@ else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
if(setControlCommand(PL2303_REQTYPE_HOST2DEVICE_VENDOR, PL2303_VENDOR_WRITE_REQUEST, 0x0002, 0x0044, null) < 0)
return false;
// End of specific vendor stuff
if(setControlCommand(PL2303_REQTYPE_HOST2DEVICE, PL2303_SET_CONTROL_REQUEST, 0x0003, 0,null) < 0)
return false;
//if(setControlCommand(PL2303_REQTYPE_HOST2DEVICE, PL2303_SET_CONTROL_REQUEST, 0x0000, 0, null) < 0)
if(setControlCommand(PL2303_REQTYPE_HOST2DEVICE, PL2303_SET_LINE_CODING, 0x0000, 0, defaultSetLine) < 0)
return false;
if(setControlCommand(PL2303_REQTYPE_HOST2DEVICE, PL2303_SET_CONTROL_REQUEST, rtsDtrState, 0, null) < 0)
return false;
if(setControlCommand(PL2303_REQTYPE_HOST2DEVICE_VENDOR, PL2303_VENDOR_WRITE_REQUEST, 0x0505, 0x1311, null) < 0)
return false;

Expand Down