[fpc-pascal] Fpc make questions...
I am not very informed about how make works when building fpc installations, I have just used commands I have gathered online and it has worked... Now I would like to know: 1) Does make clean inside the fpc source dir erase ALL of the binaries produced by an earlier build inside that source tree? 2) If so, does these two versions of "make all" build for ARMv7 and ARMv6 respecitively: make all FPC=/home/pi/dev/ppcarm OPT="-dFPC_ARMHF" make all FPC=/home/pi/dev/ppcarm OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" 3) Does the following command overwrite existing files from an earlier attempt so the CPU target can be replaced? For ARMv7: make install OPT="-dFPC_ARMHF" PREFIX=/home/pi FPC="/home/pi/dev/ppcarm" For ARMv6: make install OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" PREFIX=/home/pi FPC="/home/pi/dev/ppcarm" 4) Do I also need to switch the seed compiler /home/pi/dev/ppcarm (3.0.4) between v6 and v7 or can any of the two work to build correctly fpc itself? The reason I am asking is that I need to switch my system from building ARMv7 binaries to build ARMv6 binaries and I don't want to start over from scratch on this RPi, which I have used for some time... Hopefully make clean make all make install with the proper options will do the trick TIA.. -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Sending Hex codes over TCP/IP
I'm trying to figure out how to send and receive Arrays of Bytes or perhaps a buffer of hex codes over TCP/IP, but everything I find seems to want to send and receive strings. Can someone please point me in the right direction on how to do this? Basically I want to make a connection to an IP address at a specific port and then send some bytes to the server then get some bytes back from the server. The data sent is just hexadecimal and it can't be followed by linefeeds or carriage returns, and I want to just receive the bytes back into a buffer of some sort so I can look at it one byte at a time. I prefer some kind of array of bytes so I can just access the bytes with elements of the array. I've been going round and round trying to figure this out. Any help is greatly appreciated James ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sending Hex codes over TCP/IP
On Fri, 11 Sep 2020, James Richters via fpc-pascal wrote: I'm trying to figure out how to send and receive Arrays of Bytes or perhaps a buffer of hex codes over TCP/IP, but everything I find seems to want to send and receive strings. Can someone please point me in the right direction on how to do this? Basically I want to make a connection to an IP address at a specific port and then send some bytes to the server then get some bytes back from the server. The data sent is just hexadecimal and it can't be followed by linefeeds or carriage returns, and I want to just receive the bytes back into a buffer of some sort so I can look at it one byte at a time. I prefer some kind of array of bytes so I can just access the bytes with elements of the array. I've been going round and round trying to figure this out. Any help is greatly appreciated You'll need to be more specific. What classes or routines are you using (or trying to use) for this ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sending Hex codes over TCP/IP
A TCP connection is no more than a pair of byte streams - one in each direction. You have to define your own structure for each byte stream and the procedures for use i.e. a protocol. lt will be easier if you can use a standard protocol such as http. An http POST is one way to send an array of bytes to a server and to receive a response. if you want to define your own protocol then you could send your array of bytes as an integer length followed by the bytes encoded one after the other. If you want your protocol to be platform independent then be careful to define the bit order (little endien or big endien) and how multibyte integers are encoded (low order byte first or high order byte first).Your protocol could be as simple as one side iniiates a connection, sends a byte count followed by the byte array. The receiver, once it has received all bytes (as given by the byte count) processes the data and then returns the response preceded by a byte count. Of course your application may be more complex than that, which is why protocol design is such an interesting problem. Original message From: James Richters via fpc-pascal Date: 11/09/2020 21:59 (GMT+00:00) To: 'FPC-Pascal users discussions' Cc: James Richters Subject: [fpc-pascal] Sending Hex codes over TCP/IP I'm trying to figure out how to send and receive Arrays of Bytes or perhaps a buffer of hex codes over TCP/IP, but everything I find seems to want to send and receive strings. Can someone please point me in the right direction on how to do this? Basically I want to make a connection to an IP address at a specific port and then send some bytes to the server then get some bytes back from the server. The data sent is just hexadecimal and it can't be followed by linefeeds or carriage returns, and I want to just receive the bytes back into a buffer of some sort so I can look at it one byte at a time. I prefer some kind of array of bytes so I can just access the bytes with elements of the array. I've been going round and round trying to figure this out. Any help is greatly appreciatedJames___fpc-pascal maillist - fpc-pascal@lists.freepascal.orghttps://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sending Hex codes over TCP/IP
On Fri, 11 Sep 2020 16:58:50 -0400, James Richters via fpc-pascal wrote: >I'm trying to figure out how to send and receive Arrays of Bytes or perhaps a >buffer of hex codes over TCP/IP, but everything I find seems to want to send >and receive strings. Can someone please point me in the right direction on >how to do this? > >Basically I want to make a connection to an IP address at a specific port and >then send some bytes to the server then get some bytes back from the server. >The data sent is just hexadecimal and it can't be followed by linefeeds or >carriage returns, and I want to just receive the bytes back into a buffer of >some sort so I can look at it one byte at a time. I prefer some kind of array >of bytes so I can just access the bytes with elements of the array. > >I've been going round and round trying to figure this out. Any help is >greatly appreciated > If you use Indy10 you will find that TIdTcpClient has methods to read and send the data as TBytes, i.e. array of bytes. -- 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] Sending Hex codes over TCP/IP
What I'm trying to do is control some different ethernet relays. They use MODBUS TCP. I'm trying to keep it as simple as possible. I found a modbus library for Pascal but it was way over complicated for that I need to do, and while it looks like it would do some cool stuff, the one function I need wasn't implemented yet. I don't need any classes and the only functions I need are: 1. Make the connection to the IP address and port 2. Send 11 bytes 3. Receive 11 bytes 4. close the connection when I'm done sending and receiving bytes The protocol is already determined by the device, so I know exactly what bytes I need to send to turn a relay on or off, and I know what to expect back if it was successful. I don't need any threads or anything complicated.. or any high speed performance... just send some bytes, and read some bytes. So I need to establish a connection to 10.10.02.02 at TCP Port 502 Then I want to send this: Bytesout[0]:= $00; // High Byte of transaction ID Word Bytesout[1]:= $01; // Low Byte of transaction ID Word Bytesout[2]:= $00; //High Byte of Protocol ID (Always $00) Bytesout[3]:= $00; //Low Byte of Protocol ID (Always $00) Bytesout[4]:= $00; // High Byte of Message Length Word Bytesout[5]:= $06; // Low Byte of Message Length Word (6 Bytes to follow) Bytesout[6]:= $FE; // Unit ID (hard coded to $FE) Bytesout[7]:= $05; // Function Code $05=Write to Coil Bytesout[8]:= $00; // Hight Byte of Coil Number ($00) Bytesout[9]:= $02; // Low Byte of Coil Number ($01 to $08 for this device) Bytesout[10]:= $FF; // High Byte of Status ($FF to turn on, $00 to turn off) Bytesout[11]:= $00; // Low Byte of Status (always $00 for this operation) If the operation is successful, I will receive the exact same thing back, After the relay is activated. My program doesn't need to do anything else until the bytes are received, or a timeout occurs. This is going to be a FPC console application that will only need to run on Window 10. I'm wanting to keep it simple and lightweight. I don't need to do anything else but send and receive theses 11 bytes nothing else is supported by the device anyway. Any ideas? James -Original Message- From: Michael Van Canneyt Sent: Friday, September 11, 2020 5:13 PM To: James Richters ; FPC-Pascal users discussions Subject: Re: [fpc-pascal] Sending Hex codes over TCP/IP On Fri, 11 Sep 2020, James Richters via fpc-pascal wrote: > I'm trying to figure out how to send and receive Arrays of Bytes or perhaps a buffer of hex codes over TCP/IP, but everything I find seems to want to send and receive strings. Can someone please point me in the right direction on how to do this? > > Basically I want to make a connection to an IP address at a specific port and then send some bytes to the server then get some bytes back from the server. The data sent is just hexadecimal and it can't be followed by linefeeds or carriage returns, and I want to just receive the bytes back into a buffer of some sort so I can look at it one byte at a time. I prefer some kind of array of bytes so I can just access the bytes with elements of the array. > > I've been going round and round trying to figure this out. Any help > is greatly appreciated You'll need to be more specific. What classes or routines are you using (or trying to use) for this ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Fpc make questions...
On 2020-09-11 21:51, Bo Berglund via fpc-pascal wrote: I am not very informed about how make works when building fpc installations, I have just used commands I have gathered online and it has worked... Now I would like to know: 1) Does make clean inside the fpc source dir erase ALL of the binaries produced by an earlier build inside that source tree? Yes, as long as the same target is involved. If you want to clean for results of possible cross-compilations as well, use 'make distclean'. 2) If so, does these two versions of "make all" build for ARMv7 and ARMv6 respecitively: make all FPC=/home/pi/dev/ppcarm OPT="-dFPC_ARMHF" make all FPC=/home/pi/dev/ppcarm OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" I know nothing about ARM thus I can't answer this one. 3) Does the following command overwrite existing files from an earlier attempt so the CPU target can be replaced? For ARMv7: make install OPT="-dFPC_ARMHF" PREFIX=/home/pi FPC="/home/pi/dev/ppcarm" For ARMv6: make install OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" PREFIX=/home/pi FPC="/home/pi/dev/ppcarm" If you perform 'make all' before running 'make install', then you probably don't need the OPT=... parameter for 'make install'. 4) Do I also need to switch the seed compiler /home/pi/dev/ppcarm (3.0.4) between v6 and v7 or can any of the two work to build correctly fpc itself? No - as long as the seed compiler works on your machine and is supported by the makefiles (i.e. isn't too old), you can use the same seed compiler. Preferably, you should use a seed compiler from the last official release for your platform. The reason I am asking is that I need to switch my system from building ARMv7 binaries to build ARMv6 binaries and I don't want to start over from scratch on this RPi, which I have used for some time... Hopefully make clean make all make install with the proper options will do the trick TIA.. They should. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Fpc make questions...
On Sat, 12 Sep 2020 01:54:20 +0200, Tomas Hajny via fpc-pascal wrote: >> 3) Does the following command overwrite existing files from an earlier >> attempt so the CPU target can be replaced? >> For ARMv7: >> make install OPT="-dFPC_ARMHF" PREFIX=/home/pi >> FPC="/home/pi/dev/ppcarm" >> For ARMv6: >> make install OPT="-dFPC_ARMHF -CpARMV6 -OpARMV6" PREFIX=/home/pi >> FPC="/home/pi/dev/ppcarm" > >If you perform 'make all' before running 'make install', then you >probably don't need the OPT=... parameter for 'make install'. > > >> Hopefully >> >> make clean >> make all >> make install >> >> with the proper options will do the trick >> TIA.. > >They should. > Thanks, it is reassuring! Regarding the install I only specify the home dir as the target (PREFIX) and make install creates subdirs below that where it stuffs files. If I knew the locations affected I could just rm -r them before running make install. But I don't, so this is why I ask. I did not mention why I need to go from ARMv7 to ARMv6, but it is because I found that binaries generated by my ARMv7 installation will not run on all Raspberries. On RPiZero I get an instant exception, whereas if it was compiled on the RPiZero itself ir runs fine. On the Zero I installed using the v6 switch because that device is an ARMv6. And that binary runs on *all* RPi I have tested on. That is why I want my main RPi dev box to be converted to use ARMv6 instruction set. Final question: Lazarus is built (and rebuilt numerous times) using the ARMv7 compiler. Do I need to rebuild Lazarus (and all the installed packages) too if I switch to a different fpc compiler? -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal