Delphi XE3, Indy 10.5.9.0

I am creating an interface between a computer and an instrument. The instrument uses ASTM protocol.

I have successfully sent text based messages back and forth between the server and client. I have been able to send control characters to the server and read those. What I have not figured out after 3 days of searching is how to write and read messages that have a mixture of control characters and text. 

I am sending ASTM protocol messages which require control characters and text like the following line. Everything in angle brackets are control characters. Writing the message is not where I run into problems. It is when reading it since I will receive both text and control characters. My code below is how I read the control characters. How can I tell when I get the character whether it is a control character and when it is text in the same string of control and text characters? Thanks to Remy Lebeau and his posts on this site to get me where I am. He talked about how to use buffers but I couldn't tell how to read a buffer that contained control characters and text characters.

```
<STX>3O|1|G-13-00017||^^^HPV|R||||||N||||||||||||||O<CR><ETX>D3<CR><LF>

```

I have added the following code to my server components OnConnect event which is supposed to allows me to send control characters...

```
...
AContext.Connection.IOHandler.DefStringEncoding := TIdTextEncoding.UTF8;
...

```

My server OnExecute event...

```
procedure TTasksForm.IdTCPServer1Execute(AContext: TIdContext);
var
  lastline : WideString;
  lastcmd :  WideString ;
  lastbyte : Byte ;
begin 

  ServerTrafficMemo.Lines.Add('OnExecute') ;

  lastline := '' ;
  lastcmd := '' ;

  lastbyte := (AContext.Connection.IOHandler.ReadByte) ;

  if lastbyte = Byte(5) then
  begin

    lastcmd := '<ENQ>' ;

    ServerTrafficMemo.Lines.Add(lastcmd) ;

    AContext.Connection.IOHandler.WriteLn(lastcmd + ' received') ;

  end;

end;

```