Re: [fpc-pascal] Serial to TCP gateway in FPC?
On 27.06.2017 14:37, Lukasz Sokol wrote: But I'd put the serial port handling calls, blocking or not, into a thread separate from main anyway. Of course. (The "short message says this, too.) (p.s. why not reply on the group still? :) ) I did send the message to the group, as well, but those messages mostly are delayed by a day or more. -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial to TCP gateway in FPC?
On 27.06.2017 12:10, Lukasz Sokol wrote: The serial handling thread would poll the serial port ... As already pointed out above (in a very short message) no need for polling, just use blocking OS calls. -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial to TCP gateway in FPC?
On 27.06.2017 00:28, Bo Berglund wrote: I have the concern that I am using Application.Processmessages, which I believe cannot be used in a console program. How can I replace it? TThread.Queue is available in an appropriately done "console application". As already discussed several times in the past, I did a draft for an "active" version of a "no-GUI application" that allows for a main thread executing such queued TThread and TTimer Events. (It also has Application.Processmessages, Application.QueueAsyncCall,... ). You can test it, but I am not forcing this project much, as with modern hardware (such as the Pi3) there is not much pressure any more to avoid installing a GUI framework. -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Mutual Reference Interfaces and Memory Leaks
On Tue, Jun 27, 2017 at 11:52 AM, African Wild Dogwrote: > There are some parts of your article which are in English and you have added > a link to another article, so it helped me a lot. Thanks for your reply. You are welcome. Regards, Marcos Douglas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Mutual Reference Interfaces and Memory Leaks
2017-06-26 12:45 GMT-03:00 Marcos Douglas B. Santos: > > Hi, > > I wrote an article about it https://goo.gl/Lij4hu > But you need to translate from Portuguese to English. > > Best regards, > Marcos Douglas > There are some parts of your article which are in English and you have added a link to another article, so it helped me a lot. Thanks for your reply. I researched a bit more in google and found interesting the approach used in the Spring4D framework. I think it's compatible with Free Pascal. For the compiler devs, will the compiler attributes features ([unsafe] and [weak]) be implemented in the near future? Regards ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial to TCP gateway in FPC?
On 26/06/17 23:28, Bo Berglund wrote: [...] > > NEXT: > It looks like I will have to rewrite my relaying program now used in > Windows for the conversion to TCP from RS232 to also work as the > replacement for ser2net on RPi3. This way I can monitor the data > better and check time intervals etc. > > My problem here is the fact that the RPi is headless so the GUI > program I have written with Lazarus will not work. Instead I have to > make a console version that can run on RPi for the test and here I > have the concern that I am using Application.Processmessages, which I > believe cannot be used in a console program. > How can I replace it? > > If you are comfortable with thread programming, you could have a thread handle the hardware / serial handling (by keeping the 'messages' in a 'queue' or 'queues' (one outbound, one inbound). The serial handling thread would poll the serial port and handle serial sending timing etc, and put the received data into the rx 'queue'. Depending on how fast the serial communications are, the thread could then ThreadSwitch to give up the reminder of its time slice if not needed, and sleep for the rest of the time. Then your main program would periodically check the queues and depending on whether it needs to do something or not, will do it and then threadswitch() and sleep(), The main thread would then be responsible for network / hi level 'protocol' communication, data conversion (e.g. you could assume network data 'text' encoded in base64, or even text based json, that is then converted to/from binary form for serial) IIRC some network handling components/libraries use threads of their own. If you wanted to use 'just' network sockets, you'd probably need to handle network 'low level' communications in threads anyway. hope this makes (some) sense _l. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial to TCP gateway in FPC?
On 26/06/17 22:30, Bo Berglund wrote: My problem here is the fact that the RPi is headless so the GUIprogram I have written with Lazarus will not work. Instead I have tomake a console version that can run on RPi for the test and here Ihave the concern that I am using Application.Processmessages, which Ibelieve cannot be used in a console program.How can I replace it? You're obviously correct that APM doesn't exist in a text-only program because it's part of the LCL. But I think you need to ask yourself why you need to /replace/ it, rather than just removing it. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal