I am new to android programming smart card detection (read). We have RFC card reader(RFID-RC522) connected to the android device using otg cable. RFC Card reader is detected using usb-serial port api, but unable to read card from RFC card reader. We have implemented card reading in java but unable to implement in android.
1) How to get port number equivalent to windows COM ports
2) If it is not possible, how can I communicate using connection.controlTransfer(UsbConstants.USB_DIR_OUT, 0x00, 0x0000, 0, null, 0, 0); method
3) Java Code for Connecting Device
static int connect ( String portName ) throws IOException
{
CommPortIdentifier portIdentifier = null;
try {
portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
} catch (NoSuchPortException e) {
System.out.println("Port " + portName + " is not available");
}
if ( portIdentifier.isCurrentlyOwned() )
{
System.out.println("Error: Port " + portName + " is currently in use");
}
else
{
CommPort commPort = null;
try {
commPort = portIdentifier.open(portName,2000);
} catch (PortInUseException e) {
System.out.println("Error: Port " + portName + " is currently in use");
}
System.out.println("Info: Port Availble "+portName);
if ( commPort instanceof SerialPort )
{
SerialPort serialPort = (SerialPort) commPort;
try {
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {
System.out.println("Error: Port " + portName + " is currently in use");
}
InputStreamIn = serialPort.getInputStream();
OutputStreamOut = serialPort.getOutputStream();
return 0;
}
else
{
//System.out.println("Error: Only serial ports are handled by this example.");
System.out.println("Error: Port " + portName + " is currently in use");
}
}
return -1;
}
4) Please tell me how on android can I communicate like on java