Re: [fpc-pascal] Creating capturers
> On Nov 3, 2023, at 8:31 PM, Sven Barth wrote: > > If you need a catch all type, then you should use function references. There > is no need to invent yet another type. > The only thing it can not handle is the assignment of nested function > pointers (in contrast to nested functions directly), because they can only > ever be used in a function that is below the one where the nested function > was assigned which is not a guaranteed property for function references. > not always because it creates a heap allocated interfaces for every function they're used in, even if it doesn't escape the scope. Maybe this was fine for Delphi but they can't be used for anything real time outside of GUI apps. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial connection via TCP/IP sockets on RPi?
On Fri, 03 Nov 2023 17:34:09 +0100, Bo Berglund via fpc-pascal wrote: >So ser2net seems like a logical use given that the RPi3 is already there >connected by wire to the serial line and is available via VPN on the network. I >have just checked (using PuTTY via VPN) that the RPi3 does not yet have a >ser2net installed but there is a candidate 3.5-2 available via apt. > >So if I shut down the existing control software then the serial port becomes >free to use with ser2net, I guess. I have now found that there is a Linux utility named socat, which apparently is able to map a serial port to a network socket server: https://www.acmesystems.it/socat Here they actually use ser2net as the remote server point and socat to connect to it Seems like a possible path to go down. -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial connection via TCP/IP sockets on RPi?
On Fri, 3 Nov 2023 06:47:30 -0700, Wayne Sherman via fpc-pascal wrote: >Yes, there is software that bridges a serial connection over a >network. On Windows it is often called a "virtual com port" or >"virtual serial port" or "com port redirector". > >Open Source Linux: >ser2net >https://github.com/cminyard/ser2net >(ser2net is available in many distro package managers) Thanks a lot for your pointers!!! I have looked up your links on ser2net and gogled a bit, but I see many references to using the system with *Telnet* apparently to log in to a console command window or such. That is not my application, all transfers are binary in nature with data as big as 1 Mbytes but sent as packets with checksums. Question: - Does ser2net interfere with the data transfer by assuming "control chars" or the like? If so it cannot be used for my application even though it looked promising when I started to read about it. OTOH: If these mentions of Telnet are only examples and ser2net actually does not assume anything at all about the data being sent/received, then this seems like what I need. In fact the device hooked to the measure system is an RPi3B using the serial port on the RPi and it works fine using the custom automation software. But now I need to troubleshoot the Windows general user interface to the system from afar and I need the link via the network. So ser2net seems like a logical use given that the RPi3 is already there connected by wire to the serial line and is available via VPN on the network. I have just checked (using PuTTY via VPN) that the RPi3 does not yet have a ser2net installed but there is a candidate 3.5-2 available via apt. So if I shut down the existing control software then the serial port becomes free to use with ser2net, I guess. So then I need to do the Windows side as well to complete the system. I assume ser2net is a server only software so one cannot connect two ser2net to each other and then use the serial ports in both ends to complete the connection? I.e. on my location using another RPi3 to expose its serial port as an entry point towards the other end would not be possible, right? Or can ser2net in fact run as a client too and connect to another instance running as a server? If so all I need is an RPi here that can VPN over to the remote LAN (it can, I use that for subversion commits) and on which I install ser2net too but as a client and I now have a serial port to hook my Windows system into... -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial connection via TCP/IP sockets on RPi?
There is also some good info here: https://gist.github.com/DraTeots/e0c669608466470baa6c ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Serial connection via TCP/IP sockets on RPi?
On Fri, Nov 3, 2023 at 12:56 AM Bo Berglund wrote: > I am wondering if there is already available what I am needing? Yes, there is software that bridges a serial connection over a network. On Windows it is often called a "virtual com port" or "virtual serial port" or "com port redirector". Open Source Linux: ser2net https://github.com/cminyard/ser2net (ser2net is available in many distro package managers) Open Source Windows hub0hub and com0com https://sourceforge.net/projects/com0com/ Freeware (Windows): https://www.hw-group.com/software/hw-vsp3-virtual-serial-port Commercial Software (Windows and Linux): https://www.eltima.com/products/serial-over-ethernet/ Commercial Software (Windows): https://www.fabulatech.com/serial-port-redirector.html https://www.taltech.com/tcp-com/ See also: https://forums.raspberrypi.com/viewtopic.php?t=192755 https://novamostra.com/2020/04/16/serial-over-ip/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating capturers
Hairy Pixels schrieb am Fr., 3. Nov. 2023, 12:37: > > > > On Nov 3, 2023, at 2:08 PM, Sven Barth > wrote: > > > > By default the purpose of anonymous functions assigned to function > references *is* that they can escape their scope. This will not change, > because they were after all introduced for Delphi-compatibility and there > won't be any designations that the value can't escape. If the compiler > can't figure it out by its own (see above) then tough luck; use a feature > better suited for that. > > > > Ok I misinterpreted what you previously said then. > > I think Swift does this because they only have a single function pointer > type which serves all purposes while FPC has 4 distinct types. > > IMO FPC needs this also since it's not possible for libraries to know > which kind of function the caller may provide. Behind the scenes the > different types are required (global, nested, method, reference) but there > should be a way to unify these into single type. How to store the capturer > and manage its memory would be an open question though. > If you need a catch all type, then you should use function references. There is no need to invent yet another type. The only thing it can not handle is the assignment of nested function pointers (in contrast to nested functions directly), because they can only ever be used in a function that is below the one where the nested function was assigned which is not a guaranteed property for function references. Regards, Sven > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating capturers
> On Nov 3, 2023, at 2:08 PM, Sven Barth wrote: > > By default the purpose of anonymous functions assigned to function references > *is* that they can escape their scope. This will not change, because they > were after all introduced for Delphi-compatibility and there won't be any > designations that the value can't escape. If the compiler can't figure it out > by its own (see above) then tough luck; use a feature better suited for that. > Ok I misinterpreted what you previously said then. I think Swift does this because they only have a single function pointer type which serves all purposes while FPC has 4 distinct types. IMO FPC needs this also since it's not possible for libraries to know which kind of function the caller may provide. Behind the scenes the different types are required (global, nested, method, reference) but there should be a way to unify these into single type. How to store the capturer and manage its memory would be an open question though. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Running FPC in the browser...
On 10/22/23 11:20, Michael Van Canneyt via fpc-pascal wrote: > As a consequence, this means FPC can now be run in a browser. > See the screenshot at Well done to everyone involved. That is amazing, and yes, I can think of many possibilities this could be used for. Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Serial connection via TCP/IP sockets on RPi?
I am wondering if there is already available what I am needing? My situation is the following: I have a remote installation of a measuring equipment, which communicates through RS232 to an RPi3 interface unit. On that there is a service that handles the data sent both ways. But it is geared towards automatic operations so there is no direct connection to the target system. Now I have a need to debug a Windows application that is also designed to talk to the same type of equipment via RS232. But the problem is that I am across the ocean from the equipment, so I need to insert some network link between me and the remote system. I have a VPN connection to the remote location so I can work on the RPi3 command line (and actualy also via VNC on the GUI). So a socket client/server solution seems possible. What I want to do is this: - close down the existing service on the RPi3 that handles the data recording. - Use an RS232 <=> TCP/IP socket service on the RPi3 to transfer data to/from the device - Set up a TCP/IP socket <=> RS232 handler on a local RPi4 in my location - Connect the Windows RS232 to the RPi4 by wire - Use the application under debug normally via RS232 from Windows but have the RPi pair move the data between the endpoint RS232 connections via TCP/IP through the VPN connection. Before I start coding the RS232/Socket interface server and client parts myself I would like to know if someone here knows about an already existing Lazarus open source project that implements my wanted functionality? -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Creating capturers
Hairy Pixels schrieb am Fr., 3. Nov. 2023, 02:00: > > > > On Nov 2, 2023, at 1:44 PM, Sven Barth > wrote: > > > > Now for nested as well as anonymous routines the compiler determines > whether a capturer is required at the point that the nested or anonymous > routine is assigned to a function reference (cause otherwise it can be > handled as a nested function or even a function or method pointer). This > requirement is detected during the parsing of the routine. > > On second thought I had some questions about this part. From what I see > FPC always allocates the interface when reference pointers are used but > what you write suggests maybe the compiler will demote the type to > something more optimized (like a nested function). We talked about this at > length before but I don't think anything was decided yet. > > for example: > > procedure DoThis; > var > proc: reference to procedure; > begin > proc := procedure > begin > end; > proc(); > end; > > doesn't need the heap allocated instance because the function reference > never escapes the scope and it has no captured variables so it could be > demoted to a global function even of nested. > As soon as an anonymous function gets assigned to a function reference it *must* be converted to a method of the capturer and an interface to that must be assigned to the function reference. Because that's what function references are: interfaces. If you don't want that then call the anonymous function directly without assigning it to anything or assign it to a nested function pointer and call that. In *theory* the compiler could detect that "proc" doesn't leave the scope and that it's value is "constant" (namely a function) and thus could optimize that, but that requires quite some improvements to the optimizer. > In fact Swift requires you to mark closures types as "@escaping" if they > can escape the current scope so that the compiler can be optimize them. > This is the feature I was thinking FPC needs. > By default the purpose of anonymous functions assigned to function references *is* that they can escape their scope. This will not change, because they were after all introduced for Delphi-compatibility and there won't be any designations that the value can't escape. If the compiler can't figure it out by its own (see above) then tough luck; use a feature better suited for that. Regards, Sven > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal