Sorry for my short of knowledge of Lazarus. All done in Main Have ad a if/waitingData, makes total: serial.writeData( stOut ); if ( serial.waitingData 0 ) then stIn:= serial.readDate; label4.caption:= stIn; Results in compile-error: identifier idents no member 'waitingData' So, serial at itself is 'known' because serial.writeData and serial.readData are doing ok. Tried the following: Placed in interface-section of main: serial: TBlockSerial; Results againin compile-error: identifier idents no member 'waitingData' Then I removed 'serial: TBlockSerial;' out of interface-section. Then placed in interface-section: myTestSerial: TBlockSerial; And changed in the write-read code: if ( serial.waitingData 0 ) then stIn:= myTestSerial.readDate; label4.caption:= stIn; Now, I don't get compile-error!
But the programm hangs imideately, no response, and shows error as in the picture. I can stop it with the red-stop-button in the LAzarus-IDE. Anyone a hint for me?
So far so good! For testing and see thing clears I send from Arduino secuently a 27 char string: ( instead of a string filled with 24 'values' ending with 'end') 'N888end' N: string with numbers 'Laabbbcccdddeeefffggghhhend' L: string with letters Now I can see if a diplayed string on my Lazarus form is from one and the same sended string or an mixed string from 2 sended string! After a while and lots of coding and 'adjustments' I got a stable displayed string. ( apearently I don't need a delimiter in Lazars, but I DO in mikropAscal Arduino when receving from RS232 ) Next thing I wanted to run the application for a long time and 'catch' wrong strings by just checking: first char is it an 'L' or an 'N'? If not: increment and display the errornumber on my form.
As learned the first char in a string is placed at position 0 as in stringIN0, but then I found out i had to check stringIN1. See, picture. Ok, not a big deal but what does it mean?
Still, have to do troubleshouting etc, sometimes the application hangs soon, other times it runs longer. ( could it because of debug-mode instead of runnng it as a 'free' programm? ) By the way somehow I don't trust the timers, or maybe I have a programm-error/mistake. I also need some code if there's nog data OR time out, see.CODE 'cause it reads even when there is a time out OR no dataReady.
I see several problems. (1) The loop will fail to run if there are 27 or more characters in the comm buffer (2) The timeout value is never reset, so eventually your delay loop will only sleep for 1 mSec and then exit (3) I don't understand what you are trying to accomplish with the loop, delay, and reading the input while the buffer contains less than 27 characters. You might want to bypass the dataRead until the buffer has at least the 27 characters that make up the string. So when waitingData =27, you can do the dataRead which will read the entire string and remove 27 characters from the buffer. There is no need for your timeout loop, as the dataRead will read either a packet or a terminated string. You can check the length of the string to see if it is the expected 27 characters.
Something else to consider is how strings are defined in Pascal and Lazarus. Gpsa engineering data book 13th edition free download. A 'short' string has its length (up to 255 characters) in a byte at stIn0, and a 'wide' string uses two bytes to allow up to 65535 characters. There is also a PChar which is a null terminated string.
Here is an explanation I got from the comp.lang.pascal.delphi.misc usenet newsgroup. I think I see what you are trying to do. I assume that timer2 is an ISR that runs at a certain rate to poll the serial port and display the string. So you have a loop that runs until there are at least 27 characters in the buffer, or timeout occurs. If there is a timeout then it exits the ISR and waits for another timer2 interrupt. It seems that it would be better to use the 'FOnRxData: TNotifyEvent;' and code an event handler to process the data.
And you might want to read the serial port one byte at a time so you can detect the start character and build the string until the last character is received, and then display the result. If the strings are being sent at a comfortably readable rate (up to 5/sec), you should be able to see the data change.
You might also want to display the strings in a TMemo box so you can observe the sequential strings. Timer2 sends to Arduino and Arduino repsonses immidiately with following code: ( by the way, I removed timer1 that indicated the system time each 1000ms ) I understand I have to change the Lazarus code and I need top learn more en get more understanding. Next week, gonna work and use your suggestions from your previous posts! Tnx in advance! Here my Arduino mikroPascal code ( only the main-code and procedure. Not the init etc ) After receiving/reading the string coming from Lazarus, the Arduino imidiately responds! Just used the Usart Terminla and that shows that the string coming from Arduino are sends 100% Ok.
Defenitly I have to work on the lazarus part! TLazSerial v0.1 Serial Port Component for Lazarus (windows and linux). By Jurassic Pork 03/2013 This library is Free software; you can rediStribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is diStributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; withOut even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Library General Public License for more details. You should have received a Copy of the GNU Library General Public License along with This library; if not, Write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA, USA.
Based on: - SdpoSerial v0.1.4 CopyRight (C) 2006-2010 Paulo Costa [email protected] - Synaser library by Lukas Gebauer - TcomPort component Features: Changed: baudrate values. Stop bits new value: 1.5 new event: onstatus new property FRcvLineCRLF: if this property is true, you use RecvString in place of RecvPacket when you read data from the port. New procedure ShowSetupDialog to open a port settings form: the device combobox contain the enumerated ports. New procedure to enumerate real serial port on linux ( in synaser). Demo: a simulator of serial port gps + serial port receiver: you can send NMEA frames ( GGA GLL RMC) to the opened serial port (start gps simulator). You can change speed and heading.
In the memo you can see what is received from the opened serial port. In the status bar you can see the status events. Hi, after a break, started again! Took antoher direction.with succes! Keep in mind: - Lazarus sends a string each 'delta-seconds', in my code: 200ms. There's only 1 timer in the code.
Arduino waits for string to receive and IMMEDIALETY ( the smallest response-time ) returns a string after receiving what switches between Labcdend and N1234end ( like a flip-flop ) Therefore I can do this in Lazarus: ( later it will be more sophisticated, due time-outs and more string-error-checking etc ) Still, the code is far from ok and isn't free from hanging, but now allmost each received string by pc is ok. And now I don'ts have that strange acting from stringlenght. ( still have to investigate the comment about PAnsiChar etc ) And in case of a hang, this is after a much longer time. ( basicly the code: ) Timer.
On 09:31 AM, Paul Breneman wrote: On 02:32 AM, Bob Axtell wrote: This newbie is familiar with COMPORT from WINSOFT from my olden Delphi days, but I can no longer afford it for one program. Does anybody know of a free/cheap component? Any how does it install? www.CtrlTerm.com uses Synapse and Synaser and there is a port for Lazarus.
I should have mentioned that www.CtrlTerm.com is a simple example of how Synapse and Synaser can be used (it is not the component itself). Best regards, Paul www.TurboControl.com - Lazarus mailing list. On 10:53 PM, Roberto P. Wrote: I'd like to point out that CPortLaz is multithreaded Does it work similar to AsyncPro? In fact, IMHO, it would be desirable to have a component that internally uses TThread to handle blocking ports (either using just a byte-FIDO - this is what AsyncPro does - and/or allowing the user to implement a protocol within the Thread's 'Execute' ), and when some information from the port is received (at least one byte or when the protocol handler issues a 'ready'), does an Event (aka queued callback) to the main thread. The main thread call of course needs to be 'scheduled' using means such as TThread.Queue or Application.QueueAsyncCall.
(As at the time when AsyncPro was released, Delphi did not provide either, AsyncPro uses Windows Messages by directly accessing the Windows API, which happily is not necessary with Lazarus). Unfortunately Thread - Mainthread signaling is only easily provided in Lazarus in the GUI based Widget Types. (NoGUI still needs an appropriate enhancement.) But of course the user (or even a ComPort Unit) could provide a usable Main Loop implementation.Michael - Lazarus mailing list. On 10:53 PM, Roberto P. Wrote: I'd like to point out that CPortLaz is multithreaded Does it work similar to AsyncPro? In fact, IMHO, it would be desirable to have a component that internally uses TThread to handle blocking ports (either using just a byte-FIDO - this is what AsyncPro does - and/or allowing the user to implement a protocol within the Thread's 'Execute' ), and when some information from the port is received (at least one byte or when the protocol handler issues a 'ready'), does an Event (aka queued callback) to the main thread. The main thread call of course needs to be 'scheduled' using means such as TThread.Queue or Application.QueueAsyncCall.
(As at the time when AsyncPro was released, Delphi did not provide either, AsyncPro uses Windows Messages by directly accessing the Windows API, which happily is not necessary with Lazarus). Unfortunately Thread - Mainthread signaling is only easily provided in Lazarus in the GUI based Widget Types. (NoGUI still needs an appropriate enhancement.) But of course the user (or even a ComPort Unit) could provide a usable Main Loop implementation.
Michael Schnell wrote: On 10:53 PM, Roberto P. Wrote: I'd like to point out that CPortLaz is multithreaded Does it work similar to AsyncPro?
In fact, IMHO, it would be desirable to have a component that internally uses TThread to handle blocking ports (either using just a byte-FIDO - this is what AsyncPro does - and/or allowing the user to I agree. My mods to serial.pp were accepted into trunk a few weeks ago, but that is explicitly unthreaded since it's intended as the lowest layer for cases where- as an example- timestamps or changes to physical control lines need to be enqueued with the character stream. implement a protocol within the Thread's 'Execute' ), and when some information from the port is received (at least one byte or when the protocol handler issues a 'ready'), does an Event (aka queued callback) to the main thread. With the caveat that this sort of thing needs to be implemented very carefully so that it can interwork with e.g.
A terminal emulator component. I think the two would need to be designed together, even if in practice one was coded first. Until then, FPC's thread handling is sufficiently good that an application-specific hack isn't particularly difficult. Mark Morgan Lloyd markMLl.AT. Uk Opinions above are the author's, not those of his employers or colleagues - Lazarus mailing list.
Op 06-05-14 21:08, Zaher Dirkey schreef: Try Hi, Out of curiosity I looked into this, and I downloaded the source from sourceforge. Trying to install I found problems: minicommons never compiled for fpc/lazarus? Because some function declarations are different from the forward declarations.
Lazarus Program
Solved this for now by making them identical. More problematic: minilib lacks HTMLKeywords.inc. There I'm stuck.
I would like to try the pos-library. Lazarus mailing list. On Thu, May 8, 2014 at 10:37 PM, Koenraad Lelong wrote: op 06-05-14 21:08, Zaher Dirkey schreef: Try Hi, Out of curiosity I looked into this, and I downloaded the source from sourceforge.
Trying to install I found problems: minicommons never compiled for fpc/lazarus? Because some function declarations are different from the forward declarations. Solved this for now by making them identical.
More problematic: minilib lacks HTMLKeywords.inc. There I'm stuck. I would like to try the pos-library. Lazarus mailing list. Never mind those functions. I later read that I needed to use release, in stead of trunk. There all was OK.
I will try again ASAP. I spoke a bit too soon. I downloaded release (download snapshot). Then I tried to compile lib/minicommons. I spoke a bit too soon.
I downloaded release (download snapshot). Then I tried to compile lib/minicommons. I get the same errors I had before: /lib/mnFields.pas(750,20) Error: Calling convention doesn't match forward /lib/mnFields.pas(213,14) Hint: Found declaration: TmnFields.QueryInterface(constref TGuid,out ):LongInt; CDecl; /lib/mnFields.pas(798,20) Error: Calling convention doesn't match forward /lib/mnFields.pas(205,14) Hint: Found declaration: TmnFields.AddRef:LongInt; CDecl; /lib/mnFields.pas(803,20) Error: Calling convention doesn't match forward /lib/mnFields.pas(206,14) Hint: Found declaration: TmnFields.Release:LongInt; CDecl.