当前位置: 首页>>代码示例>>Java>>正文


Java CommPortIdentifier.getPortType方法代码示例

本文整理汇总了Java中javax.comm.CommPortIdentifier.getPortType方法的典型用法代码示例。如果您正苦于以下问题:Java CommPortIdentifier.getPortType方法的具体用法?Java CommPortIdentifier.getPortType怎么用?Java CommPortIdentifier.getPortType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.comm.CommPortIdentifier的用法示例。


在下文中一共展示了CommPortIdentifier.getPortType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.comm.CommPortIdentifier; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException 
{
    portList = CommPortIdentifier.getPortIdentifiers();
    int i;
    while (portList.hasMoreElements()) 
    {
        portId = (CommPortIdentifier) portList.nextElement();
        
        if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) 
        {
        	if (portId.getName().equals("COM5")) 
        	{
        		System.out.println("Welcome To UltraClenz Gateway Diagnosis Center");
        		HyperMain reader = new HyperMain();
            }
        }
        
    }
}
 
开发者ID:ultrac,项目名称:JavaProjects,代码行数:20,代码来源:HyperMain.java

示例2: getPortIdentifiers

import javax.comm.CommPortIdentifier; //导入方法依赖的package包/类
@Override
public List<String> getPortIdentifiers() {
    Enumeration ports = CommPortIdentifier.getPortIdentifiers();
    List<String> list = new ArrayList<String>();
    while (ports.hasMoreElements()) {
        CommPortIdentifier id = (CommPortIdentifier) ports.nextElement();
        if (id.getPortType() == CommPortIdentifier.PORT_SERIAL) {
            list.add(id.getName());
        }
    }
    return list;
}
 
开发者ID:kochedykov,项目名称:jlibmodbus,代码行数:13,代码来源:SerialPortFactoryJavaComm.java

示例3: CommPortSimple

import javax.comm.CommPortIdentifier; //导入方法依赖的package包/类
public CommPortSimple(String devName) throws Exception {

        @SuppressWarnings("unchecked")
        Enumeration<CommPortIdentifier> pList = 
                CommPortIdentifier.getPortIdentifiers();

        // Walk the list, looking for the given name
        CommPortIdentifier cpi = null;
        boolean atLeastOneSerialPresent = false;
        while (pList.hasMoreElements()) {
            CommPortIdentifier c = pList.nextElement();
            if (c.getPortType() !=CommPortIdentifier.PORT_SERIAL) {
                System.err.println("Not a serial port: " + c.getName());
                continue;
            }
            if (devName.equals(c.getName())) {
                cpi = c;
                break; // found!
            }
            atLeastOneSerialPresent = true;
            System.out.println("Not matched: " + c.getName());
        }
        if (cpi == null) {
            System.err.println("Did not find serial port '" + devName + "'");
            if (atLeastOneSerialPresent)
                System.err.println("Try again with one of the listed names");
            else
                System.err.println("In fact, I didn't see ANY serial ports!");
            System.exit(1);
        }

        thePort = cpi.open("JavaCook DataComm",
                TIMEOUTSECONDS * 1000);
        SerialPort myPort = (SerialPort) thePort;

        // set up the serial port
        myPort.setSerialPortParams(BAUD, SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

        // Get the input and output streams
        is = new BufferedReader(new InputStreamReader(thePort.getInputStream()));
        os = new PrintStream(thePort.getOutputStream(), true);
    }
 
开发者ID:shashanksingh28,项目名称:code-similarity,代码行数:44,代码来源:CommPortSimple.java


注:本文中的javax.comm.CommPortIdentifier.getPortType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。