C-Compiler for download programs on TXT

Alle APIs oder Firmwares für den TXT: Community-Firmware, .net, C++, usw.
Forumsregeln
Bitte beachte die Forumsregeln!

C-Compiler for download programs on TXT

Beitragvon ChrisOrton » 04 Aug 2017, 14:32

Does a C-Compiler exist that allows the creation of native, download, programs for the TXT

Such a thing appears to be available for the TX controller
C-Compiler programming package FIRMWARE 1.30 - 48.11 MB


But the only C++ kit for the TXT
TXT-C-Programming-Expert-Kit - 0.42 MB

Only seems to create Windows programs that control the TXT remotely

(I have lot of other questions about the architecture of the TXT and libraries that C code wold have to interact with)

Thanks
ChrisOrton
 
Beiträge: 3
Registriert: 04 Aug 2017, 07:47

Re: C-Compiler for download programs on TXT

Beitragvon MasterOfGizmo » 04 Aug 2017, 15:56

Yes, there's a way to do so. But it's not trivial and you need to use a Linux PC.

The Community-Firmware http://cfw.ftcommunity.de/ftcommunity-TXT/en/
comes with a complete build chain. This is installed on a linux PC when building as described here
https://github.com/ftCommunity/ftcommun ... e-firmware

After a successful build of the firmware the entire build chain is left installed on your PC and you can use that to cross compile any program for the TXT.

Edit: This build chain is not limited to the community firmware. I can equally well be used to compile programs for the original firmware.
ftDuino, der Arduino für fischertechnik: http://ftduino.de
Benutzeravatar
MasterOfGizmo
 
Beiträge: 1322
Registriert: 30 Nov 2014, 08:44

Re: C-Compiler for download programs on TXT

Beitragvon ChrisOrton » 07 Aug 2017, 11:46

Thanks, I'd half guessed the tools for the community firmware could provide an approach for building native applications and it is good to get confirmation

Is there any library documentation in the CFW? As the next question would be how to access the TXT hardware from native/downloadable code
ChrisOrton
 
Beiträge: 3
Registriert: 04 Aug 2017, 07:47

Re: C-Compiler for download programs on TXT

Beitragvon MasterOfGizmo » 07 Aug 2017, 12:40

ChrisOrton hat geschrieben:Is there any library documentation in the CFW? As the next question would be how to access the TXT hardware from native/downloadable code


With TXT hardware you refer to what exactly? The "generic" hardware like i2c busses and USB are accessed similar to any other Linux PC. If you are referring to the ft specific IOs then you are out of luck. There is no "official" interface to that and we only have a Python library named ftrobypy to do that. If you want access from e.g. a C program to the ft IOs then you'll need to implement the necessary library yourself.

Something similar exists inside the original firmware. But that part isn't open source so we don't have access to it.
ftDuino, der Arduino für fischertechnik: http://ftduino.de
Benutzeravatar
MasterOfGizmo
 
Beiträge: 1322
Registriert: 30 Nov 2014, 08:44

Re: C-Compiler for download programs on TXT

Beitragvon ChrisOrton » 07 Aug 2017, 17:15

Thanks again, I did mean the FT hardware specifically I/O status, motor speed and so on.

I can se I may have to do a lot of guesing
ChrisOrton
 
Beiträge: 3
Registriert: 04 Aug 2017, 07:47

Re: C-Compiler for download programs on TXT

Beitragvon richard.kunze » 07 Aug 2017, 19:28

ChrisOrton hat geschrieben:I can se I may have to do a lot of guesing

You don't have to start entirely from scratch. Most of the guesswork (and a working implementation) has already been done in https://github.com/ftrobopy/ftrobopy. Basically, you access the TXT I/Os by sending commands via a serial port (/dev/ttyO2 in the community firmware) to the IO-Board of the TXT (ftrobopy calls this board the "motor shield"). The protocol itself is similar to the ROBOPro online protocol described in the "TXT-C-Programming-Expert-Kit " (exchange of serialized control structures every 10ms or so), but the details of the data structures vary a bit.

I'd recommend to use the ftrobopy python implementation as a starting point - the relevant part of the code (the data exchange loop) is at https://github.com/ftrobopy/ftrobopy/bl ... y.py#L1439, and the relevant part for communicating directly over the internal serial port (called "direct mode" in ftrobopy, as opposed to the "online mode" that uses the ROBOPro protocol) starts at https://github.com/ftrobopy/ftrobopy/bl ... y.py#L1467
richard.kunze
 
Beiträge: 470
Registriert: 27 Dez 2015, 00:49
Wohnort: Rhein-Main-Gebiet
Alter: 48

Re: C-Compiler for download programs on TXT

Beitragvon Torsten » 07 Aug 2017, 21:24

Hi Chris,

The TXT motor-shield communicates with the TXT-Linux only once every 10ms. Python usually is fast enough to keep track with this rhythm.
You could create a native C/C++ module for Python (using the standard Python-C API) that contains speed sensitive C/C++ functions and then import this into your python-scripts. Thus you can easily combine ftrobopy and fast C/C++ routines. I use this method to combine image processing functions written in C/C++ with python-scrips in combination with ftrobopy. An example of this can be seen in my fischertechnik digital camera ftDigiCam (see ft:pedia 1/2016).

To cross-compile the C/C++ modules for the TXT I use the official fischertechnik "TXT Controller Open Source Archive" (http://www.fischertechnik.de/ResourceIm ... ?raid=8400).

Best,
Torsten
Torsten
 
Beiträge: 158
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)
Alter: 48

Re: C-Compiler for download programs on TXT

Beitragvon MasterOfGizmo » 09 Aug 2017, 13:12

Torsten hat geschrieben:To cross-compile the C/C++ modules for the TXT I use the official fischertechnik "TXT Controller Open Source Archive" (http://www.fischertechnik.de/ResourceIm ... ?raid=8400).


That's exactly the code the Community-Firmware has been based on. This is basically just an older version of the same setup. I had some issues getting this old stuff to work on a recent Linux machine.

You need to be careful when dealing with that archive. Although it's named "open source" it also contains proprietary code binaries copyright by fischertechnik/Knobloch/whoever
ftDuino, der Arduino für fischertechnik: http://ftduino.de
Benutzeravatar
MasterOfGizmo
 
Beiträge: 1322
Registriert: 30 Nov 2014, 08:44

Re: C-Compiler for download programs on TXT

Beitragvon Torsten » 09 Aug 2017, 22:07

Hi Chris,

here is a very quick way (in Windows7) to get to compile a simple C program that natively runs on the TXT:

1.Download the linaro-arm package:
https://releases.linaro.org/archive/14. ... _win32.zip
(it seems that this old version has been used by fischertechnik to build the TXTs Linux OS, newer versions will most likely also work fine, but I haven't tested that)

2. Unpack the file to your preferred location.

3. Take a file "helloworld.c" e.g.:

#include <stdio.h>
int main(int arg, char* arg) {
printf("Hello world\n");
return 0;
}

4. Use the linaro gcc binary to compile the source:
C:\> where_linaro_has_been_unpacked\bin\arm-linux-gnueabihf-gcc.exe helloworld.c
This will create a file named "a.out"

5. Copy this file to your TXT:
scp a.out ROBOPro@192.168.7.2:

6. Login to your TXT:
ssh ROBOPro@192.168.7.2

8. make the a.out file executable:
chmod a+x a.out

9. run the program from the TXT command line:
./a.out

This does not yet give you access to the TXTs I/O but at least you get the idea. Programs that have been compiled like this will run with the original fischertechnik firmware as well as with the community firmware.

Best,
Torsten
Torsten
 
Beiträge: 158
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)
Alter: 48

Re: C-Compiler for download programs on TXT

Beitragvon MasterOfGizmo » 10 Aug 2017, 11:37

Really great! How about creating a page for cfw.ftcommunity.de explaining this?

Although this method has a small caveat: The linaro compiler only comes with a few libraries. If you need some special libs for HW io then you need to compile them.
ftDuino, der Arduino für fischertechnik: http://ftduino.de
Benutzeravatar
MasterOfGizmo
 
Beiträge: 1322
Registriert: 30 Nov 2014, 08:44

Re: C-Compiler for download programs on TXT

Beitragvon Torsten » 10 Aug 2017, 14:23

MasterOfGizmo hat geschrieben:Really great! How about creating a page for cfw.ftcommunity.de explaining this?

Although this method has a small caveat: The linaro compiler only comes with a few libraries. If you need some special libs for HW io then you need to compile them.


I will elaborate on that a little more and put it up onto cfw.ftcommunity.de.

Why don't we just include a C-compiler (e.g. gcc) into the cfw build ?
You could then just login with ssh onto the TXT and compile your C programs there.

Converting "ftrobopy.py" to "ftTXTDirectIOlib.[c|h]" (or some better name) is something I have on my ToDo/NiceToHave-list. However this still has to wait I little since I currently have too many open projects I'm working on.
Torsten
 
Beiträge: 158
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)
Alter: 48

Re: C-Compiler for download programs on TXT

Beitragvon MasterOfGizmo » 10 Aug 2017, 16:03

Torsten hat geschrieben:Why don't we just include a C-compiler (e.g. gcc) into the cfw build ?
You could then just login with ssh onto the TXT and compile your C programs there.


For no particular reason. I think Raphael suggested the same. But the size of the firmware would greatly increase. Those of us who have successfully built the CFW themselves already have all the required tools on their host PC and cross compiling there is just so much faster and easier.

I don't think it makes much sense to add all he tools to the standard end user firmware (you won't be done with just the c compiler itself). But a seperate "hacker edition" would sure make sense. Go!
ftDuino, der Arduino für fischertechnik: http://ftduino.de
Benutzeravatar
MasterOfGizmo
 
Beiträge: 1322
Registriert: 30 Nov 2014, 08:44

Re: C-Compiler for download programs on TXT

Beitragvon richard.kunze » 10 Aug 2017, 16:30

Torsten hat geschrieben:Why don't we just include a C-compiler (e.g. gcc) into the cfw build ?

As MoG said: No real reason. But doing so could be quite a bit of work, since Buildroot does not provide a native compiler package for the target environment - so we'd have to roll our own.

I'm not quite sure if a native C compiler on the TXT makes much sense, though, because of the CPU speed and especially RAM constraints of the TXT. Sure, compiling a "hello world" or similarly simple program will probably work OK, but for bigger projects you would need a cross compiler anyway.

As a comparison, have a look at native compilation on a Raspberry Pi: The RasPi 3 has about 8 times the CPU power (four cores at 1.2 GHz vs. one core at 500 MHz for the TXT) and four times as much RAM as the TXT, and even there, compiling natively is much slower than cross-compiling on a PC.

I think we're probably better of concentrating on an easy to use cross-compile environment that works both on Windows and Linux instead.
richard.kunze
 
Beiträge: 470
Registriert: 27 Dez 2015, 00:49
Wohnort: Rhein-Main-Gebiet
Alter: 48

Re: C-Compiler for download programs on TXT

Beitragvon Torsten » 10 Aug 2017, 21:45

ok, I see the point and I was not aware of buildroot not really having compiler support.
So the linaro packages could be a solution. They are available for Windows as well as for Linux. The advantage of linaro is, that it is very easy to install and does not need 6 hours to build like the cfw.
Of course using the cfw-build as cross-compile environment would still be the solution of choice for the "hardcore" developers.
Still we would need the equivalent of ftrobopy for C/C++.
Would it be sufficient if such a library would only support the 'direct'-mode ? or would the posix socket mode also be needed ? (e.g. to access several TXTs from within one program)
Torsten
 
Beiträge: 158
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)
Alter: 48

Re: C-Compiler for download programs on TXT

Beitragvon reus » 18 Nov 2017, 23:25

Hi,

Just an addition to what Torsten wrote about getting quickly a toolchain:

Toolchains for Windows and Linux can be found in
https://releases.linaro.org/archive/14. ... /binaries/
On my Linux-VM, the entire toolchain occupies less than 300MB on the disk and only needs a few seconds to setup.

Note: My first attempt to compile a test program failed with an error message saying that libz could not be found. This is because the toolchain is 32 bit and my VM was running a 64-bit Linux. Just install the right version of libz with
sudo apt-get install zlib1g:i386

(thanks to stackexchange, as usual)
reus
 
Beiträge: 79
Registriert: 02 Nov 2010, 10:39


Zurück zu TXT-Sonderprogrammierungen

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast