zoukankan      html  css  js  c++  java
  • d

     1                         int cishu=0;
     2                         if((dataLength)%1020!=0)
     3                             cishu=(dataLength)/1020+1;
     4                         else
     5                             cishu=(dataLength)/1020;
     6                         for(int i=0;i<cishu;i++){
     7                             if((dataLength-1020)>0){
     8                                 sendBuf[3] = (byte)(1020>>24);//小于1020的表示改帧结束,此次发送的长度是datalength
     9                                 sendBuf[2] = (byte)(1020>>16);
    10                                 sendBuf[1]  = (byte)(1020>>8);
    11                                 sendBuf[0] = (byte)1020;
    12                             }else if((dataLength-1020)<0)
    13                             {
    14                                 sendBuf[3] = (byte)(dataLength>>24);//1020表示改帧未结束,此次发出的长度是1020
    15                                 sendBuf[2] = (byte)(dataLength>>16);
    16                                 sendBuf[1]  = (byte)(dataLength>>8);
    17                                 sendBuf[0] = (byte)dataLength;
    18                             }else{
    19                                 sendBuf[3] = (byte)(1021>>24);//1021表示表示改帧是结束帧,此次发出的长度是1020
    20                                 sendBuf[2] = (byte)(1021>>16);
    21                                 sendBuf[1]  = (byte)(1021>>8);
    22                                 sendBuf[0] = (byte)1021;
    23                             }
    24                             if((dataLength-1020)>0)
    25                             {
    26                                 System.arraycopy(buffer, i*1020, sendBuf, 4, 1020);
    27                                 if(xjtuActivity.cv.sendMessage(sendBuf,1024)==false){
    28                                     xjtuActivity.messageShow.sendEmptyMessage(6);
    29                                     break;
    30                                 }
    31                                 dataLength=dataLength-1020;
    32                             }else{
    33                                 System.arraycopy(buffer,(cishu-1)*1020,sendBuf,4,dataLength);
    34                                 if(xjtuActivity.cv.sendMessage(sendBuf,dataLength+4)==false){
    35                                     xjtuActivity.messageShow.sendEmptyMessage(6);
    36                                     break;
    37                                 }
    38                                 dataLength=0;
    39                             }     
    40                         }
  • 相关阅读:
    链接脚本语法
    STM32 硬件IIC接口总线
    C99一些特性
    oneid与用户标签之间的相互打通 实现用户标签
    图计算实现ID_Mapping、Oneid打通数据孤岛
    对于hive使用的一点记录
    centos7 hue安装
    Kafka监控安装
    hadoop2.6.0集群搭建
    centos6+cdh5.4.0 离线搭建cdh搭建
  • 原文地址:https://www.cnblogs.com/GoAhead/p/3010561.html
Copyright © 2011-2022 走看看