Merge pull request #36 from justinjessada/master
authorSam Moore <[email protected]>
Mon, 16 Sep 2013 04:08:24 +0000 (21:08 -0700)
committerSam Moore <[email protected]>
Mon, 16 Sep 2013 04:08:24 +0000 (21:08 -0700)
Cleaned up Beaglebone sensors/actuators/PWM code

1  2 
server/actuator.c

diff --combined server/actuator.c
@@@ -147,7 -147,20 +147,20 @@@ void Actuator_SetValue(Actuator * a, do
        //TODO: Set actuator
        switch (a->id)
        {
-               case ACTUATOR_TEST0:
+               case ACTUATOR_TEST0:                    //LED actuator test code, should blink onboard LED next to Ethernet port
+                       FILE *LEDHandle = NULL;         //code reference: http://learnbuildshare.wordpress.com/2013/05/19/beaglebone-black-controlling-user-leds-using-c/
+                       char *LEDBrightness = "/sys/class/leds/beaglebone\:green\:usr0/brightness";
+                       if(value == 1) {
+                               if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL) {
+                                       fwrite("1", sizeof(char), 1, LEDHandle);
+                                       fclose(LEDHandle);
+                               }
+                       else if(value == 0) {
+                               if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL) {
+                                       fwrite("0", sizeof(char), 1, LEDHandle);
+                                       fclose(LEDHandle);
+                       }
+                       else perror("Pin value should be 1 or 0");
                        break;
                case ACTUATOR_TEST1:
                        break;
@@@ -220,7 -233,7 +233,7 @@@ void Actuator_Handler(FCGIContext * con
  
        // key/value pairs
        FCGIValue values[] = {
 -              {"id", &id, FCGI_REQUIRED(FCGI_LONG_T)}, 
 +              {"id", &id, FCGI_REQUIRED(FCGI_INT_T)}, 
                {"set", &set, FCGI_DOUBLE_T},
                {"start_time", &start_time, FCGI_DOUBLE_T},
                {"end_time", &end_time, FCGI_DOUBLE_T},

UCC git Repository :: git.ucc.asn.au