请问SPCOMM控件一次最多能传送多少字节的数据包?
我一次传送15360字节的数据包出错!!!

解决方案 »

  1.   

    应该是2048吧.看SPCOMM源码
    INPUTBUFFERSIZE = 2048;
    将数值改大点应该可以的吧。具体没试过:)
      

  2.   

    你可以试一下每次发送一个字符,循徊发送的方法:
    for I := 1 to Length(str) do
      writecommdata(@str[I],1);
    我都是用这种办法的,整块发送好象(不确定)不行.
      

  3.   

    请大家帮忙看一看呀!!
    我现在发送的数据包大小为15360字节。
    程序如下:
    发送部分:
    procedure senddata; 
    var 
      i:integer; 
      commflg:boolean; 
    begin 
      viewstring:=''; 
      commflg:=true; 
      for i:=1 to length(pbuf) do 
      begin 
        if not form1.comm1.writecommdata(@pbuf[i],1) then 
          begin 
            commflg:=false; 
            break; 
          end; 
         sleep(2); 
         viewstring:=viewstring+inttohex(pbuf[i],2)+''; 
      end; 
      viewstring:='发送'+ viewstring; 
      form1.memo1.lines.add(viewstring); 
      form1.memo1.lines.add(''); 
      if not commflg then messagedlg('发送失败 !' ,mterror,[mbyes],0); 
    end; 
    procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer; 
    begin
      for i:=0 to (15360 div 16)-1) do
        begin 
          pbuf[i*16+1]:=byte($49);
          pbuf[i*16+2]:=byte($07);
          pbuf[i*16+3]:=byte($37);
          pbuf[i*16+4]:=byte($a9);
          pbuf[i*16+5]:=byte($e6);
          pbuf[i*16+6]:=byte($af);
          pbuf[i*16+7]:=byte($06);
          pbuf[i*16+8]:=byte($fc);      pbuf[i*16+9]:=byte($01);
          pbuf[i*16+10]:=byte($68);
          pbuf[i*16+11]:=byte($30);
          pbuf[i*16+12]:=byte($4e);
          pbuf[i*16+13]:=byte($ac);
          pbuf[i*16+14]:=byte($b3);
          pbuf[i*16+15]:=byte($31);
          pbuf[i*16+16]:=byte($d2);
       end;
      senddata;
    end;
    程序老是报出:发送失败!并且还经常死机!请各位大侠看看是怎么回事?
    谢谢!!!
      

  4.   

    你以为你的pbuf是什么类型啊。可以有这么大吗??~~~~~~~~~~~~~~~~~~~~~~~~  
      我们约好一起去看雪!
    ☆★○●◎◇◆□■△▲※
      

  5.   

    pbuf如果是数组的话,应该没有这么大。请分多次完成~~~~~~~~~~~~~~~~~~~~~~~~  
      我们约好一起去看雪!
    ☆★○●◎◇◆□■△▲※
      

  6.   

    begin
      for i:=0 to (15360 div 16)-1) do
        begin 
          pbuf[i*16+1]:=byte($49);
          pbuf[i*16+2]:=byte($07);
          pbuf[i*16+3]:=byte($37);
          pbuf[i*16+4]:=byte($a9);
          pbuf[i*16+5]:=byte($e6);
          pbuf[i*16+6]:=byte($af);
          pbuf[i*16+7]:=byte($06);
          pbuf[i*16+8]:=byte($fc);
          pbuf[i*16+9]:=byte($01);
          pbuf[i*16+10]:=byte($68);
          pbuf[i*16+11]:=byte($30);
          pbuf[i*16+12]:=byte($4e);
          pbuf[i*16+13]:=byte($ac);
          pbuf[i*16+14]:=byte($b3);
          pbuf[i*16+15]:=byte($31);
          pbuf[i*16+16]:=byte($d2);
           senddata;
       end; 
    end;
    ~~~~~~~~~~~~~~~~~~~~~~~~  
      我们约好一起去看雪!
    ☆★○●◎◇◆□■△▲※
      

  7.   

    pbuf的大小为15369字节呀!
    难道不行吗?