Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Serial Port

Posted on 2001-08-08
7
Medium Priority
?
416 Views
Last Modified: 2010-04-06
I know Delphi isn't designed for creating device drivers but I think I can use it to send data to a serial port.  

1) Is this done with basic Delphi commands or is it a WinAPI type command?

2) Is there a resource online that will teach me the essentials?


Note: I am going to receive a box that attaches to the serial port.  I need to be able to send a string of ascii characters and read a response.

Thanks in advance for your assistance.
Don
0
Comment
Question by:d32coder
[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
7 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 400 total points
ID: 6366917
I use a free open source component called Async, I use it for all my serial interfaces, tell me your E-Mail and I'll send it to you.

Motaz
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6366928
0
 

Author Comment

by:d32coder
ID: 6367483
Thanks Motaz: d32coder@home.com  

mnasman, Looking at your URL's now.


Don
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:VSF
ID: 6368353
Sent some nice components to you via e-mail <d32coder@home.com>!
Hope they help you!


VSF
0
 
LVL 17

Expert Comment

by:inthe
ID: 6368485
hi,
just to mention that while the components above certainly make life easier ,they are wrapper for using the WinApi .
Api's like :
CreateFile()
ReadFile()
WriteFile()
Get/SetCommState()

etc are the ones mainly used.

below is example to initilize modem on Com4:

 var
  ComFile : THandle;
  TimeOuts: TCommTimeouts;
  DCB: TDCB;
  ReadBuff: array[0..100] of char;
  NumBytes: DWord;
 begin
  ComFile := CreateFile(PChar('COM4'),GENERIC_READ +
GENERIC_WRITE,0,nil,OPEN_EXISTING,FILE_FLAG_WRITE_THROUGH,0);
    if ComFile = INVALID_HANDLE_VALUE then
    begin
     ShowMessage('Unable to open COM4');
     exit;
    end;
    TimeOuts.ReadIntervalTimeout        := 100;
    TimeOuts.ReadTotalTimeoutMultiplier  := 100;
    TimeOuts.ReadTotalTimeoutConstant    := 0;
    TimeOuts.WriteTotalTimeoutMultiplier := 0;
    TimeOuts.WriteTotalTimeoutConstant  := 0;
    SetCommTimeOuts(ComFile,TimeOuts);
    GetCommState(ComFile,DCB);
    DCB.BaudRate := 5600;
    DCB.ByteSize := 7;
    DCB.StopBits := ONESTOPBIT;
    DCB.Parity  := EVENPARITY;
    SetCommState(ComFile,DCB);
    ReadBuff := '';
    StrPCopy(ReadBuff,'ATZ' + #13 + #10);
    WriteFile(ComFile,ReadBuff,Length(ReadBuff),NumBytes,NIL);
    ReadBuff := '';
    ReadFile(ComFile,ReadBuff,100,NumBytes,NIL);
    CloseHandle(ComFile);
end;

nice to know how things are done but i would still get and use some of the components mentioned above to save much time.

Regards Barry
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6370261
listening :-)
0
 

Author Comment

by:d32coder
ID: 6370293
I honestly didn't expect so many responses so quickly.  I should receive the box UPS in the next day or so.  I'll report on it (and choose an answer) as soon as I get it connected.

Note: Please do not send me "cracked" components.  I'm in the software business and do not appreciate piracy.

Don
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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