728x90

어떤 칩셋은 정상동작하고 어떤 칩셋은 오동작이 발생한거 같다.

코드 사용 위치가 잘못되어 발생한 거 아닌가 싶다.


sendCommand() 는 Control transfer를 사용하여 Device로 Data를 보낸다.
UsbDeviceConnection.controlTransfer() 를 사용하여야 한다.

controlTransfer()의 proto type을 보면
public int controlTransfer (int requestType, int request, int value, int index, byte[] buffer, int length, int timeout)
requestType    request type for this transaction
request        request ID for this transaction
value        value field for this transaction
index        index field for this transaction
buffer        buffer for data portion of transaction, or null if no data needs to be sent or received
length        the length of the data to send or receive
timeout        in milliseconds


// for more info, search SET_LINE_CODING and SET_CONTROL_LINE_STATE in the document:
// "Universal Serial Bus Class Definitions for Communication Devices"

final int RQSID_SET_LINE_CODING = 0x20;
final int RQSID_SET_CONTROL_LINE_STATE = 0x22;

int usbResult;
usbResult = usbDeviceConnection.controlTransfer(0x21, // requestType
        RQSID_SET_CONTROL_LINE_STATE, // SET_CONTROL_LINE_STATE
        0, // value
        0, // index
        null, // buffer
        0, // length
        0); // timeout

// baud rate = 9600, 8 data bit, 1 stop bit
byte[] encodingSetting = new byte[] { (byte) 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 };
usbResult = usbDeviceConnection.controlTransfer(0x21, // requestType
        RQSID_SET_LINE_CODING, // SET_LINE_CODING
        0, // value
        0, // index
        encodingSetting, // buffer
        7, // length
        0); // timeout



블로그 이미지

Link2Me

,