On Wed, 21 Jun 2017 08:02:00 +0000, Mark Morgan Lloyd <markmll.fpc-pas...@telemetry.co.uk> wrote:
>> What about Linux (Raspberry Pi)? Is the com port name simply ttyUSB1or do I >> have to use the full /dev/ttyUSB1? > >You *definitely* have to use the name as given. You're opening a file in >the filesystem tree, not an internally-reserved name. OK, thanks! I am now creating a super-simple proxy app which will open a serial port and connect to a TCP server. Then it will send all incoming data on the serial port to the TCP server and all incoming TCP server data back to the serial port. Right now I am doing a Lazarus GUI app on Windows, but eventually I will move the code into a command line app. I have used the serial unit in FPC to handle the serial port connection and am now looking for the TCP Client component to use. I have used Indy's TIdTcpClient in the past, but it required me to create a thread to handle the data transfers, and I don't really like complicating matters like that for this (seemingly) simple project. I looked at the socket unit, which has the advantage that it is part of FPC. But the documentation is very confusing... For example I was looking at fpconnect: https://www.freepascal.org/docs-html/rtl/sockets/fpconnect.html and noted that the example does NOT use fpconnect at all, instead it uses a depreciated Connect method with strange arguments... Is there some updated documentation somewhere? Anyway: The functions of this proxy app are only: - Open the specified serial port and set it to the required baudrate - Open a connection to the TCP server port - Now somehow run a loop as follows: - Serial data available? If so read them and send to the TCP server - TCP data available? If so read and send through the serial port - Stop condition set? If so close down TCP and serial connections and exit the program. (Don't know how this will work) - Repeat loop again Two issues here: 1) How do I enter a loop in a GUI application? In a command line application it is just going to be part of he main program code. 2) How do I stop the program from running at 100% CPU utilization (on Windows)? And of course how to use the sockets unit properly? -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal