Solved

Serial Port

Posted on 2001-08-08
7
403 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
7 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 100 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:mnasman
ID: 6366928
0
 

Author Comment

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

mnasman, Looking at your URL's now.


Don
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now