How to list the Connected USB Port Number using Vendor id and product id using java -
what best api in java display connected usb port number using vendor id , product id?
you can list serial ports using simple javax.comm
api
import javax.comm.*; import java.util.enumeration; public class listports { public static void main(string args[]) { enumeration ports = commportidentifier.getportidentifiers(); while (ports.hasmoreelements()) { commportidentifier port = (commportidentifier)ports.nextelement(); string type; switch (port.getporttype()) { case commportidentifier.port_serial: type = "serial"; break; default: /// shouldn't happen type = "unknown"; break; } system.out.println(port.getname() + ": " + type); } } }
the output like
com1: serial com2: serial com7: serial
edit: see blog on creating , using real-time port monitoring application powered ibm lotus.
using jusb for windows , for linux can read , write operation want.you find a example here
Comments
Post a Comment