Sleep function not detected


 
Thread Tools Search this Thread
Top Forums Programming Sleep function not detected
# 1  
Old 07-30-2013
Sleep function not detected

Hello Im using geany to write my c codes. Below is my code to make the internal LED of beaglebone flashing. But i cant seem to use the sleep or delay to make the program wait for a couple of miliseconds. I've included all include files that i can find but none of it solve the problem. Any help is much appreciated Smilie

Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <termios.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#include <assert.h>

using namespace std;

int main() {
    int i=0;
    printf("LED Flash Start\n");
    
    FILE *LEDHandle = NULL ;
    const char *LEDBrightness = "/sys/class/leds/beaglebone:green:usr0/brightness";
    
    
    while(i<10){
        
        if((LEDHandle = fopen(LEDBrightness, "r+"))!=NULL){
            fwrite("1", sizeof(char), 1, LEDHandle);
            fclose(LEDHandle);
        }
        Sleep(1000);
        
        if((LEDHandle = fopen(LEDBrightness, "r+"))!=NULL){
            fwrite("0", sizeof(char), 1, LEDHandle);
            fclose(LEDHandle);
        }
        Sleep(1000);
    }
    printf("LED Flash Stop\n");
    return 0;
}

# 2  
Old 07-30-2013
You have to write sleep with a lowercase s, this is not the case in your code above.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Doubt with signals and sleep function

Hi , I have a doubt with signals and sleep function. In a program i have this while(1) { //do some work sleep(1); }And in a thread i have something like this union sigval data; char message; char msg; data.sival_int=0; while(1) { ... (4 Replies)
Discussion started by: bacesado
4 Replies

2. Hardware

iPhone Not being detected

I'm New to the linux world I'm running OpenSuse and as soon as I installed everything was wokring like a charm. and i said to myself I'm so keeping this OpSys! everytime i would plug in my iPhone it would read it as anything else as a filesystem and i was able to go through the device files an etc,... (9 Replies)
Discussion started by: JuankyKong
9 Replies

3. Shell Programming and Scripting

How the Sleep function will work?

Hi All, I am new to Unix , there i am facing one problem with sleep command. that is .. in while loop i have defined sleep function .. my condition is like this while #i knew this is infinite loop do sleep 200 echo "hello " done. this condition will never become .. true... (3 Replies)
Discussion started by: mandlysreedhar
3 Replies

4. Programming

C Sleep function hangs @ __kernel_vsyscall ()

This is the gdb backtrace. ^C Program received signal SIGINT, Interrupt. 0xffffe424 in __kernel_vsyscall () (gdb) bt #0 0xffffe424 in __kernel_vsyscall () #1 0xb7e56a70 in __nanosleep_nocancel () from /lib/libc.so.6 #2 0xb7e568bb in __sleep (seconds=0) at sleep.c:138 #3 0x080496d5 in... (6 Replies)
Discussion started by: dragonpoint
6 Replies

5. Shell Programming and Scripting

Help with sleep function

Hey everyone, just entering the linux world, I need some help with a shell script i'm trying to write, the purpose is to check every 10 minutes what was the last time a certain file was modified, and if there is a connection to the server at this moment send an email with the date of the... (2 Replies)
Discussion started by: moshe88
2 Replies

6. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

7. Solaris

OS is not detected CPU and memory

Hi, Server AIBVRFCC failed POST while booting on 06/28/2009. Server is up, but OS cannot see two CPUs (CPU 0 and CPU 2) and half of the installed system memory (8 GB is physically installed but only 4 GB is seen by OS now). bld00016:root psrinfo 1 on-line since 06/28/09 05:51:36 3 on-line... (1 Reply)
Discussion started by: arumsun
1 Replies

8. Solaris

dmfe0: TX stall detected

I just starting recieving in /var/adm/messages this kind of notice: dmfe: NOTICE: dmfe0: TX stall detected after 2 ticks in state 3; automatic recovery initiated does any one have any idea why this notice is generated ? thanks in advance. (1 Reply)
Discussion started by: pasalagua
1 Replies

9. Debian

HDD not detected by RHL 9 (or 7.2)

Hi, I have got myself a new hard disk- a 80 GB SATA IDE from Seagate. When I try installing Red Hat Linux 9(and RHL 7.2 too), it displays an error message saying that it fails to detect any hard drive. In the BIOS, I tried changing the drive configuration to "Legacy Drive", but that didnt help... (5 Replies)
Discussion started by: Abhishek Ghose
5 Replies
Login or Register to Ask a Question