⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buildsource.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	return Platform.decodeBaudrate(rate);    }     /**     * Make an old, broken serial-port packet source     * @param args "COMn[:baudrate][,packetSize]" ("COM1" if args is null)     *   baudrate is an integer or mote name (rene, mica, mica2, mica2dot).     *   The default baudrate is 19200.     * @return The new packet source, or null if the arguments are invalid     */    public static PacketSource makeArgsOldSerial(String args) {	if (args == null)	    args = "COM1";	ParseArgs parser = new ParseArgs(args, ":,");	String port = parser.next();	int baudrate = decodeBaudrate(parser.next());	String packetSizeS = parser.next();	if (packetSizeS == null) {	    return makeOldSerial(port, baudrate);	}	else {	    int packetSize = Integer.parseInt(packetSizeS);	    return makeOldSerial(port, baudrate, packetSize);	}    }    /**     * Make an old, broken serial-port packet source     * @param port javax.comm serial port name ("COMn:")     * @param baudrate requested baudrate     * @param packetSize packet size to use     * @return The new packet source     */    public static PacketSource makeOldSerial(String port, int baudrate,					     int packetSize) {	return new BrokenPacketizer("old-serial@" + port + ":" + baudrate,				    packetSize,				    new SerialByteSource(port, baudrate));    }    /**     * Make an old, broken serial-port packet source with the default      * packet size.     * @param port javax.comm serial port name ("COMn:")     * @param baudrate requested baudrate     * @return The new packet source     */    public static PacketSource makeOldSerial(String port, int baudrate) {	return makeOldSerial(port, baudrate,			     net.tinyos.message.MoteIF.defaultPacketSize);    }    /**     * Make a serial-port packet source. Serial packet sources report     * missing acknowledgements via a false result to writePacket.     * @param args "COMn[:baudrate]" ("COM1" if args is null)     *   baudrate is an integer or mote name (rene, mica, mica2, mica2dot).     *   The default baudrate is 19200.     * @return The new packet source, or null if the arguments are invalid     */    public static PacketSource makeArgsSerial(String args) {	if (args == null)	    args = "COM1";	ParseArgs parser = new ParseArgs(args, ":");	String port = parser.next();	String platformOrBaud = parser.next();	int baudrate = decodeBaudrate(platformOrBaud);	int platform = Platform.decodePlatform(platformOrBaud);	return makeSerial(port, baudrate, platform);    }    /**     * Make a serial-port packet source. Serial packet sources report     * missing acknowledgements via a false result to writePacket.     * @param port javax.comm serial port name ("COMn:")     * @param baudrate requested baudrate     * @return The new packet source     */     public static PacketSource makeSerial(String port, int baudrate, int platform) {	return new Packetizer("serial@" + port + ":" + baudrate,			      new SerialByteSource(port, baudrate), platform);    }    /**     * Make an old, broken serial-port packet source for a network-accessible     * serial port     * @param args "hostname:portnumber[,packetSize]" (no default)     * @return The new packet source, or null if the arguments are invalid     */    public static PacketSource makeArgsOldNetwork(String args) {	if (args == null)	    return null;	ParseArgs parser = new ParseArgs(args, ":,");	String host = parser.next();	String portS = parser.next();	if (portS == null)	    return null;	int port = Integer.parseInt(portS);	String packetSizeS = parser.next();	if (packetSizeS == null) {	    return makeOldNetwork(host, port);	}	else {	    int packetSize = Integer.parseInt(packetSizeS);	    return makeOldNetwork(host, port, packetSize);	}    }    /**     * Make an old, broken serial-port packet source for a network-accessible     * serial port     * @param host hostname of network-accessible serial port     * @param port tcp/ip port number     * @param packetSize packet size to use     * @return The new packet source     */    public static PacketSource makeOldNetwork(String host, int port,					      int packetSize) {	return new BrokenPacketizer("old-network@" + host + ":" + port,				    packetSize,				    new NetworkByteSource(host, port));    }    /**     * Make an old, broken serial-port packet source for a network-accessible     * serial port with the default packet size     * @param host hostname of network-accessible serial port     * @param port tcp/ip port number     * @return The new packet source     */    public static PacketSource makeOldNetwork(String host, int port) {	return makeOldNetwork(host, port,			      net.tinyos.message.MoteIF.defaultPacketSize);    }    /**     * Make a serial-port packet source for a network-accessible serial     * port. Serial packet sources report missing acknowledgements via a     * false result to writePacket.     * @param args "hostname:portnumber" (no default)     * @return The new packet source, or null if the arguments are invalid     */    public static PacketSource makeArgsNetwork(String args) {	if (args == null)	    return null;	ParseArgs parser = new ParseArgs(args, ":,");	String host = parser.next();	String portS = parser.next();	String platformS = parser.next();	if (portS == null)	    return null;	int port = Integer.parseInt(portS);	int platform;	if (platformS == null) 	    platform = Platform.defaultPlatform;	else	    platform = Platform.decodePlatform(platformS);	return makeNetwork(host, port, platform);    }    /**     * Make a serial-port packet source for a network-accessible serial     * port. Serial packet sources report missing acknowledgements via a     * false result to writePacket.     * @param host hostname of network-accessible serial port     * @param port tcp/ip port number     * @return The new packet source     */    public static PacketSource makeNetwork(String host, int port, int platform) {	return new Packetizer("network@" + host + ":" + port,			      new NetworkByteSource(host, port), platform);    }    // We create tossim sources using reflection to avoid depending on    // tossim at compile-time    /**     * Make a tossim serial port (node 0) packet source     * @param args "hostname" ("localhost" for null) (on which tossim runs)     * @return The new packet source     */    public static PacketSource makeArgsTossimSerial(String args) {	if (args == null)	    args = "localhost";	return makeTossimSerial(args);    }    /**     * Make a tossim serial port (node 0) packet source     * @param host hostname on which tossim runs     * @return The new packet source     */    public static PacketSource makeTossimSerial(String host) {	return makeTossimSource("TossimSerialSource", host);    }    /**     * Make a tossim radio packet source     * @param args "hostname" ("localhost" for null) (on which tossim runs)     * @return The new packet source     */    public static PacketSource makeArgsTossimRadio(String args) {	if (args == null)	    args = "localhost";	return makeTossimRadio(args);    }    /**     * Make a tossim radio packet source     * @param host hostname on which tossim runs     * @return The new packet source     */    public static PacketSource makeTossimRadio(String host) {	return makeTossimSource("TossimRadioSource", host);    }    private static PacketSource makeTossimSource(String name, String host) {	try {	    Class[] oneStringArg = new Class[1];	    oneStringArg[0] = Class.forName("java.lang.String");	    Object[] args = new Object[1];	    args[0] = host;	    Class tossimSource = Class.forName("net.tinyos.sim.packet." + name);	    return (PacketSource)tossimSource.getConstructor(oneStringArg).newInstance(args);	}	catch (Exception e) {	    System.err.println("Couldn't instantiate tossim packet source");	    System.err.println("Did you compile tossim?");	    return null;	}    }//     static class ParseArgs {// 	String tokens[];// 	int tokenIndex;// 	ParseArgs(String s, String delimiterSequence) {// 	    int count = delimiterSequence.length();// 	    tokens = new String[count + 1];// 	    tokenIndex = 0;// 	    // Fill in the tokens// 	    int i = 0, lastMatch = 0;// 	    while (i < count) {// 		int pos = s.indexOf(delimiterSequence.charAt(i++));// 		if (pos >= 0) {// 		    // When we finally find a delimiter, we know where// 		    // the last token ended// 		    tokens[lastMatch] = s.substring(0, pos);// 		    lastMatch = i;// 		    s = s.substring(pos + 1);// 		}// 	    }// 	    tokens[lastMatch] = s;// 	}// 	String next() {// 	    return tokens[tokenIndex++];// 	}//     }    public static void main(String[] args) {	System.err.println(sourceHelp());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -