[Lazarus] Using 5dpo for serial comm...
Bo Berglund
bo.berglund at gmail.com
Sat Oct 9 23:33:05 CEST 2010
On Wed, 06 Oct 2010 23:11:57 +0200, Bo Berglund
<bo.berglund at gmail.com> wrote:
After I got 5dpo operational on Ubuntu I went back to my old Delphi
code, which I intend to port over to Lazarus, to remind me what it is
doing.
I have to perform some surgery on it to allow for a different comm
component when used from lazarus at the very least.
Then I found that when sending data to the instrumentation there is
one case when a memory upload is being done that involves a large
amount of data, up to 1 Mb on occasion.
For this reason I have code that splits the data into chunks of 512
bytes and sends those to the comm component only after checking the
state of the transmit buffer.
Like this:
{code}
repeat
{send data from Cmd in chunks of 512 bytes}
sBuf := Copy(Cmd, 1, 512);
Delete(Cmd,1,512);
FComm.WriteString(sBuf);
while FComm.TxWaiting > 16 do
begin
Application.ProcessMessages;
Sleep(1);
end;
{Here was code for the progress bar update}
until Cmd = '';
{code}
One purpose of this is to not overload the transmit buffer and another
is to be able to track the progress of transfer by incrementing a
progress bar for each 512 bytes sent.
But with TSdpoSerial I can't find any such property as TxWaiting or
similar to check.
Is it not needed or possible? Maybe the component can handle any size
string I send to it without choking?
But what about the user feedback? I would really want to be able to
show the actual data flow to the user in a progress bar since the
whole operation takes considerable time.
So how can I know how many bytes have actually left the transmit
buffer (or how many that still remain to be sent).
--
Bo Berglund
Developer in Sweden
More information about the Lazarus
mailing list