Flex接收51单片机发送过来的16进制数据转换为String
来源:互联网 发布:下载easyrecovery软件 编辑:程序博客网 时间:2024/06/02 04:15
private static function toHex(bytes:ByteArray):String{
var pos:int =bytes.position;
bytes.position=0;
var result:String="";
while(bytes.bytesAvailable>=8){
result+=toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte());
}
while(bytes.bytesAvailable>1){
result+=toHexNum(bytes.readUnsignedByte())+"";
}
if(bytes.bytesAvailable){
result+=toHexNum(bytes.readUnsignedByte());
}
bytes.position=pos;
return result;
}
private static function toHexNum(n:uint):String{
//return 0<0xF?" "+n.toString(16):n.toString(16);
return String.fromCharCode(n.toString());
}
var pos:int =bytes.position;
bytes.position=0;
var result:String="";
while(bytes.bytesAvailable>=8){
result+=toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte());
}
while(bytes.bytesAvailable>1){
result+=toHexNum(bytes.readUnsignedByte())+"";
}
if(bytes.bytesAvailable){
result+=toHexNum(bytes.readUnsignedByte());
}
bytes.position=pos;
return result;
}
private static function toHexNum(n:uint):String{
//return 0<0xF?" "+n.toString(16):n.toString(16);
return String.fromCharCode(n.toString());
}
0 0
- Flex接收51单片机发送过来的16进制数据转换为String
- .net C# 如何接收安卓(android)发送过来的数据流转换为图片
- flex socket.writeObject()发送对象,java接收flex socket发送过来的对象
- 使用ajax接收后台发送过来的json数据
- 前端如何接收 websocket 发送过来的实时数据
- 51单片机串口的发送与接收
- 51单片机串口程序,字符串/16进制发送与接收
- .ashx接收APPCAN发送过来的图片数据流,保存为图片
- 地磅称量系统之(60) 接收地磅发送过来的数据显示在LCD上
- Web服务接收手机端发送过来的数据,分析判断后产生应答。
- 51单片机串口中断波特率为9600接收数据不正确
- 51单片机串口通信的发送与接收(转)
- 51单片机串口通信的发送与接收(转)
- 51单片机串口通信的发送与接收(转)
- 51单片机串口通信的发送与接收(转)
- 51单片机串口通信的发送与接收(转)
- 51单片机串口通信的发送与接收(转)
- 51单片机串口通信的发送与接收
- 常用正则表达式
- sed命令用法总结
- javascript获取xml节点的最大值(实现代码)
- 我的首个电子书软件--嘎嘎读书 的开发(四)
- struts2系列一之struts。xml无class转换路径/使用开发模式
- Flex接收51单片机发送过来的16进制数据转换为String
- 测试UDP端口
- SVN版本冲突解决详解
- 网页前端持续集成(2) - qunit+JSCoverage+PhantomJS使用小记
- testblog
- 笔记 --- string 字符串
- 使用甘特图创建生产过程中的可视化警报
- struts2系列二之namespace 的使用
- android模拟器上网