• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ByteUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.rapplogic.xbee.util.ByteUtils的典型用法代码示例。如果您正苦于以下问题:Java ByteUtils类的具体用法?Java ByteUtils怎么用?Java ByteUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ByteUtils类属于com.rapplogic.xbee.util包,在下文中一共展示了ByteUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ZNetApiAtExample

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public ZNetApiAtExample() throws XBeeException {
		try {
			
			// replace with port and baud rate of your XBee
			xbee.open("COM6", 9600);	
			
			// get the 8 byte SH/SL address
			log.debug("SH is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SH"))).getValue()));
			log.debug("SL is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SL"))).getValue()));
			
			// uncomment to run
//			this.configureIOSamples(xbee);
//			this.associationStatus(xbee);
//			this.nodeDiscover(xbee);
//			this.configureCoordinator(xbee);
//			this.configureEndDevice(xbee);
		} finally {
			if (xbee != null && xbee.isConnected()) {
				xbee.close();		
			}
		}
	}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:23,代码来源:ZNetApiAtExample.java


示例2: sendPacket

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
/**
 * This exists solely for the XMPP project.  Use sendRequest instead
 * 
 * Not Thread Safe
 * 
 * @param packet
 * @throws RuntimeException when serial device is disconnected
 */
public void sendPacket(int[] packet)  throws IOException {
	// TODO should we synchronize on read lock so we are sending/recv. simultaneously?
	// TODO call request listener with byte array
	
	if (!this.isConnected()) {
		throw new XBeeNotConnectedException();
	}
	
	if (log.isInfoEnabled()) {
		log.info("Sending packet to XBee " + ByteUtils.toBase16(packet));	
	}

       for (int packetByte : packet) {
       	// if connection lost
       	//Caused by: com.rapplogic.xbee.api.XBeeException
       	//Caused by: java.io.IOException: Input/output error in writeArray
       	xbeeConnection.getOutputStream().write(packetByte);
       }

       xbeeConnection.getOutputStream().flush();
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:30,代码来源:XBee.java


示例3: main

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public static void main(String[] args) {
	//83 56 78 24 00 01 02 00 03 ff 85
	Checksum ck = new Checksum();

	ck.addByte(0x83);
	ck.addByte(0x56);
	ck.addByte(0x78);
	ck.addByte(0x26);
	ck.addByte(0x00);
	ck.addByte(0x01);
	ck.addByte(0x02);
	ck.addByte(0x00);
	ck.addByte(0x03);
	ck.addByte(0xff);
	// checksum
	ck.addByte(0x83);
	
	// checksum is 0x83
	//ck.compute();
	ck.verify();
	
	System.out.println("checksum is " + ByteUtils.formatByte(ck.getChecksum()));
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:24,代码来源:Checksum.java


示例4: ZNetApiAtExample

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public ZNetApiAtExample() throws XBeeException {
		try {
			
			// replace with port and baud rate of your XBee
			xbee.open("COM6", 9600);	
			
			// get the 8 byte SH/SL address
			log.debug("SH is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SH"))).getValue()));
			log.debug("SL is " + ByteUtils.toBase16(((AtCommandResponse)xbee.sendAtCommand(new AtCommand("SL"))).getValue()));
			
			// uncomment to run
//			this.configureIOSamples(xbee);
//			this.associationStatus(xbee);
//			this.nodeDiscover(xbee);
//			this.configureCoordinator(xbee);
//			this.configureEndDevice(xbee);
		} finally {
			xbee.close();
		}
	}
 
开发者ID:allanlang,项目名称:xbee-api-jssc,代码行数:21,代码来源:ZNetApiAtExample.java


示例5: BroadcastSenderExample

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
private BroadcastSenderExample() throws XBeeException {
	
	XBee xbee = new XBee();
	
	try {
		// replace with your com port and baud rate. this is the com port of my coordinator		
		xbee.open("/dev/ttyUSB0", 9600);
		
		while (true) {
			// put some arbitrary data in the payload
			int[] payload = ByteUtils.stringToIntArray("the\nquick\nbrown\nfox");
			
			ZNetTxRequest request = new ZNetTxRequest(XBeeAddress64.BROADCAST, payload);
			// make it a broadcast packet
			request.setOption(ZNetTxRequest.Option.BROADCAST);

			log.info("request packet bytes (base 16) " + ByteUtils.toBase16(request.getXBeePacket().getPacket()));
			
			xbee.sendAsynchronous(request);
			// we just assume it was sent.  that's just the way it is with broadcast.  
			// no transmit status response is sent, so don't bother calling getResponse()
				
			try {
				// wait a bit then send another packet
				Thread.sleep(15000);
			} catch (InterruptedException e) {
			}
		}
	} finally {
		if (xbee != null && xbee.isConnected()) {
			xbee.close();		
		}
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:35,代码来源:BroadcastSenderExample.java


示例6: ZBNodeDiscoverExample

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public ZBNodeDiscoverExample() throws XBeeException, InterruptedException {
	
	try {
		// replace with your serial port
		xbee.open("/dev/tty.usbserial-A6005v5M", 9600);
		
		
		// get the Node discovery timeout
		xbee.sendAsynchronous(new AtCommand("NT"));
		AtCommandResponse nodeTimeout = (AtCommandResponse) xbee.getResponse();
		
		// default is 6 seconds
		int nodeDiscoveryTimeout = ByteUtils.convertMultiByteToInt(nodeTimeout.getValue()) * 100;			
		log.info("Node discovery timeout is " + nodeDiscoveryTimeout + " milliseconds");
					
		log.info("Sending Node Discover command");
		xbee.sendAsynchronous(new AtCommand("ND"));

		// NOTE: increase NT if you are not seeing all your nodes reported
		
		List<? extends XBeeResponse> responses = xbee.collectResponses(nodeDiscoveryTimeout);
		
		log.info("Time is up!  You should have heard back from all nodes by now.  If not make sure all nodes are associated and/or try increasing the node timeout (NT)");
		
		for (XBeeResponse response : responses) {
			if (response instanceof AtCommandResponse) {
				AtCommandResponse atResponse = (AtCommandResponse) response;
				
				if (atResponse.getCommand().equals("ND") && atResponse.getValue() != null && atResponse.getValue().length > 0) {
					ZBNodeDiscover nd = ZBNodeDiscover.parse((AtCommandResponse)response);
					log.info("Node Discover is " + nd);							
				}
			}
		}
	} finally {
		if (xbee != null && xbee.isConnected()) {
			xbee.close();		
		}
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:41,代码来源:ZBNodeDiscoverExample.java


示例7: isDigitalEnabled

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public boolean isDigitalEnabled(int pin) {
	if (pin >=0 && pin <= 7) {
		return ByteUtils.getBit(this.digitalChannelMaskLsb, pin + 1);
	} else if (pin >=10 && pin <= 12) {
		return ByteUtils.getBit(this.digitalChannelMaskMsb, pin - 7);
	} else {
		throw new IllegalArgumentException("Unsupported pin: " + pin);
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:10,代码来源:ZNetRxIoSampleResponse.java


示例8: isAnalogEnabled

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public boolean isAnalogEnabled(int pin) {
	if (pin >=0 && pin <= 3) {
		return ByteUtils.getBit(this.analogChannelMask, pin + 1);
	} else {
		throw new IllegalArgumentException("Unsupported pin: " + pin);
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:8,代码来源:ZNetRxIoSampleResponse.java


示例9: isDigitalOn

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
/**
 * If digital I/O line (DIO0) is enabled: returns true if digital 0 is HIGH (ON); false if it is LOW (OFF).
 * If digital I/O line is not enabled this method returns null as it has no value.
 * <p/>
 * Important: the pin number corresponds to the logical pin (e.g. D4), not the physical pin number.
 * <p/>
 * Digital I/O pins seem to report high when open circuit (unconnected)
 * 
 * @return
 */	
public Boolean isDigitalOn(int pin) {
	if (this.isDigitalEnabled(pin)) {
		if (pin >=0 && pin <= 7) {
			return ByteUtils.getBit(dioLsb, pin + 1);
		} else if (pin >=10 && pin <= 12) {
			return ByteUtils.getBit(dioMsb, pin - 7);
		}			
	}
	
	return null;
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:22,代码来源:ZNetRxIoSampleResponse.java


示例10: toString

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public String toString() {
	return super.toString() + 
		",sourceEndpoint=" + ByteUtils.toBase16(this.getSourceEndpoint()) +
		",destinationEndpoint=" + ByteUtils.toBase16(this.getDestinationEndpoint()) +
		",clusterId(msb)=" + ByteUtils.toBase16(this.getClusterId().getMsb()) +
		",clusterId(lsb)=" + ByteUtils.toBase16(this.getClusterId().getLsb()) +
		",profileId(msb)=" + ByteUtils.toBase16(this.getProfileId().getMsb()) +
		",profileId(lsb)=" + ByteUtils.toBase16(this.getProfileId().getLsb());
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:10,代码来源:ZNetExplicitRxResponse.java


示例11: toString

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public String toString() {
	return "nodeAddress16=" + this.nodeAddress16 + 
	", nodeAddress64=" + this.nodeAddress64 + 
	", nodeIdentifier=" + this.nodeIdentifier + 
	", parentAddress=" + this.getParent() + 
	", deviceType=" + this.deviceType +
	", status=" + this.status +
	", profileId=" + ByteUtils.toBase16(this.profileId) + 
	", mfgId=" + ByteUtils.toBase16(this.mfgId);
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:11,代码来源:ZBNodeDiscover.java


示例12: toString

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public String toString() {
	return super.toString() + 
		",destAddr64=" + this.destAddr64 +
		",destAddr16=" + this.destAddr16 +
		",broadcastRadius=" + this.broadcastRadius + 
		",option=" + this.option +
		",payload=" + ByteUtils.toBase16(this.payload);
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:9,代码来源:ZNetTxRequest.java


示例13: toString

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public String toString() {
	// 8/19/09 fixed null pointer on length.get16BitValue
	return "apiId=" + this.apiId +
		",length=" + (length == null ? "null" : length.get16BitValue()) + 
		",checksum=" + ByteUtils.toBase16(checksum) +
		",error=" + this.error;
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:8,代码来源:XBeeResponse.java


示例14: toString

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public String toString() {
	return "command=" + this.getCommand() +
		",status=" + this.getStatus() + ",value=" + 
		(this.value == null ? "null" : ByteUtils.toBase16(this.getValue())) +
		"," +
		super.toString();
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:8,代码来源:AtCommandResponse.java


示例15: isDigitalOn

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
/**
 * Returns the digital value of the specified pin.
 * Returns null if pin is not configured for Digital input 
 * 
 * @return
 */
public Boolean isDigitalOn(int pin) {
	
	if (!parent.isDigitalEnabled(pin)) {
		return null;
	}
	
	if (pin >= 0 && pin <= 7) {
		return ByteUtils.getBit(dioLsb, pin + 1);
	} else {
		// pin 8
		return ByteUtils.getBit(dioMsb, 1);		
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:20,代码来源:IoSample.java


示例16: parse

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public void parse(IPacketParser parser) throws IOException {

		if (parser.getApiId() == ApiId.RX_16_IO_RESPONSE) {
			this.setSourceAddress(parser.parseAddress16());	
		} else {
			this.setSourceAddress(parser.parseAddress64());
		}	
		
		super.parseBase(parser);

		log.debug("this is a I/O sample!");
		// first byte is # of samples
		int sampleSize = parser.read("# I/O Samples");
		
		// create i/o samples array
		this.setSamples(new IoSample[sampleSize]);
		
		// channel indicator 1
		this.setChannelIndicator1(parser.read("Channel Indicator 1"));
		
		log.debug("channel indicator 1 is " + ByteUtils.formatByte(this.getChannelIndicator1()));
		
		// channel indicator 2 (dio)
		this.setChannelIndicator2(parser.read("Channel Indicator 2"));
		
		log.debug("channel indicator 2 is " + ByteUtils.formatByte(this.getChannelIndicator2()));	
		
		// collect each sample
		for (int i = 0; i < this.getSamples().length; i++) {
			
			log.debug("parsing sample " + (i + 1));
			
			IoSample sample = parseIoSample((IIntInputStream)parser);
			
			// attach sample to parent
			this.getSamples()[i] = sample;
		}		
	}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:39,代码来源:RxResponseIoSample.java


示例17: isDigitalEnabled

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public boolean isDigitalEnabled(int pin) {
	if (pin >= 0 && pin <= 7) { 
		return ByteUtils.getBit(channelIndicator2, pin + 1);
	} else if (pin == 8) {
		return ByteUtils.getBit(channelIndicator1, 1);
	} else {
		throw new IllegalArgumentException("Unsupported pin: " + pin);
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:10,代码来源:RxResponseIoSample.java


示例18: isAnalogEnabled

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
public boolean isAnalogEnabled(int pin) {
	if (pin >= 0 && pin <= 5) {
		return  ByteUtils.getBit(channelIndicator1, pin + 2);
	} else {
		throw new IllegalArgumentException("Unsupported pin: " + pin);
	}
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:8,代码来源:RxResponseIoSample.java


示例19: compute

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
/**
 * Computes checksum and stores in checksum instance variable
 * 
 * @return
 */
public void compute() {
	// discard values > 1 byte
	checksum = 0xff & checksum;
	// perform 2s complement
	checksum = 0xff - checksum;
	
	log.debug("computed checksum is " + ByteUtils.formatByte(checksum));
}
 
开发者ID:andrewrapp,项目名称:xbee-api,代码行数:14,代码来源:Checksum.java


示例20: BroadcastSenderExample

import com.rapplogic.xbee.util.ByteUtils; //导入依赖的package包/类
private BroadcastSenderExample() throws XBeeException {
	
	XBee xbee = new XBee();
	
	try {
		// replace with your com port and baud rate. this is the com port of my coordinator		
		xbee.open("/dev/ttyUSB0", 9600);
		
		while (true) {
			// put some arbitrary data in the payload
			int[] payload = ByteUtils.stringToIntArray("the\nquick\nbrown\nfox");
			
			ZNetTxRequest request = new ZNetTxRequest(XBeeAddress64.BROADCAST, payload);
			// make it a broadcast packet
			request.setOption(ZNetTxRequest.Option.BROADCAST);

			log.info("request packet bytes (base 16) " + ByteUtils.toBase16(request.getXBeePacket().getPacket()));
			
			xbee.sendAsynchronous(request);
			// we just assume it was sent.  that's just the way it is with broadcast.  
			// no transmit status response is sent, so don't bother calling getResponse()
				
			try {
				// wait a bit then send another packet
				Thread.sleep(15000);
			} catch (InterruptedException e) {
			}
		}
	} finally {
		xbee.close();
	}
}
 
开发者ID:allanlang,项目名称:xbee-api-jssc,代码行数:33,代码来源:BroadcastSenderExample.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSTerm类代码示例发布时间:2022-05-23
下一篇:
Java AudioFocusRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap