Notes about the fischertechnik TXT firmware version 4.5.x

The Civetweb web server on the fischertechnik TXT controller

On the TXT is a webserver from civetweb available.

civetweb configuration example:

# Civetweb web server configuration file.
# For detailed description of every option, visit
# https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md
# Lines starting with '#' and empty lines are ignored.
# To make a change, remove leading '#', modify option's value,
# save this file and then restart Civetweb.
document_root /var/www
listening_ports 80
#original hiden parts:
hide_files_patterns .*|TxtControlMain|libs|run.sh|ROBOPro
url_rewrite_patterns /txt=/opt/knobloch
put_delete_auth_file /var/www/.htpasswd
authentication_domain TXTController.local
run_as_user ROBOPro
#add by me to activate CGI
cgi_pattern **.cgi$
access_log_file /opt/knobloch/accesslog.txt
error_log_file /opt/knobloch/errorlog.txt

# access_log_file /var/www/accesslog.txt   is not writable under the user= ROBOPro account
# error_log_file /var/www/errorlog.txt  is not writable under the user=ROBOPro account

Example of a simple C/C++ script

filenaam: cpptest.cgi, in /var/www, don't forget to adjust the file attributes.

This file needs to be compiled with the same Eclipse configuration as used for the download programs an the SLI programs, see the installation section in: https://github.com/fischertechnik/txt_demo_c_download/blob/master/README.md


 *  Compiler:   gcc / g++
 * Simple CGI example
#include <stdio.h>          // for printf()
#include <unistd.h>         // for sleep()
//#include "KeLibTxtDl.h"     // TXT Lib
//#include "FtShmem.h"        // TXT Transfer Area
int main(void)
     printf("Content-type: text/html\n\n") ;
     /** Print the HTML response page to STDOUT. **/
     printf("<html>\n") ;
     printf("<head><title>CGI Output</title></head>\n") ;
     printf("<body>\n") ;
     printf("<h1>Hello, world.</h1>\n") ;
     printf("</body>\n") ;
     printf("</html>\n") ;
 return 0;

Example of a simple Python script

filenaam: pytest.cgi, in /var/www, don't forget to adjust the file attributes.

Shows also the use of the FtRoboPy module

# Import modules for CGI handling
import cgi, cgitb
import ftrobopy
import sys
print ("Content-type:text/html\r\n\r\n")
print ('<html>')
print ('<head>')
print ('<title>Hello Word - First CGI Program</title>')
print ('</head>')
print ('<body>')
print ('<h2>Hello Word! This is my first CGI program</h2>')
print ('<p>')
print ("1<br/>")
print ("1A<br/>")
while not txt.sound_finished():
print ("2<br/>")
Motor_links  = txt.motor(2)
print ("3<br/>")
print ("4<br/>")
Motor_links.setDistance(500, syncto=0)
print ('5<br/>')
while not Motor_links.finished():
  print ('r')
print ("<br />")
print ("End FT program<br/>")
print ('</p>')
print ('</body>')
print ('</html>')