Sponsored Content
Full Discussion: Sleep function not detected
Top Forums Programming Sleep function not detected Post 302838545 by HellRyder on Tuesday 30th of July 2013 03:09:57 AM
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;
}

 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
XkbAddDeviceLedInfo(3)						   XKB FUNCTIONS					    XkbAddDeviceLedInfo(3)

NAME
XkbAddDeviceLedInfo - Initialize an XkbDeviceLedInfoRec structure SYNOPSIS
XkbDeviceLedInfoPtr XkbAddDeviceLedInfo ( device_info, led_class, led_id ) XkbDeviceInfoPtr device_info; unsigned int led_class; unsigned int led_id; ARGUMENTS
- device_info structure in which to add LED info - led_class input extension class for LED device of interest - led_id input extension ID for LED device of interest DESCRIPTION
XkbAddDeviceLedInfo first checks to see whether an entry matching led_class and led_id already exists in the device_info->leds array. If it finds a matching entry, it returns a pointer to that entry. Otherwise, it checks to be sure there is at least one empty entry in device_info->leds and extends it if there is not enough room. It then increments device_info->num_leds and fills in the next available entry in device_info->leds with led_class and led_id. If successful, XkbAddDeviceLedInfo returns a pointer to the XkbDeviceLedInfoRec structure that was initialized. If unable to allocate suf- ficient storage, or if device_info points to an invalid XkbDeviceInfoRec structure, or if led_class or led_id are inappropriate, XkbAddDe- viceLedInfo returns NULL. To allocate additional space for button actions in an XkbDeviceInfoRec structure, use XkbResizeDeviceButtonActions. STRUCTURES
Information about X Input Extension devices is transferred between a client program and the Xkb extension in an XkbDeviceInfoRec structure: typedef struct { char * name; /* name for device */ Atom type; /* name for class of devices */ unsigned short device_spec; /* device of interest */ Bool has_own_state; /* True=>this device has its own state */ unsigned short supported; /* bits indicating supported capabilities */ unsigned short unsupported; /* bits indicating unsupported capabilities */ unsigned short num_btns; /* number of entries in btn_acts */ XkbAction * btn_acts; /* button actions */ unsigned short sz_leds; /* total number of entries in LEDs vector */ unsigned short num_leds; /* number of valid entries in LEDs vector */ unsigned short dflt_kbd_fb; /* input extension ID of default (core kbd) indicator */ unsigned short dflt_led_fb; /* input extension ID of default indicator feedback */ XkbDeviceLedInfoPtr leds; /* LED descriptions */ } XkbDeviceInfoRec, *XkbDeviceInfoPtr; typedef struct { unsigned short led_class; /* class for this LED device*/ unsigned short led_id; /* ID for this LED device */ unsigned int phys_indicators; /* bits for which LEDs physically present */ unsigned int maps_present; /* bits for which LEDs have maps in maps */ unsigned int names_present; /* bits for which LEDs are in names */ unsigned int state; /* 1 bit => corresponding LED is on */ Atom names[XkbNumIndicators]; /* names for LEDs */ XkbIndicatorMapRec maps; /* indicator maps for each LED */ } XkbDeviceLedInfoRec, *XkbDeviceLedInfoPtr; SEE ALSO
XkbResizeDeviceButtonActions(3) X Version 11 libX11 1.2.1 XkbAddDeviceLedInfo(3)
All times are GMT -4. The time now is 10:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy