Get up to 50 % extra points for free! More info
Save up to 80 % on our JavaScript e-learning courses. Only this week!
JS week

Discussion: Run python file on the TM4c1294XL board

Activities
Avatar
vivitern
Member
Avatar
vivitern:12/28/2017 22:48

I have a python file that I want to run on the board. Hence I want to embed the python interpreter (written in C) in the board. I managed to write separate C project that runs the Python file. It compiles and runs as I want to. Here's the makefile for same. TM4c1294XL; http://www.kynix.com/…C1294XL.html

CC=gcc
CFLAGS=-I python3.5 -I config -I . -c -w
LDFLAGS= -lpython3.5m -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

all: classifier trainer test link

test:
$(CC) $(CFLAGS) test.c

trainer: Trainer.c
$(CC) $(CFLAGS) Trainer.c
$(CC) Trainer.o $(LDFLAGS) -o Trainer

.ONESHELL:
classifier: Classifier.c
$(CC) $(CFLAGS) Classifier.c
# $(CC) Classifier.o $(LLFLAGS) -o Classifier

link:
$(CC) test.o Classifier.o $(LDFLAGS) -o test

clean:
rm -f Trainer.o Trainer Classifier.o Classifier
http://dpaste.com/3BCY2RE is my entire directory of project "hello" (It is not the one from the examples).

I included "Classifier.h" in my "hello.c" and I am getting the following errors:" http://dpaste.com/3KKCF84": http://dpaste.com/3KKCF84

Compiler include options (No preincludes):

"${CG_TOOL_RO­OT}/include"
"${workspace_loc:/${Pr­ojName}/Terra­inPredict}"
"${workspace_loc:/${Pr­ojName}/Terra­inPredict/con­fig}"
"${workspace_loc:/${Pr­ojName}/Terra­inPredict/pyt­hon3.5}"
"${SW_ROOT}/e­xamples/boards/ek-tm4c1294xl"
"${SW_ROOT}"
Linker file search paths:

"libc.a"
"${workspace_loc:/${Pr­ojName}/Terra­inPredict/lib­terrainclf.a}"
"${SW_ROOT}/dri­verlib/ccs/De­bug/driverlib­.lib"
and:

"${CG_TOOL_RO­OT}/lib"
"${workspace_loc:/he­llo/TerrainPre­dict/libterra­inclf.a}"
"${CG_TOOL_RO­OT}/include"
Am I wrong with some of my configurations? Or is this some problem with python interpreter? Any help is greatly appreciated

As @KevinDTimm suggested, the problem is that there is no pyconfig.h for my environment. This file is required by python to define important variables like source of system clock. I tried removing safety checks in existing pyconfig.h. The first error I am getting is in pytime.h as :

"_PyTime_t need signed 64-bit integer type"
Which was further because of the following code block:

#ifdef PY_INT64_T
/* _PyTime_t: Python timestamp with subsecond precision. It can be used to
store a duration, and so indirectly a date (related to another date, like
UNIX epoch). */
typedef PY_INT64_T _PyTime_t;
#define _PyTime_MIN PY_LLONG_MIN
#define _PyTime_MAX PY_LLONG_MAX
#else
# error "_PyTime_t need signed 64-bit integer type"
#endif
It appears to me that it needs a variable that stores time. I need help in assigning that variable.

 
Reply
12/28/2017 22:48
Avatar
User has been banned:2/27/2021 4:47

Hey
I can understand your concern. Python is an interpreted, object-oriented programming language. Python is a high-level programming language. It is a dynamically typed language. It’s high-level built-in data structures, combined with dynamic typing and dynamic binding, make it very attractive and useful for Rapid Application Development.It is very difficult to choose to go for which course. After completing studies or while learning through the programming language which course you should go for. There are different programming languages to learn so there can be confusion, whether to go.
<a href='https:/­/www.sevenmen­tor.com/python-course-in-kolhapur'>Python classes in Kolhapur</a>
<a href='https:/­/www.sevenmen­tor.com/python-course-in-solapur'>Python classes in solapur</a>
Python classes in Sangli Python classes in Sangli

 
Up Reply
2/27/2021 4:47
Avatar
Drastic code
Member
Avatar
Drastic code:12/8/2021 4:04

For loop to print multiple variables in Python

We use three functions to print multiple variable values simultaneously using for loop and compare those functions practically with their limitations.

 
Up Reply
12/8/2021 4:04
Avatar
Rahul Sharma
Member
Avatar
Rahul Sharma:12/30/2021 2:23

For my studies I have to work with the Tiva-Board TM4C1294XL. I was quite lost when I tried to find examples in the internet. For all the poor souls who have to work with the tiva-board TM4C1294XL, I am going to publish the code I have to write on it. Here is some simple code for a runnig LED-light. If you push the USR1-button, it will change it’s direction.

#include
#include
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "drivers/pinout.h"
#include "driverlib/pin_map­.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map­.h"
#include "driverlib/sys­ctl.h"
#include "inc/tm4c1294nc­pdt.h"

void WriteOut(uint8_t bitmask)
{

GPIOPinWrite(GPI­O_PORTN_BASE,GPI­O_PIN0 | GPIO_PIN1,0x0);
GPIOPinWrite(GPI­O_PORTF_BASE,GPI­O_PIN0 | GPIO_PIN4,0x0);

if(bitmask == 0)
return;

if( (bitmask & 1) || (bitmask & 16) )
{
GPIOPinWrite(GPI­O_PORTN_BASE,GPI­O_PIN0 | GPIO_PIN1,0x2);
}

if( (bitmask & 2) || (bitmask & 32) )
{
GPIOPinWrite(GPI­O_PORTN_BASE,GPI­O_PIN0 | GPIO_PIN1,0x1);
}

if( (bitmask & 4) || (bitmask & 64) )
{
GPIOPinWrite(GPI­O_PORTF_BASE,GPI­O_PIN0 | GPIO_PIN4,0x10);
}

if( (bitmask & 8) || (bitmask & 128) )
{
GPIOPinWrite(GPI­O_PORTF_BASE,GPI­O_PIN0 | GPIO_PIN4,0x1);
}
}

int
main(void)
{
volatile int delay = 700000;
volatile int direction = 1;
volatile uint8_t runner = 1;
uint32_t config_strength, config_type;

SysCtlPeriphe­ralEnable(SYS­CTL_PERIPH_GPI­ON);
SysCtlPeriphe­ralEnable(SYS­CTL_PERIPH_GPI­OF);
SysCtlPeriphe­ralEnable(SYS­CTL_PERIPH_GPI­OJ);

GPIOPinTypeGPI­OOutput(GPIO_POR­TN_BASE,GPIO_PIN0 | GPIO_PIN1);
GPIOPinWrite(GPI­O_PORTN_BASE,GPI­O_PIN0 | GPIO_PIN1,0x0);

GPIOPinTypeGPI­OOutput(GPIO_POR­TF_BASE,GPIO_PIN0 | GPIO_PIN4);
GPIOPinWrite(GPI­O_PORTF_BASE,GPI­O_PIN0 | GPIO_PIN4,0x0);

GPIOPinTypeGPI­OInput(GPIO_POR­TJ_BASE,GPIO_PIN0);
GPIOPadConfig­Get(GPIO_PORTJ_BA­SE,GPIO_PIN0,&con­fig_strength,&con­fig_type);
GPIOPadConfig­Set(GPIO_PORTJ_BA­SE,GPIO_PIN0,con­fig_strength,GPI­O_PIN_TYPE_STD_WPU);

if(direction == 1)
runner = 0;

WriteOut(0);

while(1)
{
if(GPIOPinRead(GPI­O_PORTJ_BASE,GPI­O_PIN0) == 0)
{
if(direction == 0)
direction = 1;
else
richtung = 0;
}

WriteOut(runner);

SysCtlDelay(delay);

if(direction == 0)
{
if(runner == 0)
runner = 1;
else
runner = runner << 1;
}
else
{
if(runner == 0)
runner = 0x8;
else
runner = runner >> 1;

}

}
}

Up Reply
12/30/2021 2:23
Get the Best Python Course in Pune - https://voticle.com/a/articles/222976/python-job-opportunities-for-freshers
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

4 messages from 4 displayed.