#include <liberipc/eripc.h>#include <liberipc/eripcbusyd.h>#include <liberipc/eripccontentlister.h>#include <pthread.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <sys/ioctl.h>Go to the source code of this file.
Defines | |
| #define | BUFSIZE 1024 |
| #define | BUTTON_IOCTL_BASE 'b' |
| #define | BUTTON_IOCTL_WRITE_ACTIVITY_LED _IOW( BUTTON_IOCTL_BASE,2,unsigned int) |
Functions | |
| static int | execCommand (erIpcCmd_t *cmd) |
| void | serviceCallback (char *szBuffer, int *nBuf, void *data) |
| void * | testIPC (void *arg) |
| void | switch_led (int device, int led_status) |
| int | main (int argc, char *argv[]) |
Variables | |
| static eCcBusyState | busy = ccBusyState_Blink |
| static erClientChannel_t | contentListerChannel |
| #define BUFSIZE 1024 |
| #define BUTTON_IOCTL_WRITE_ACTIVITY_LED _IOW( BUTTON_IOCTL_BASE,2,unsigned int) |
| static int execCommand | ( | erIpcCmd_t * | cmd | ) | [static] |
Definition at line 41 of file erbusyd.c.
00042 { 00043 switch ((int) cmd->cc) 00044 { 00045 case ccBusySetBusy: 00046 if (busy != ccBusyState_Shutdown) 00047 { 00048 busy = atoi(cmd->arg[0]); 00049 if (busy < 0 || busy >= ccBusyState_Undefined) 00050 { 00051 busy = ccBusyState_Off; 00052 } 00053 //printf("-- ccBusySetBusy [%d]\n", busy); 00054 clBusyIndicator(contentListerChannel, busy); 00055 } 00056 break; 00057 00058 case ccBusyUndefined: 00059 default: 00060 // ignore 00061 break; 00062 } 00063 }

| int main | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Definition at line 95 of file erbusyd.c.
00096 { 00097 pthread_t erTid; 00098 int button_device; 00099 int blink = 0; 00100 eCcBusyState wasbusy = ccBusyState_Undefined; 00101 int sleep = 100*1000; 00102 int ret = 0; 00103 00104 if (pthread_create(&erTid, NULL, testIPC, (void *) "1") != 0) 00105 { 00106 printf("%s %s: ", __FILE__, __FUNCTION__); 00107 perror("Could not create thread\n"); 00108 } 00109 // setup the client channel of contentlister 00110 ret = erIpcStartClient(ER_CONTENTLISTER_CHANNEL, &contentListerChannel); 00111 if (ret != 0) 00112 printf("erIpcStartClient returned %d", ret); 00113 00114 button_device = open("/dev/buttons", O_RDWR); 00115 if (button_device == -1) 00116 { 00117 printf("Error opening button device\n"); 00118 exit(-1); 00119 } 00120 00121 while (1) 00122 { 00123 sleep = 100*1000; 00124 00125 switch (busy) 00126 { 00127 case ccBusyState_Blink: 00128 switch_led(button_device, blink); 00129 blink = !blink; 00130 sleep = 40*1000; 00131 break; 00132 00133 case ccBusyState_On: 00134 if (wasbusy != ccBusyState_On) 00135 { 00136 switch_led(button_device, 1); 00137 } 00138 break; 00139 00140 case ccBusyState_Shutdown: 00141 if (wasbusy != ccBusyState_Shutdown) 00142 { 00143 switch_led(button_device, 1); 00144 } 00145 break; 00146 00147 case ccBusyState_Off: 00148 default: 00149 if (wasbusy != ccBusyState_Off) 00150 { 00151 switch_led(button_device, 0); 00152 } 00153 } 00154 00155 wasbusy = busy; 00156 usleep(sleep); 00157 } 00158 00159 return 0; 00160 }

| void serviceCallback | ( | char * | szBuffer, | |
| int * | nBuf, | |||
| void * | data | |||
| ) |
Definition at line 65 of file erbusyd.c.
00066 { 00067 erIpcCmd_t command; 00068 00069 if (busyParseCommand(szBuffer, &command) >= 0) 00070 { 00071 execCommand(&command); 00072 } 00073 }

| void switch_led | ( | int | device, | |
| int | led_status | |||
| ) |
Definition at line 86 of file erbusyd.c.
00087 { 00088 int ret = ioctl(device, BUTTON_IOCTL_WRITE_ACTIVITY_LED, &led_status); 00089 if (ret == -1) 00090 { 00091 printf("Error writing led %d\n", led_status); 00092 } 00093 }
| void* testIPC | ( | void * | arg | ) |
Definition at line 75 of file erbusyd.c.
00076 { 00077 char szBuffer[BUFSIZE]; 00078 int nBuf = BUFSIZE; 00079 int nRet = 0; 00080 00081 nRet = erIpcStartServer(ER_BUSYD_CHANNEL, serviceCallback, szBuffer, &nBuf, NULL); 00082 00083 return (void*)nRet; 00084 }

eCcBusyState busy = ccBusyState_Blink [static] |
erClientChannel_t contentListerChannel [static] |
1.5.6