Board index » delphi » Digi Board can't access Ports 5 and above

Digi Board can't access Ports 5 and above

I'm currently writing a delphi app that I need to send data out the digi
comports, I can send data out of Ports 3,4, but nothing happens if I try
using ports 5 and above.. Here is a snippet of my code any help would be
app!!!

    if OpenDialog1.Execute then
    begin
    AssignFile(F1, OpenDialog1.Filename);
    Reset(F1);
    filetotal := getfilesize(OpenDialog1.FileName);
    try
      case wedm.ItemIndex of
      0 : Comm_port:='\\.\COM3';
      1 : Comm_port:='\\.\COM4';
      2 : Comm_port:='\\.\COM5';
      3 : Comm_port:='\\.\COM6';
      4 : Comm_port:='\\.\COM7';
      5 : Comm_port:='\\.\COM8';
      6 : Comm_port:='\\.\COM9';
      7 : Comm_port:='\\.\COM10';
      8 : Comm_port:='\\.\COM11';
      9 : Comm_port:='\\.\COM12';
      10 : Comm_port:='\\.\COM13';
      11 : Comm_port:='\\.\COM14';
      12 : Comm_port:='\\.\COM15';
      13 : Comm_port:='\\.\COM16';
      14 : Comm_port:='\\.\COM17';
      15 : Comm_port:='\\.\COM18';
      end;
      showmessage(Comm_port);
      statusp.Panels[0].text := 'Opening Com Port ' +
inttostr(wedm.ItemIndex + 3);
      hcomport :=
createfile(pchar(Comm_Port),GENERIC_WRITE,0,NIL,OPEN_EXISTING,FILE_ATTRIBUTE
_NORMAL,LONGINT(0));
      IF hcomport=INVALID_HANDLE_VALUE then
      begin
        messagedlg('UNABLE TO OPEN COM PORT ' + inttostr(wedm.ItemIndex +
3),mterror,[mbok],0);
      end
      else statusp.Panels[0].text := 'Com Open Succesfull';
      status:=getcommstate(hcomport,comdcb);
      IF status=False then
      begin
        messagedlg('UNABLE TO get COM State',mterror,[mbok],0);
      end
      else statusp.Panels[0].text := 'Com Status Received';
      dcbstr := 'baud=9600 parity=E data=7 stop=2';
      status := buildcommdcb(pchar(dcbstr),comdcb);
      IF status=False then
      begin
        messagedlg('UNABLE TO build dcb',mterror,[mbok],0);
      end
      else statusp.Panels[0].text := 'dcb built';
      status:=setcommstate(hcomport,comdcb);
      IF status=False then
      begin
        messagedlg('UNABLE TO Set COM State',mterror,[mbok],0);
      end
      else statusp.Panels[0].text := 'Com state set';
      i:=0;
      progressbar1.max := FileTotal;
      WHILE NOT EOF(F1) DO
      BEGIN
        NUMBERWRITTEN:=0;
        Read(F1, WD);
        statusp.Panels[0].text := inttostr(i);
        application.ProcessMessages;
        inc(i);
        WDATA := WD;
        status :=
writefile(hcomport,pchar(WData)^,length(wdata),NUMBERWRITTEN,nil);
        progressBar1.position := i;
      END;
      CloseFile(f1);
      Progressbar1.Position := 0;
      Showmessage('Download Succesfull!');
      statusp.Panels[0].text := 'Complete';
      CloseHandle(Hcomport);
    except
      Showmessage('An Error Occured');
    end;
  end;

 

Re:Digi Board can't access Ports 5 and above


False alarm fixed my own problems

Quote
JIM VARRATI wrote in message ...
>I'm currently writing a delphi app that I need to send data out the digi
>comports, I can send data out of Ports 3,4, but nothing happens if I try
>using ports 5 and above.. Here is a snippet of my code any help would be
>app!!!

>    if OpenDialog1.Execute then
>    begin
>    AssignFile(F1, OpenDialog1.Filename);
>    Reset(F1);
>    filetotal := getfilesize(OpenDialog1.FileName);
>    try
>      case wedm.ItemIndex of
>      0 : Comm_port:='\\.\COM3';
>      1 : Comm_port:='\\.\COM4';
>      2 : Comm_port:='\\.\COM5';
>      3 : Comm_port:='\\.\COM6';
>      4 : Comm_port:='\\.\COM7';
>      5 : Comm_port:='\\.\COM8';
>      6 : Comm_port:='\\.\COM9';
>      7 : Comm_port:='\\.\COM10';
>      8 : Comm_port:='\\.\COM11';
>      9 : Comm_port:='\\.\COM12';
>      10 : Comm_port:='\\.\COM13';
>      11 : Comm_port:='\\.\COM14';
>      12 : Comm_port:='\\.\COM15';
>      13 : Comm_port:='\\.\COM16';
>      14 : Comm_port:='\\.\COM17';
>      15 : Comm_port:='\\.\COM18';
>      end;
>      showmessage(Comm_port);
>      statusp.Panels[0].text := 'Opening Com Port ' +
>inttostr(wedm.ItemIndex + 3);
>      hcomport :=
>createfile(pchar(Comm_Port),GENERIC_WRITE,0,NIL,OPEN_EXISTING,FILE_ATTRIBUT
E
>_NORMAL,LONGINT(0));
>      IF hcomport=INVALID_HANDLE_VALUE then
>      begin
>        messagedlg('UNABLE TO OPEN COM PORT ' + inttostr(wedm.ItemIndex +
>3),mterror,[mbok],0);
>      end
>      else statusp.Panels[0].text := 'Com Open Succesfull';
>      status:=getcommstate(hcomport,comdcb);
>      IF status=False then
>      begin
>        messagedlg('UNABLE TO get COM State',mterror,[mbok],0);
>      end
>      else statusp.Panels[0].text := 'Com Status Received';
>      dcbstr := 'baud=9600 parity=E data=7 stop=2';
>      status := buildcommdcb(pchar(dcbstr),comdcb);
>      IF status=False then
>      begin
>        messagedlg('UNABLE TO build dcb',mterror,[mbok],0);
>      end
>      else statusp.Panels[0].text := 'dcb built';
>      status:=setcommstate(hcomport,comdcb);
>      IF status=False then
>      begin
>        messagedlg('UNABLE TO Set COM State',mterror,[mbok],0);
>      end
>      else statusp.Panels[0].text := 'Com state set';
>      i:=0;
>      progressbar1.max := FileTotal;
>      WHILE NOT EOF(F1) DO
>      BEGIN
>        NUMBERWRITTEN:=0;
>        Read(F1, WD);
>        statusp.Panels[0].text := inttostr(i);
>        application.ProcessMessages;
>        inc(i);
>        WDATA := WD;
>        status :=
>writefile(hcomport,pchar(WData)^,length(wdata),NUMBERWRITTEN,nil);
>        progressBar1.position := i;
>      END;
>      CloseFile(f1);
>      Progressbar1.Position := 0;
>      Showmessage('Download Succesfull!');
>      statusp.Panels[0].text := 'Complete';
>      CloseHandle(Hcomport);
>    except
>      Showmessage('An Error Occured');
>    end;
>  end;

Other Threads