0

I use windows 7, 64-bit SP1, and TP Async V4.07 and have the following problem: I have two Com ports, Com11, and Com18. I add the following components to my form:

enter image description here

I open a Com port on ApdComPort2 (Com18) and it works without a problem. The ApdDataPacket2 detects the packet terminator and the result displayed is what is expected. Both Com11 and Com18 work fine. Now if I open another Com port (Com11) with ApdComPort1 I get an Access violation:

enter image description here

The code that generates the error is this in the AdPacket module:

procedure TApdDataPacketManager.EnablePackets;
var
  i : integer;
begin
  for i := 0 to pred(PacketList.Count) do
    with TApdDataPacket(PacketList[i]) do
      if Enabled then
        Enable;
end;

It is the PacketList.Count that seems to be the problem when it iterates through the list but I can’t catch why:

enter image description here

Note that ApdComPort2 works without problem with both Com11 and Com18. If I remove the Apd2 components then Apd1 works as expected. The problems surface when I try to use two (or more) Apd components at the same time. Does anybody have a suggestion or can recommend a component that works with more than one serial port simultaneously?

Bo SM6FIE
  • 19
  • 4
  • 1
    An error address of 0x00000008 indicates reading a nil pointer. Based on your suspicion regarding `PacketList.Count`, maybe the `PacketList` isn't instantiated. I don't have the `AsyncPro` installed and can't therefore check further. – Tom Brunberg Oct 22 '22 at 17:25
  • Please post the dfm code so we can see how you did set up the components. – Delphi Coder Oct 22 '22 at 20:14

1 Answers1

-1

Some notes about the Turbo Power Async Professional components:

When using the Async components it is very important on how you add the components to the form. If you don’t does it in the right order and in the correct way it will not work if you use more than one serial port. You will actually get an access violation. For example, if you add the components below you have to do it in this way:

enter image description here

  1. Add one ApdComPort to the form, it will become ApdComPort1
  2. Now copy and paste this component to the form, it will become ApdComPort2
  3. Add one ApdDataPacket component to the form, it will become ApdDataPacket1
  4. Now copy and paste this component to the form, it will become ApdDataPacket2
  5. Add one ApdSLController component to the form, it will become ApdSLController1
  6. Now copy and paste this component to the form, it will become ApdSLController2

When doing it, as described above, it works to use two serial ports with ApdDatapacket. Now I don’t get any getting Access violations. I have tested it up to 4 ports and it works as well.

Bo SM6FIE
  • 19
  • 4
  • And how does this differ from your initial problem? What would be a "wrong" way? – AmigoJack Oct 23 '22 at 08:18
  • 2
    @AmigoJack I'm guessing OP is probably enabling the said components at design time. This means that the said components try to start working as soon as they are created. So if the said components don't get streamed in right order from DFM one of the components might try to start working before the connected component is even created. This would then result in AV. OP should enable these components only after the form finished constructing and thus ensuring that all needed components have been created already. – SilverWarior Oct 23 '22 at 16:13