From: Debian User Date: Mon, 16 Sep 2013 06:31:18 +0000 (+0000) Subject: Make it work on the BBB X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=118d9bd329135edaf88eaf345479b17c2456a689;p=matches%2FMCTX3420.git Make it work on the BBB --- diff --git a/server/actuator.c b/server/actuator.c index 2967c6c..759fffc 100644 --- a/server/actuator.c +++ b/server/actuator.c @@ -106,7 +106,7 @@ void * Actuator_Loop(void * arg) pthread_mutex_unlock(&(a->mutex)); if (!a->activated) break; - + Log(LOGDEBUG, "About to Setvalue"); Actuator_SetValue(a, a->control.value); } @@ -127,6 +127,7 @@ void Actuator_SetControl(Actuator * a, ActuatorControl * c) if (c != NULL) a->control = *c; a->control_changed = true; + Log(LOGDEBUG, "About to broadcast"); pthread_cond_broadcast(&(a->cond)); pthread_mutex_unlock(&(a->mutex)); @@ -144,23 +145,30 @@ void Actuator_SetValue(Actuator * a, double value) gettimeofday(&t, NULL); DataPoint d = {TIMEVAL_DIFF(t, g_options.start_time), value}; + Log(LOGDEBUG, "id: %d", a->id); //TODO: Set actuator switch (a->id) { - 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); + 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:usr3/brightness"; + int val = (!!(int)value); + Log(LOGDEBUG, "Val: %d", val); + if(val == 1) { + if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL) { + fwrite("1", sizeof(char), 1, LEDHandle); + fclose(LEDHandle); + } else perror("fail"); + } + else if(val == 0) { + if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL) { + fwrite("0", 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"); } - else perror("Pin value should be 1 or 0"); break; case ACTUATOR_TEST1: break; @@ -172,6 +180,7 @@ void Actuator_SetValue(Actuator * a, double value) Data_Save(&(a->data_file), &d, 1); } + /** * Helper: Begin Actuator response in a given format * @param context - the FCGIContext diff --git a/server/fastcgi.c b/server/fastcgi.c index 092eaed..62978ea 100644 --- a/server/fastcgi.c +++ b/server/fastcgi.c @@ -442,7 +442,7 @@ void FCGI_PrintRaw(const char *format, ...) void FCGI_WriteBinary(void * data, size_t size, size_t num_elem) { Log(LOGDEBUG,"Writing!"); - FCGI_fwrite(data, size, num_elem, FCGI_stdout); + fwrite(data, size, num_elem, stdout); } /** diff --git a/server/image.c b/server/image.c index 81c692b..05a587e 100644 --- a/server/image.c +++ b/server/image.c @@ -8,7 +8,7 @@ void Image_Handler(FCGIContext * context, const char * params) { static CvCapture * capture = NULL; if (capture == NULL) - capture = cvCreateCameraCapture(-1); + capture = cvCreateCameraCapture(0); static int p[] = {CV_IMWRITE_JPEG_QUALITY, 100, 0}; diff --git a/server/interferometer.c b/server/interferometer.c index 136148b..4861318 100644 --- a/server/interferometer.c +++ b/server/interferometer.c @@ -6,7 +6,6 @@ #include "cv.h" #include "highgui_c.h" #include "interferometer.h" -#include "analysis.h" #include /** Buffer for storing image data. Stored as a single intensity value for the laser light **/ diff --git a/server/run.sh b/server/run.sh index a172c45..aafc5d1 100755 --- a/server/run.sh +++ b/server/run.sh @@ -1,6 +1,6 @@ #!/bin/bash # Use this to quickly test run the server in valgrind -spawn-fcgi -p9005 -n ./valgrind.sh +#spawn-fcgi -p9005 -n ./valgrind.sh # Use this to run the server normally #./stream & -#spawn-fcgi -p9005 -n ./server +spawn-fcgi -p9005 -n ./server diff --git a/server/server b/server/server new file mode 100755 index 0000000..0778a46 Binary files /dev/null and b/server/server differ diff --git a/server/test_a0 b/server/test_a0 new file mode 100644 index 0000000..d2e139f Binary files /dev/null and b/server/test_a0 differ diff --git a/server/test_a1 b/server/test_a1 new file mode 100644 index 0000000..e69de29 diff --git a/server/test_s0 b/server/test_s0 new file mode 100644 index 0000000..d733bc5 Binary files /dev/null and b/server/test_s0 differ diff --git a/server/test_s1 b/server/test_s1 new file mode 100644 index 0000000..70a9cea Binary files /dev/null and b/server/test_s1 differ diff --git a/server/test_s2 b/server/test_s2 new file mode 100644 index 0000000..b344435 Binary files /dev/null and b/server/test_s2 differ diff --git a/server/test_s3 b/server/test_s3 new file mode 100644 index 0000000..1600a47 Binary files /dev/null and b/server/test_s3 differ diff --git a/server/test_s4 b/server/test_s4 new file mode 100644 index 0000000..8dfbdcf Binary files /dev/null and b/server/test_s4 differ diff --git a/server/test_s5 b/server/test_s5 new file mode 100644 index 0000000..51bb5db Binary files /dev/null and b/server/test_s5 differ diff --git a/web/stream.html b/web/stream.html index 71fb0d0..69b08dc 100644 --- a/web/stream.html +++ b/web/stream.html @@ -2,4 +2,4 @@ - +