11/7/2017
Posted by 
Delphi Serial Port Example Rating: 6,3/10 280reviews
Delphi Serial Port Example

Jun 22, 2014 Another is the that all the current supporters of Async Pro are Delphi. IO lines -not parallel port). And of course, USB is serial. Serial Port Component.

I am still having issues with the TComPort component but this time is not the component itself is the logic behind it. I have a device witch sends some ascii strings via serial port i need to prase those strings the problem is the computer reacts very fast so in the event char it captures only a part of the string the rest of the string comes back later. So parsing it when it is recived makes it impossible. I was thinking in writing a timer witch verify if there was no serial activity 10 secons or more and then prase the string that i am saving into a buffer. But this method is unprofessional isn't there a idle event witch i can listen.Waiting for the best solution for my problem.

Assume you use Djean Crnila's et al TComport (several components are called 'TComport'). This issue might be related to the data event trigger but also possible the baud rate of your serial device is set to a rate different from the rate of your comport control. If your device sends packets once every few ms, you should easily be able to capture and parse the entire data packet if the packet is a reasonable length. Does the device send an end of packet control character? -makes it easier. If you provide a more info about the device, received packet etc.

Someone might be able to provide help. – May 11 '12 at 13:56 •.

Don't use a component! Here's an example how to open a com port with code.then you can use the WriteFile and ReadFile functions to write and read data to and from the com port. Var hCommFile: THandle; procedure TForm1.Button1Click(Sender: TObject); var NumberWritten, BytesRead, BytesToRead: LongWord; Data: String; Buffer: PChar; begin hCommFile:= CreateFile('COM2', GENERIC_WRITE or GENERIC_READ, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); //Change COM1 to the comport you are using. If hCommFile = INVALID_HANDLE_VALUE then begin ShowMessage('Unable to open COM1'); Exit; end; NumberWritten:= 0; Data:= 'Data come here.'

; if WriteFile(hCommFile, PChar(Data)^, Length(Data), NumberWritten, nil) = False then ShowMessage('Unable to write to COM1'); //Write. BytesRead:= 0; BytesToRead:= 5; //Change it to as much as many bytes you want to read. If ReadFile(hCommFile, Buffer, BytesToRead, BytesRead, nil) = False then ShowMessage('Unable to read from COM1'); //Read.the variable named Buffer will contain the data recieved. End; //Don't forget to close the COM port. Procedure TForm1.Button2Click(Sender: TObject); begin CloseHandle(hCommFile); end; I haven't tested it but it should work. Hope that helps.

GLes 'Today is the first day of the rest of your life' /gLes@hab. Winhex 12.0 Sr 13 Crack there. hu/.