nrComms

Using nrcomm1 component with a tRichEdit Called memoDMS

Settings

nrComm1.ComPort := cpCom1;
nrComm1.Terminal := memoDMS;
nrComm1.active := true;

comm port is correct
nrComm1AfterReceive is triggered but no data is shown in the tRichedit component
I have other programs working correctly with this setup

Help
KevinfeeningAsked:
Who is Participating?
 
jimyXConnect With a Mentor Commented:
Are you sure there is no any option forgotten somewhere?

This can be one of the situations where you catch one silly tiny thing, that has slipped, and you find it after flipping the project.

If you can, please attach both projects (pas & dfm), after removing whatever sensitive data that you do not want to expose (if any).
0
 
jimyXCommented:
Haven't used nrComm before.

But normally there are other settings (Baud rate, data bits, ...etc). Have you set everything inline with the other programs' settings?

You need to set everything in order to be able to send/receive through the com port.
0
 
KevinfeeningAuthor Commented:
Sorry I didn't explain
I copied and pasted the tNRComm and tRichedit so all setting are the same
attached is a word doc with the settings

All the program does is after the richedit has got the data then
I copy the data to a file

  assignFile(filename,ePath.text);
  rewrite(filename);
  append(filename);
  memoDMS.Refresh;
  for l := 0 to 10000 do begin
      if memoDMS.Lines.Strings[l] = '' then break;
      if memoDMS.Lines.Strings[l] <> '' then
         writeLn(filename,memoDMS.Lines.Strings[l]);
  end;

but the 2nd program has no information in the tRichedit but the tRichedit.onafterreceive
event triggers in both programs
Comms.docx
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
jimyXCommented:
So you confirm that you have successfully connected to the port.
And you can send receive from that port but the only problem you have is that, the data received does not appear in the "memoDMS" RichEdit.

First here are some improvements to your code:

- Use Append no need to Rewrite if the file exists:

  assignFile(filename,ePath.text);
  if FileExists(ePath.text) then
    append(filename)
  else
    rewrite(filename);

Open in new window


- Do not waste resources an cycle unnecessarily around lines that might not exist.
Use actual number of lines to iterate "memoDMS.Lines.Count".

Do you want to quit reading lines if the current line is empty?

If what you read might include empty lines, then do not just quit the loop by "break" after detecting the first empty line, you have the exact number of lines to read and you will save the non-empty lines only, this way:
  for l := 0 to memoDMS.Lines.Count-1 do begin
      if memoDMS.Lines.Strings[l] <> '' then
         writeLn(filename,memoDMS.Lines.Strings[l]);
  end;

Open in new window


Or even better save the content of the memoDMS to a local variable, and then save to file form that variable, to avoid the RichEdit getting flushed with the next read before saving.

Second can you explain more on what you read and how does the other program work?
Does a TTimer do the reading from the port or you click a Button?
0
 
KevinfeeningAuthor Commented:
Thanks for the coding tips

But as I said the first program memodms id populated with data from the comms port
and can be exported to a text file and be seen on screen

The second program  memodms has not data displayed
0
 
jimyXCommented:
>   coding tips
That was side notes, not related to the issue (at least directly).

Any input for the following?
>   So you confirm that you have successfully connected to the port.
>   And you can send receive from that port but the only problem you have is that, the data received does not appear in the "memoDMS" RichEdit.

>   can you explain more on what you read and how does the other program work?
Does a TTimer do the reading from the port or you click a Button?
0
 
KevinfeeningAuthor Commented:
Coding Tips
I actually meant thanks

Any input for the following?
>   So you confirm that you have successfully connected to the port.

Successfully connected

>   And you can send receive from that port but the only problem you have is that, the data received does not appear in the "memoDMS" RichEdit.

Yes it works in the first program not the second

>   can you explain more on what you read and how does the other program work?
Does a TTimer do the reading from the port or you click a Button?

both programs the timer allows the user to see the data before copying to the text file then memdms.clear is used
0
 
jimyXCommented:
Something does not seem logical here.
If one program can connect then the other should do.

Let's go through the differences between the two programs:
1. Which Delphi version of each.
2. Can you post the code that does sending receiving from the port.
0
 
KevinfeeningAuthor Commented:
I know that's why I asked

both are on the same Delphi version

no code is used only the Nrcomm1 protocol with the settings given before for the baud rate
comport  etc and the terminal set to memoDMS

I shows data in the Memo and the other one doesn't
0
 
KevinfeeningAuthor Commented:
Changes the trichedit to tmemo and now works fine

Thanks for you time
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.