Recent

Author Topic: LazSerial wait for incoming data  (Read 946 times)

andromeda

  • New Member
  • *
  • Posts: 12
LazSerial wait for incoming data
« on: November 27, 2020, 03:33:08 pm »
Hi,
How to implement wait for incoming data with lazserial ?

The com port is connected to interface keyboard, i need to wait until keypressed as kbhit in c language or readkey in pascal.

for example with WaitingData ?

Code: Pascal  [Select][+][-]
  1.  
  2. while (ser.WaitingData = 0) do ;
  3.  

Thanks for your help.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: LazSerial wait for incoming data
« Reply #1 on: November 27, 2020, 11:27:50 pm »
This forum has a nice search feature down on the lower left..

Put in TLazSerial and I bet you will find the answer to your questions
The only true wisdom is knowing you know nothing

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: LazSerial wait for incoming data
« Reply #2 on: November 28, 2020, 01:29:48 am »
hello,

for example with WaitingData ?

Code: Pascal  [Select][+][-]
  1. while (ser.WaitingData = 0) do ;
  2.  
your code is a cpu eater.

Are you in a GUI program  ? 
if yes use this :
Code: Pascal  [Select][+][-]
  1. while (ser.WaitingData = 0)  
  2.      do
  3.         begin
  4.           application.processMessages;
  5.           sleep(100);
  6.         end;

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: LazSerial wait for incoming data
« Reply #3 on: November 28, 2020, 01:56:22 am »
Well I thought the component already has a thread that runs and I thought there were events already in place?

OnRxData, OnStatus etc.

In anycase, one can post a user message from the Thread to the main thread and you simply implement a message handler.
The only true wisdom is knowing you know nothing

andromeda

  • New Member
  • *
  • Posts: 12
Re: LazSerial wait for incoming data
« Reply #4 on: November 28, 2020, 08:44:09 pm »
is on apply console, not a gui.

 

TinyPortal © 2005-2018