Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
2,241 Views

Autostart on Edison

Hello,

I have to make my agent to start automaticlly.

Do you know when Edison gets IP Adress?

I have created .service file, because I found on the net hat rc.local doesnt exist on Edison:

[Unit]

Description= Agent Service

After=xdk-daemon.service

Requires=xdk-daemon.service network.service network-online.target

[Service]

ExecStart=/home/root/agent/app

[Install]

WantedBy=multi-user.target

But after reboot Edison it reports this garbage:

/servlet/JiveServlet/showImage/2-425543-296548/1.PNG

Here prof that my app is running:

/servlet/JiveServlet/showImage/2-425543-296550/2.PNG

When I run it manualy after login works fine:

/servlet/JiveServlet/showImage/2-425543-296551/3.PNG

I have to have my app in autostart.

I have tried to modify .service file adding the following line:

[Service]

ExecStart=/home/root/agent/app

Type=idle

But it deosnt work either.

Thanks for support.

Paweł

0 Kudos
17 Replies
idata
Community Manager
59 Views

Hello Pawek,

 

 

I will try to help you. Could you please provide us more details about your application? Is your application based on a Python script? I ask this because I have seen that when starting a Python through a system service if you don't specify the "WorkingDirectory" it will not start.

 

 

Another thing you could try is to create a shell script that waits until you have an IP address and when you do runs the original script.

 

 

I will be waiting for your response.

 

-Peter.
idata
Community Manager
59 Views

Hello Pawek,

 

 

Do you have any updates about this?

 

 

-Peter.
idata
Community Manager
59 Views

Yes. I insert a artificial 10 sec delay and it works fine. But other problem occures. I get that errors:

I get that error on both of my Edisons:

root@Intel-Edison-SanDiego-01:~# [ 5759.863343] INFO: task Proximetry:428 blocked for more than 120 seconds.

[ 5759.863432] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

[ 5879.846826] INFO: task Proximetry:428 blocked for more than 120 seconds.

[ 5879.846914] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

[ 5999.830327] INFO: task Proximetry:428 blocked for more than 120 seconds.

[ 5999.830416] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

[ 6119.813835] INFO: task Proximetry:428 blocked for more than 120 seconds.

[ 6119.813925] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

[ 6239.797330] INFO: task Proximetry:428 blocked for more than 120 seconds.

[ 6239.797418] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

root@Intel-Edison-Katowice-01:~# [ 5759.863343] INFO: task Proximetry:428 blocked for more than 120 seconds.

"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

INFO: task Proximetry:428 blocked for more than 120 seconds.

"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

INFO: task Proximetry:428 blocked for more than 120 seconds.

"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

INFO: task Proximetry:428 blocked for more than 120 seconds.

"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

INFO: task Proximetry:428 blocked for more than 120 seconds.

"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.

How to fix it?

I would appriciate any help,

Paweł

idata
Community Manager
59 Views

Hi Pawek,

 

 

This error is known as kernel panic, this issue is usually caused by a hardware failure or a software bug in the operating system. Since this error message started to appear with the service we can assume that it is related to it. Nevertheless, I'm not sure if the application is causing it or if the service is the cause. Anyhow, it would be helpful to know more about the application (if possible), to determine if it could be affecting in this behavior.

 

 

You mentioned that you have run the script manually after boot, do you see this error message? Or, is everything normal when running the application manually?

 

 

I found an article online with a similar issue: https://www.blackmoreops.com/2014/09/22/linux-kernel-panic-issue-fix-hung_task_timeout_secs-blocked-.... The writer used sysctl to solve the issue he was facing, the method he used might not be the solution for the behavior on your Edison (as sysctl on Edison works a little bit different) but it could be lead you to the right direction.

 

 

We'll be waiting for your response.

 

-Peter.
idata
Community Manager
59 Views

Hi Peter,

I just confirm that this error occures when my app is started by service and when my app is started manually. So it have to be something else.

I found this solutnion earlier, but it doenst help.

My application send information about network (ip, mac, default gw etc [This code was tested many times on other linux platforms]), sensors read (temp, vibration, analog color, distance , sound, light, button and led state) to our cloud where statistics, alerts and conf parameters are shown. This Edison also regarding to that sensors reads stops motor or execute another actions like changing led state or turn on buzzer.

Thanks,

Paweł

Ps.

When I run it way that it doesnt take over console (from service or by ./App& ) I am able to re-run my binary. Investigation shows that it hangs on recivfrom finction used as below:

int size = recvfrom(prox_sock, buffer, sizeof(buffer), MSG_DONTWAIT, NULL, NULL);

idata
Community Manager
59 Views

I understand, let me see what I can find out about this. If I'm able to find something useful I'll post it here.

 

 

-Peter.

 

idata
Community Manager
59 Views

Perer,

I'm looking forward to hear from you soon.

Thanks,

Paweł

idata
Community Manager
59 Views

Hello Paweł,

 

 

I searched more information about this specific issue and I found the following:

 

 

The error message is related to the fact that a task/process may be using all of the system resources causing the system (Edison in this case) to hang. Most likely the kernel panic is being caused by the application. When the running application waits for some event to occur it goes into a blocked state, then as it waits (blocks) for 120 seconds or more the kernel panic message is triggered.

 

 

It seems that the cause of this messages is an issue on the application and you might have to debug it.

 

 

We would like to know if you can share the application with us to see if we notice anything that might be triggering this behavior. Also, you could try to set /proc/sys/kernel/hung_task_timeout_secs to 0 (to disable the messages) or increase /proc/sys/kernel/hung_task_timeout_secs to more than 120 seconds and see if that makes any difference.

 

 

Let me know.

 

-Peter.
idata
Community Manager
59 Views

Hi,

this is top log after about 4h working of my app, it seems ok:

Mem: 219092K used, 763976K free, 0K shrd, 33160K buff, 60244K cached

CPU: 3% usr 62% sys 0% nic 33% idle 0% io 0% irq 0% sirq

Load average: 1.95 2.04 2.04 2/137 441

PID PPID USER STAT VSZ %VSZ %CPU COMMAND

437 2 root RW 0 0% 30% [kworker/u4:2]

423 401 root D 2776 0% 25% ./Proximetry <-------------------------------------------

438 2 root SW 0 0% 11% [kworker/u4:3]

342 1 root S 19896 2% 0% /usr/bin/redis-server /etc/redis/redis

441 401 root R 2892 0% 0% top

126 2 root SW 0 0% 0% [dhd_watchdog_th]

64 2 root SW 0 0% 0% [kworker/0:2]

350 302 root S 111m 12% 0% /usr/bin/node /opt/xdk-daemon/current/

249 1 pulse S < 109m 11% 0% /usr/bin/pulseaudio --system --resampl

318 293 root S 80208 8% 0% node /usr/lib/edison_config_tools/edis

302 297 root S 76996 8% 0% /usr/bin/node /opt/xdk-daemon/main.js

173 1 systemd- S 12092 1% 0% /lib/systemd/systemd-timesyncd

138 1 root S 9552 1% 0% /lib/systemd/systemd-udevd

115 1 root S 8680 1% 0% /lib/systemd/systemd-journald

192 1 root S 6348 1% 0% /usr/sbin/wpa_supplicant -u -c/etc/wpa

316 315 root S 5264 1% 0% (sd-pam)

196 1 root S 5128 1% 0% /usr/sbin/ofonod -n

250 1 root S 4684 0% 0% /usr/lib/bluez5/bluetooth/bluetoothd -

273 1 root S 4536 0% 0% /usr/sbin/mosquitto -c /etc/mosquitto/

1 0 root S 4480 0% 0% {systemd} /sbin/init

Or am I wrong?

Only one that this applicaion make different way then my other linux devices is sensors reading. Rest is copy-pasted between other platforma (read of ip and so on).

Maybe there is issue?

int Steps;

bool Direction;

bool hold_request = false;

uint32_t now, then;

extern bool should_run;

void prepare_gpios_and_aio(void)

{

/* Initialize GPIOs*/

buzzer = mraa_gpio_init(GPIO_BUZZER_PIN);

button = mraa_gpio_init(GPIO_BUTTON_PIN);

led_red = mraa_gpio_init(GPIO_RED_LED_PIN);

/* Initialize AIOs*/

temp = mraa_aio_init(AIO_TEMP_PIN);

light = mraa_aio_init(AIO_LIGHT_PIN);

sound = mraa_aio_init(AIO_SOUND_PIN);

distance = mraa_aio_init(AIO_DIST_PIN);

red = mraa_aio_init(AIO_RED);

vibro = mraa_aio_init(AIO_VIBRO);

stepper_gpio1 = mraa_gpio_init(GPIO_STEPPER1_PIN);

stepper_gpio2 = mraa_gpio_init(GPIO_STEPPER2_PIN);

stepper_gpio3 = mraa_gpio_init(GPIO_STEPPER3_PIN);

stepper_gpio4 = mraa_gpio_init(GPIO_STEPPER4_PIN);

/*Because we need more 5V outputs*/

additional_power_source1 = mraa_gpio_init(GPIO_PS1);

additional_power_source2 = mraa_gpio_init(GPIO_PS2);

/* Check if all went good*/

if (!check_init())

{

PROX_LOG(

"Unable to initialize all sensors. Please check your connections.\n");

exit(EXIT_FAILURE);

}

/* Set mode (all to strong) and direction for GPIOs*/

mraa_gpio_mode(button, MRAA_GPIO_STRONG);

mraa_gpio_dir(button, MRAA_GPIO_IN);

mraa_gpio_mode(buzzer, MRAA_GPIO_STRONG);

mraa_gpio_dir(buzzer, MRAA_GPIO_OUT);

mraa_gpio_mode(led_red, MRAA_GPIO_STRONG);

mraa_gpio_dir(led_red, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio1, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio1, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio2, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio2, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio3, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio3, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio4, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio4, MRAA_GPIO_OUT);

mraa_gpio_mode(additional_power_source1, MRAA_GPIO_STRONG);

mraa_gpio_dir(additional_power_source1, MRAA_GPIO_OUT);

mraa_gpio_write(additional_power_source1,1);

mraa_gpio_mode(additional_power_source2, MRAA_GPIO_STRONG);

mraa_gpio_dir(additional_power_source2, MRAA_GPIO_OUT);

mraa_gpio_write(additional_power_source2,1);

}

int read_from_gpio(mraa_gpio_context sensor)

{

return mraa_gpio_read(sensor);

}

int read_from_aio(mraa_aio_context sensor)

{

return mraa_aio_read(sensor);

}

int get_temp_in_celcius(void) // [! IMPORTANT] VCC 3.3 -> 5 on board

{

const int B = 4255; /* B-const value form datasheet for our sensor*/

int adc_read = 0;

adc_read = mraa_aio_read(temp); /* Raw read from aio*/

float resistance = 1023.0 / ((float) adc_read) - 1.0; /* Calculate resistance*/

resistance *= 100000.0;

float temperature = 1.0 / (log(resistance / 100000.0) / B + 1 / 298.15)

- 273.15; /* Magic. Also from datasheet*/

/**

* For more info please reference to;

*

* http://www.seeedstudio.com/wiki/File:Grove_-_Temperature_sensor_v1.1.pdf http://www.seeedstudio.com/wiki/File:Grove_-_Temperature_sensor_v1.1.pdf

* * * * * * * * * * * * * * * * * * * */

return (int) temperature;

}

int get_distance(void)

{

// [!IMPORTANT] Works fine only between 10cm to 80cm according to datasheet

// https://www.sparkfun.com/datasheets/Components/GP2Y0A21YK.pdf https://www.sparkfun.com/datasheets/Components/GP2Y0A21YK.pdf

int volts, sum = 0;

int i;

// int resolution=(1 << mraa_aio_get_bit(distance));

for (i = 0; i < 5; i++)

{

volts = mraa_aio_read(distance);

sum += volts;

}

volts = sum / 5;

float val = 3027.4 / volts;

val = pow(val, 1.2134); //...

idata
Community Manager
59 Views

I understand, please let me see if I can find something out.

 

 

-Peter.
idata
Community Manager
59 Views

I've been trying to compile your code and I noticed that there are some lines missing (the includes, defines, etc.). I'm able to guess most of them but some others like COLOR_BLUE, COLOR_GREEN and some others I just don't know what they are supposed to be. Could you please share these lines as well?

 

 

I'll be waiting for your reply.

 

-Peter.
idata
Community Manager
59 Views

Hi,

//# include "sensor.h"

# include

# include

//# include "prox_config.h"

//# include "prox_core.h"

# include

# include

*GPIOs*/

# define GPIO_BUTTON_PIN 2

# define GPIO_RED_LED_PIN 4

# define GPIO_BUZZER_PIN 5

# define GPIO_PS1 8

# define GPIO_PS2 9

# define GPIO_STEPPER1_PIN 10

# define GPIO_STEPPER2_PIN 11

# define GPIO_STEPPER3_PIN 12

# define GPIO_STEPPER4_PIN 13

/*AIOs*/

# define AIO_TEMP_PIN 0

# define AIO_SOUND_PIN 1

# define AIO_LIGHT_PIN 2

# define AIO_DIST_PIN 5

# define AIO_RED 4

# define AIO_VIBRO 3

# define ADC_REF 5 /* 5V */

# define LOW 0

# define HIGH 1

# define COLOR_RED 1

# define COLOR_GREEN 2

# define COLOR_BLUE 3

Thanks,

Paweł

idata
Community Manager
59 Views

I found that after that Kernel panic top shows that

Mem: 221360K used, 761708K free, 0K shrd, 34960K buff, 60252K cached

CPU: 0% usr 99% sys 0% nic 0% idle 0% io 0% irq 0% sirq

usr is used in 99%.

Maybe this is problem? What may cause that?

Best,

Paweł

idata
Community Manager
59 Views

Hi Pawek,

I'm trying to run your application, from your previous posts I put together the following code:

//# include "sensor.h"

# include

# include

//# include "prox_config.h"

//# include "prox_core.h"

# include

# include

//I added these lines, they were missing

# include "mraa/gpio.h"

# include "mraa/aio.h"

///////////////////////////////////////

/*GPIOs*/

# define GPIO_BUTTON_PIN 2

# define GPIO_RED_LED_PIN 4

# define GPIO_BUZZER_PIN 5

# define GPIO_PS1 8

# define GPIO_PS2 9

# define GPIO_STEPPER1_PIN 10

# define GPIO_STEPPER2_PIN 11

# define GPIO_STEPPER3_PIN 12

# define GPIO_STEPPER4_PIN 13

/*AIOs*/

# define AIO_TEMP_PIN 0

# define AIO_SOUND_PIN 1

# define AIO_LIGHT_PIN 2

# define AIO_DIST_PIN 5

# define AIO_RED 4

# define AIO_VIBRO 3

# define ADC_REF 5 /* 5V */

# define LOW 0

# define HIGH 1

# define COLOR_RED 1

# define COLOR_GREEN 2

# define COLOR_BLUE 3

//I added these lines, they were missing

mraa_aio_context temp, light, sound, distance, red, vibro;

mraa_gpio_context buzzer, button, led_red, stepper_gpio1, stepper_gpio2, stepper_gpio3, stepper_gpio4, additional_power_source1, additional_power_source2;

///////////////////////////////////////

int Steps;

bool Direction;

bool hold_request = false;

uint32_t now, then;

extern bool should_run;

void prepare_gpios_and_aio(void)

{

/* Initialize GPIOs*/

buzzer = mraa_gpio_init(GPIO_BUZZER_PIN);

button = mraa_gpio_init(GPIO_BUTTON_PIN);

led_red = mraa_gpio_init(GPIO_RED_LED_PIN);

/* Initialize AIOs*/

temp = mraa_aio_init(AIO_TEMP_PIN);

light = mraa_aio_init(AIO_LIGHT_PIN);

sound = mraa_aio_init(AIO_SOUND_PIN);

distance = mraa_aio_init(AIO_DIST_PIN);

red = mraa_aio_init(AIO_RED);

vibro = mraa_aio_init(AIO_VIBRO);

stepper_gpio1 = mraa_gpio_init(GPIO_STEPPER1_PIN);

stepper_gpio2 = mraa_gpio_init(GPIO_STEPPER2_PIN);

stepper_gpio3 = mraa_gpio_init(GPIO_STEPPER3_PIN);

stepper_gpio4 = mraa_gpio_init(GPIO_STEPPER4_PIN);

/*Because we need more 5V outputs*/

additional_power_source1 = mraa_gpio_init(GPIO_PS1);

additional_power_source2 = mraa_gpio_init(GPIO_PS2);

/* Check if all went good*/

if (!check_init())

{

PROX_LOG(

"Unable to initialize all sensors. Please check your connections.\n");

exit(EXIT_FAILURE);

}

/* Set mode (all to strong) and direction for GPIOs*/

mraa_gpio_mode(button, MRAA_GPIO_STRONG);

mraa_gpio_dir(button, MRAA_GPIO_IN);

mraa_gpio_mode(buzzer, MRAA_GPIO_STRONG);

mraa_gpio_dir(buzzer, MRAA_GPIO_OUT);

mraa_gpio_mode(led_red, MRAA_GPIO_STRONG);

mraa_gpio_dir(led_red, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio1, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio1, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio2, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio2, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio3, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio3, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio4, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio4, MRAA_GPIO_OUT);

mraa_gpio_mode(additional_power_source1, MRAA_GPIO_STRONG);

mraa_gpio_dir(additional_power_source1, MRAA_GPIO_OUT);

mraa_gpio_write(additional_power_source1,1);

mraa_gpio_mode(additional_power_source2, MRAA_GPIO_STRONG);

mraa_gpio_dir(additional_power_source2, MRAA_GPIO_OUT);

mraa_gpio_write(additional_power_source2,1);

}

int read_from_gpio(mraa_gpio_context sensor)

{

return mraa_gpio_read(sensor);

}

int read_from_aio(mraa_aio_context sensor)

{

return mraa_aio_read(sensor);

}

int get_temp_in_celcius(void) // [! IMPORTANT] VCC 3.3 -> 5 on board

{

const int B = 4255; /* B-const value form datasheet for our sensor*/

int adc_read = 0;

adc_read = mraa_aio_read(temp); /* Raw read from aio*/

float resistance = 1023.0 / ((float) adc_read) - 1.0; /* Calculate resistance*/

resistance *= 100000.0;

float temperature = 1.0 / (log(resistance / 100000.0) / B + 1 / 298.15)

- 273.15; /* Magic. Also from datasheet*/

/**

* For more info please reference to;

*

* http://www.seeedstudio.com/wiki/File:Grove_-_Temperature_sensor_v1.1.pdf http://www.seeedstudio.com/wiki/File:Grove_-_Temperature_sensor_v1.1.pdf

* * * * * * * * * * * * * * * * * * * */

return (int) temperature;

}

int get_distance(void)

{

// [!IMPORTANT] Works fine only between 10cm to 80cm according to datasheet

// https://www.sparkfun.com/datasheets/Components/GP2Y0A21YK.pdf https://www.sparkfun.com/datasheets/Components/GP2Y0A21YK.pdf

int volts, sum = 0;

int i;

// int resolution=(1 << mraa_aio_get_bit(distance));

for (i = 0; i < 5; i++)

{

volts = mraa_aio_read(distance);

sum += volts;

}

<...
idata
Community Manager
59 Views

I apologize. It is how it ends when I have to refactor code quicly and without checking.This is a part of bigger project, but now it should run. The reason of compilation error is because in thise code the functions like chek_init are used before declaration.

Please use this:

/*

* source.c

*

* Created on: 3 lis 2016

* Author: pzydziak

*/

//# include "sensor.h"

# include

# include

//# include "prox_config.h"

//# include "prox_core.h"

# include

# include

//I added this lines, they were missing

# include "mraa/gpio.h"

# include "mraa/aio.h"

# include

///////////////////////////////////////

/*GPIOs*/

# define GPIO_BUTTON_PIN 2

# define GPIO_RED_LED_PIN 4

# define GPIO_BUZZER_PIN 5

# define GPIO_PS1 8

# define GPIO_PS2 9

# define GPIO_STEPPER1_PIN 10

# define GPIO_STEPPER2_PIN 11

# define GPIO_STEPPER3_PIN 12

# define GPIO_STEPPER4_PIN 13

/*AIOs*/

# define AIO_TEMP_PIN 0

# define AIO_SOUND_PIN 1

# define AIO_LIGHT_PIN 2

# define AIO_DIST_PIN 5

# define AIO_RED 4

# define AIO_VIBRO 3

# define ADC_REF 5 /* 5V */

# define LOW 0

# define HIGH 1

# define COLOR_RED 1

# define COLOR_GREEN 2

# define COLOR_BLUE 3

//I added this lines, they were missing

mraa_aio_context temp, light, sound, distance, red, vibro;

mraa_gpio_context buzzer, button, led_red, stepper_gpio1, stepper_gpio2, stepper_gpio3, stepper_gpio4, additional_power_source1, additional_power_source2;

///////////////////////////////////////

uint64_t prox_time_ms(void)

{

struct timeval tv;

gettimeofday(&tv, NULL);

return (uint64_t) ((tv.tv_sec) * 1000 + (tv.tv_usec) / 1000);

}

int Steps;

bool Direction;

bool hold_request = false;

uint32_t now, then;

bool should_run;

bool check_init();

void SetDirection();

void prepare_gpios_and_aio(void)

{

/* Initialize GPIOs*/

buzzer = mraa_gpio_init(GPIO_BUZZER_PIN);

button = mraa_gpio_init(GPIO_BUTTON_PIN);

led_red = mraa_gpio_init(GPIO_RED_LED_PIN);

/* Initialize AIOs*/

temp = mraa_aio_init(AIO_TEMP_PIN);

light = mraa_aio_init(AIO_LIGHT_PIN);

sound = mraa_aio_init(AIO_SOUND_PIN);

distance = mraa_aio_init(AIO_DIST_PIN);

red = mraa_aio_init(AIO_RED);

vibro = mraa_aio_init(AIO_VIBRO);

stepper_gpio1 = mraa_gpio_init(GPIO_STEPPER1_PIN);

stepper_gpio2 = mraa_gpio_init(GPIO_STEPPER2_PIN);

stepper_gpio3 = mraa_gpio_init(GPIO_STEPPER3_PIN);

stepper_gpio4 = mraa_gpio_init(GPIO_STEPPER4_PIN);

/*Because we need more 5V outputs*/

additional_power_source1 = mraa_gpio_init(GPIO_PS1);

additional_power_source2 = mraa_gpio_init(GPIO_PS2);

/* Check if all went good*/

if (!check_init())

{

printf(

"Unable to initialize all sensors. Please check your connections.\n");

exit(1);

}

/* Set mode (all to strong) and direction for GPIOs*/

mraa_gpio_mode(button, MRAA_GPIO_STRONG);

mraa_gpio_dir(button, MRAA_GPIO_IN);

mraa_gpio_mode(buzzer, MRAA_GPIO_STRONG);

mraa_gpio_dir(buzzer, MRAA_GPIO_OUT);

mraa_gpio_mode(led_red, MRAA_GPIO_STRONG);

mraa_gpio_dir(led_red, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio1, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio1, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio2, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio2, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio3, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio3, MRAA_GPIO_OUT);

mraa_gpio_mode(stepper_gpio4, MRAA_GPIO_STRONG);

mraa_gpio_dir(stepper_gpio4, MRAA_GPIO_OUT);

mraa_gpio_mode(additional_power_source1, MRAA_GPIO_STRONG);

mraa_gpio_dir(additional_power_source1, MRAA_GPIO_OUT);

mraa_gpio_write(additional_power_source1,1);

mraa_gpio_mode(additional_power_source2, MRAA_GPIO_STRONG);

mraa_gpio_dir(additional_power_source2, MRAA_GPIO_OUT);

mraa_gpio_write(additional_power_source2,1);

}

int read_from_gpio(mraa_gpio_context sensor)

{

return mraa_gpio_read(sensor);

}

int read_from_aio(mraa_aio_context sensor)

{

return mraa_aio_read(sensor);

}

int get_temp_in_celcius(void) // [! IMPORTANT] VCC 3.3 -> 5 on board

{

const int B = 4255; /* B-const value form datasheet for our sensor*/

int adc_read = 0;

adc_read = mraa_aio_read(temp); /* Raw read from aio*/

float resistance = 1023.0 / ((float) adc_read) - 1.0; /* Calculate resistance*/

resistance *= 100000.0;

float temperature = 1.0 / (log(resistance / 100000.0) / B + 1 / 298.15)

- 273.15; /* Magic. Also from datasheet*/

/**

* For more info...

idata
Community Manager
59 Views

Hello Pawek,

 

 

Thank you for providing us this information. It compiles correctly now.

 

 

I think you are probably right, the error could be caused because usr is hoarding all the resources. Nevertheless, I also believe an issue on the code is causing this behavior. I haven't been able to detect any issues on it but I suggest you to check it and to be aware of any possibility of infinite loops.

 

 

I'll keep on seeking and I'll post any useful finding I get.

 

-Peter.
idata
Community Manager
59 Views

Hi Pawek,

 

 

We have been testing the code you provided us, yet we have not been able to replicate the issue. I believe this is not the entire application, am I right?

 

 

I'd like to ask you if you see this behavior only when running this specific application, or, if you are able to see usr on 99% with any other script. If the issue also appears when other applications are running then this might be an issue with the image and you could try to reflash the latest image to see if that helps. Nevertheless, if the issue is only present with this application, the code is probably the cause and it will have to be debugged manually. Since I'm not able to replicate the issue, this is the best suggestion I can give you right now.

 

 

Are you able to replicate the issue with the code posted above? If so, is there anything in specific that I have to do? Am I missing something?

 

 

Let me know.

 

-Peter.
Reply