Need help

8 years 10 months ago #1797 by djatie
Need help was created by djatie
I try to create auto on off gpio on raspberry b+
I want to off the pin every 07:00 am
this my cron code
0 0 7 1/1 * ? *
then this my script
/*
This code is running one time when program is enabled
*/
public void Setup()
{
}

/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_15", "ControlOff","");
}
im enable it, but nothing happen. can sombody help me, im newbie
thanks for helping
The following user(s) said Thank You: sharonlei

Please Log in or Create an account to join the conversation.

8 years 10 months ago #1803 by EasyIoT
Replied by EasyIoT on topic Need help

djatie wrote: I try to create auto on off gpio on raspberry b+
I want to off the pin every 07:00 am
this my cron code
0 0 7 1/1 * ? *
then this my script
/*
This code is running one time when program is enabled
*/
public void Setup()
{
}

/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_15", "ControlOff","");
}
im enable it, but nothing happen. can sombody help me, im newbie
thanks for helping


Where is enable code?
Also you can use Console.WriteLine to output some debug info in console to see if your cron job is executed. Also I'm not sure cron is ok. Isn't correct: 0 7 * * *
The following user(s) said Thank You: djatie, sharonlei

Please Log in or Create an account to join the conversation.

8 years 9 months ago - 8 years 9 months ago #1817 by djatie
Replied by djatie on topic Need help
Thanks i fix it now working but i have new problem
now i have scenario
Pin 15 wil on off on 7:00Am then off on 7:05AM (its like flip flop)
i have write 2 code
1. AUTO_ON
public void Setup()
{
}
public void Run()
{
DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_15", "ControlOn","");
}
2. AUTO_OFF
public void Setup()
{
}
public void Run()
{
DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_15", "ControlOff","");
}

first i have set cron job auto on with this -> 0 7 * * *
then for off i set with this -> 5 7 * * *
On 7:00 AM this gpio ON, then on 7:05 the gpio want off. I change the cron code but it wont work. I enable then disable all cron job, try with other time. The fist cron will executed but the second wont, Its some wrong with my code? or this cron have some limited?

Please Log in or Create an account to join the conversation.

8 years 7 months ago #2110 by djatie
Replied by djatie on topic Need help
UP UP UP

Please Log in or Create an account to join the conversation.

8 years 7 months ago - 8 years 7 months ago #2238 by NightOne
Replied by NightOne on topic Need help
are you creating a new automation script or changing an old script....I have found on my EasyIOT server when I change an old script, meaning a test automation script that came with the install, then I cant get cron to run.... I have found that if I first create a new script and set the cron when I create the script then the cron works fine.
so my advice if the first cron works, then just create a new automation program, create cron 5 7 * * * and add your code and update.

The other option I suppose which I have been told is bad coding practise, make a single automation script and just add a wait state, I see that you turn on the PIN at 7 every morning, then turn it off again at 5 past 7...so just add

DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_15", "ControlOn","");
System.Threading.Thread.Sleep(300000);
DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_15", "ControlOff","");

The Sleep part of the above is normally considered bad because its a blocking function, meaning the code stops there and waits, it cant do anything else in the meantime. In your code example the code wasnt doing anything anyway so I dont see it as being that bad :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.293 seconds

Forum latest

  • No posts to display.