Solved

nrComms

Posted on 2014-03-07
10
478 Views
Last Modified: 2014-03-09
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
0
Comment
Question by:Kevinfeening
[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
  • 5
  • 5
10 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 39914361
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
 

Author Comment

by:Kevinfeening
ID: 39915254
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
 
LVL 24

Expert Comment

by:jimyX
ID: 39915469
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Kevinfeening
ID: 39915517
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
 
LVL 24

Expert Comment

by:jimyX
ID: 39915544
>   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
 

Author Comment

by:Kevinfeening
ID: 39915550
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
 
LVL 24

Expert Comment

by:jimyX
ID: 39915559
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
 

Author Comment

by:Kevinfeening
ID: 39915568
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
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 39915691
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
 

Author Comment

by:Kevinfeening
ID: 39916676
Changes the trichedit to tmemo and now works fine

Thanks for you time
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Not able to call Delphi XE10 dll function from Delphi 6.0 4 53
Delphi Seattle StructureView color 1 31
Broadcast a message using ICS 2 48
Posting a string with PostMessage 23 43
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

738 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