[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

SERIAL PORTS AND DELPHI

Example: My company has a machine that sends the registration of customers through the serial port to the computer, how do I get this data and insert them in 1 memo of my program before they go to the computer? is still necessary that they go to the computer to be stored in 2 places in the memo and the computer.
0
MelissaCandyGirl
Asked:
MelissaCandyGirl
  • 5
  • 3
  • 2
  • +1
1 Solution
 
twocandlesCommented:
Do you mean you have 2 different apps? If so, you won't be able to read the serial port from 2 apps, since the 2nd one that tries to open the serial port will get an error ("port already open" or "cannot open file"). If you want to display the data as it comes in, you will have to write 1 application for both write to memo and store it wherever you want.
0
 
MelissaCandyGirlAuthor Commented:
no. since the data comes from the serial port, my program that I am trying to open the door and get the data, then he closes the door. and here the company's other program opens the door again and get the data.
0
 
twocandlesCommented:
But then the data needs to be sent twice in order to be read by two apps at two different times...

Or you can write the data back to the port. At my company we're using a similar approach: we have a cable that connects COM1 and COM2 on the same machine in cross-mode. You can write to COM2 and read from COM1 using the same computer.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MelissaCandyGirlAuthor Commented:
Finally...  how do I get this data and insert them in 1 memo of my program?
0
 
8080_DiverCommented:
how do I get this data and insert them in 1 memo of my program before they go to the computer? is still necessary that they go to the computer to be stored in 2 places in the memo and the computer.
This sounds like you are trying to intercept the data so that you can display it in a field on a form in your application but you still want the data to wind up "at the computer".
Where is the data when it is "at the computer"?  Do you mean that it is being put in a database or what?  Also, the term "memo field" sounds like you may be used to working with MS Access . . . Are you saying that you want to write this to a text field that has multiple lines?  If so, do you want each received piece of data to be written on a separate line?
Are you having trouble reading the serial port?
If you can answer these questions I can probably help you.  I've worked with serial communications in Delphi.
0
 
MelissaCandyGirlAuthor Commented:
Greetings 8080_Diver, data is sent by the computer through the serial port, has an automated program that already handle such data and do the work that has been programmed for you, if a register.
my problem is, we assume that I get this program, do not use it more, then I want my program, which will take the data by serial port and put in a memo, but this is just one example that I taking these data at 1 memo I can do what you want then, records and more.
I know nothing about serial ports and read the data that pass through it, so I wanted this basic example.
0
 
8080_DiverCommented:
I know nothing about serial ports
Now, that is going to be a problem.  Dealing with serial ports is not as simple as dropping a TADOCONNECTION and a TADOQUERY component on a DataModule and setting the aprameters and then off you go.  There are several factors to consider when working with serial ports, things like:
  • Is there a carrier signal (i.e. is the port connected to anything)?
  • Time outs,
  • Is there data available at the port?
  • Getting the data before it gets over written;
  • Do you need to send an acknowledgement?
  • What do you do if the data is garbages (i.e. do you send a NACK instead of an ACK)?
And that is just to mention a few of the points.  No offense intended but this is definitely not for the novice or the faint of heart!
There is a set of components that I use for this purpose and I have a manual that is something like 1200 pages for them.  The components are now available for free (that's the Good News) and you can probably find them by searching for their comercial name of  "Asynch Pro".  The Bad News is, as I mentioned, the manual I have is rather thick and the components, while wonderful for working with serial ports, are more than a bit complicated . . . and they are the best ones I know of.
0
 
MelissaCandyGirlAuthor Commented:
8080_Diver, thanks dear, I'll download the manual and study.
Finally, you can make an example of the code of practice and get the data from the serial port and all go to a memo?
can be in any way with any parameter, and any point on your preference, just to have me as an example study.
0
 
MerijnBSr. Software EngineerCommented:
To be honest, I think 8080_Diver gives a little over complicated point of view of things.

MelissaCandy: what do you know about the data which is sent out of the serial port, the protocol?
0
 
8080_DiverCommented:
@MerijnB,
Well, IMHO, working with Serial Ports is complicated.  I've done it many times over the years and the simple solutions usually turn out to be "designed for Success (which means they only work if everything is working perfetly and, if something goes wrong, they blow all apart and don't provide muc in the way of information about why).  If you don't care about getting all of the data and you don't care about whether you get the same data twice in a row, then there are some really simple solutions.  It is not that there is a lot of "heavy lifting" but, rather, that there a lot of little Lego blocks that you need to remember to put together in the right order.
@MelissaCandy&,
Unfortunately, I don't have a demo app handy and I don't have the time to create one right now.  (Something to do with having a full time position and trying to have a personal life ;-).  I will say that, if you read the manual and download the components, I believe there are some demo apps that are also available as downloads.  
The manual also has a fantastic explanation of serial communications and what all you have to deal with when using serial ports for data communications.  It's kind of like bulding a small end table from a stack of boards.  If you have never done it before, it seems amazingly complicated; however, if after you've done ift a few times, it isn't so complicated . . . mostly because you pretty much know what you're getting into. ;-)
0
 
MelissaCandyGirlAuthor Commented:
thanks dear
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now