Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ComPort Programming

Posted on 1999-07-30
2
Medium Priority
?
598 Views
Last Modified: 2012-06-27
Any one has experience in using AnsyPro TApdComPort and TApdDataPacket?
My question is how to get data unknown length and end condition. How to get data partially?
simon

0
Comment
Question by:ysimon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:slposey
ID: 1392042
Since you don't seem to have gotten an answer here, I'd suggest posting your question to TurboPower's newsgroups.

0
 

Accepted Solution

by:
Worminator earned 100 total points
ID: 1392043
As I understand it all you want to do is recieve data periodically as you do not know what the length of the packet is or its end condition. Here is a code sample that will display incoming data in a memo box.

procedure TForm1.InComTrigger(CP: TObject; Msg,   TiggerHandle,Data: Word);
Var
  C       : Char;
  InData  : String;
begin
  Case Msg of
    //Normal Incoming data
    apw_TriggerAvail :
      begin
        if memIncomingData.Lines.Count <> 0 then
          Indata := memIncomingData.Lines[memIncomingData.Lines.Count-1]
        else
          Indata := '';

        //For the Current no of bytes of data in the buffer do
        While Data > 0 do
        begin
          //Fetch the next character in the buffer
          C := Incom.GetChar;

          //Add that Character to the exsisting data
          Indata := InData + C;
          Dec(Data);
        end;//While statement

        //If we are not at the end of the line in the memo box then we need t0
        //add the new data to the existing line
        If(Indata<>'') then
          if memIncomingData.Lines.Count <> 0 then
            memIncomingData.Lines[memIncomingData.Lines.Count-1] := Indata
          else
           //Add new data to the next new                memIncomingData.Lines.Add(Indata);
      end;//apw_TriggerAvail :

  end;//Case Msg of
end;//Procedure

Sorry about the messy looking code but I cut and pasted it from the Delphi IDE and this edit box sucks.

This code needs to be added to the InComTrigger event of the TApdmPort component.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question