From: Jeremy Tan Date: Sun, 29 Sep 2013 07:42:18 +0000 (-0700) Subject: Merge pull request #44 from jtanx/master X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=276903df90e1a0088832294749aca3fa56216697;hp=cc49aadf6963bd0f1ba887f099f21338f41a82ac;p=matches%2FMCTX3420.git Merge pull request #44 from jtanx/master Update gui + stub code for pin stuff on non BBB platforms --- diff --git a/server/bbb_pin.c b/server/bbb_pin.c index a652b97..4d1276b 100644 --- a/server/bbb_pin.c +++ b/server/bbb_pin.c @@ -479,4 +479,11 @@ bool ADC_Read(int id, int *value) *value = strtol(adc_str, NULL, 10); return true; -} \ No newline at end of file +} + +#ifndef _BBB +//For running on systems that are not the BBB +bool True_Stub(void *arg, ...) { return true; } +bool ADC_Read_Stub(int *val, ...) { *val = 0; return true; } +bool GPIO_Read_Stub(bool *val, ...) { *val = false; return true; } +#endif \ No newline at end of file diff --git a/server/bbb_pin.h b/server/bbb_pin.h index 9eb011e..97e7f9b 100644 --- a/server/bbb_pin.h +++ b/server/bbb_pin.h @@ -31,28 +31,28 @@ extern bool PWM_Set(int pin, bool polarity, long period, long duty); // period a extern bool PWM_Stop(int pin); #else -//'Empty' defines so it compiles on any platform that's not the BBB +//Horrible hacks to silence gcc when compiling on systems that are not the BBB +extern bool True_Stub(void *arg, ...); +extern bool ADC_Read_Stub(int *val, ...); +extern bool GPIO_Read_Stub(bool *val, ...); -extern bool GPIO_Export(int pin); -extern void GPIO_Unexport(int pin); - -#define GPIO_Export(pin) true -#define GPIO_Unexport(pin) +#define GPIO_Export(pin) True_Stub((void*)pin) +#define GPIO_Unexport(pin) (void)0 -#define PWM_Export(pin) true -#define PWM_Unexport(pin) +#define PWM_Export(pin) True_Stub((void*)pin) +#define PWM_Unexport(pin) (void)0 -#define ADC_Export(pin) true -#define ADC_Unexport(pin) +#define ADC_Export(pin) True_Stub((void*)pin) +#define ADC_Unexport(pin) (void)0 -//Hack to both zero the result field (so it's never uninitialised) and return true -#define GPIO_Read(pin, result) ((*(result) = 0) == 0) -#define GPIO_Set(pin, value) true +#define GPIO_Read(pin, result) GPIO_Read_Stub(result, pin) +#define GPIO_Set(pin, value) True_Stub((void*)pin, value) -#define ADC_Read(id, value) ((*(value) = 0) == 0) +#define ADC_Read(id, value) ADC_Read_Stub(value, id) -#define PWM_Set(pin, polarity, period, duty) true -#define PWM_Stop(pin) true +#define PWM_Set(pin, polarity, period, duty) True_Stub((void*)pin, polarity, period, duty) +#define PWM_Stop(pin) True_Stub((void*)(int)pin) +//yuck #endif //_BBB diff --git a/server/data.c b/server/data.c index 3824833..dae3172 100644 --- a/server/data.c +++ b/server/data.c @@ -13,9 +13,8 @@ void Data_Init(DataFile * df) { // Everything is NULL - df->filename = NULL; + memset(df, 0, sizeof(DataFile)); pthread_mutex_init(&(df->mutex), NULL); - df->file = NULL; } /** diff --git a/server/sensor.c b/server/sensor.c index 8e4773f..bfa8b66 100644 --- a/server/sensor.c +++ b/server/sensor.c @@ -225,6 +225,7 @@ bool Sensor_Read(Sensor * s, DataPoint * d) break; case DIGITAL_REALTEST: { + d->value = 0; //d->value must be something... valgrind... // Can pass pin as argument, just using 20 as an example here // Although since pins will be fixed, can just define it here if we need to //d->value = pinRead(20); //Pin 20 on the Beaglebone diff --git a/testing/MCTXWeb/public_html/pintest.html b/testing/MCTXWeb/public_html/pintest.html new file mode 100644 index 0000000..5d0527b --- /dev/null +++ b/testing/MCTXWeb/public_html/pintest.html @@ -0,0 +1,156 @@ + + + + BeagleBone Black Pin Test + + + + + + + + + + + + + + + + + +
+ + + +
+
+
Dashboard
+ + + + + +
+ GPIO + + + PWM + +
+ +
Error log
+ +
+ +
+
Analogue input (ADC)
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
AIN01234567
Value
Export
+
+
+ +
+
GPIO controls
+
+ +
+
PWM controls
+
+
+ +
+ + diff --git a/testing/MCTXWeb/public_html/static/mctx.gui.js b/testing/MCTXWeb/public_html/static/mctx.gui.js index a9e8ae7..180c395 100644 --- a/testing/MCTXWeb/public_html/static/mctx.gui.js +++ b/testing/MCTXWeb/public_html/static/mctx.gui.js @@ -81,8 +81,8 @@ $.fn.populateNavbar = function () { return {text : items[item].name, href : href}; }; - menu.populateSubmenu("Sensor data", mctx.sensors, sensorTranslator); - menu.populateSubmenu("Actuator data", mctx.actuators, actuatorTranslator); + menu.populateSubmenu("Sensor data dump", mctx.sensors, sensorTranslator); + menu.populateSubmenu("Actuator data dump", mctx.actuators, actuatorTranslator); menu.appendTo(this); return this; } diff --git a/testing/MCTXWeb/public_html/static/mctx.pintest.js b/testing/MCTXWeb/public_html/static/mctx.pintest.js new file mode 100644 index 0000000..7a792e8 --- /dev/null +++ b/testing/MCTXWeb/public_html/static/mctx.pintest.js @@ -0,0 +1,246 @@ +/** + * mctx.pintest: Pin test stuff. + * Must be included after mctx.gui.js + */ + + +mctx.pintest = {}; +mctx.pintest.gpios = [ + 4, 5, 8, 9, 10, 11, 14, 15, 26, 27, 30, 31, 44, 45, + 46, 47, 48, 49, 60, 61, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 86, 87, 88, 89, 112, 115 + ]; +mctx.pintest.pwms = [0, 1, 2, 3, 4, 5, 6, 7]; +mctx.pintest.refreshRate = 750; + + +function unexport (type, number, container, menu) { + var url = mctx.api + "pin"; + + $.ajax({url : url, data : {type : type, num : number, export : -1}}) + .fail(function () { + switch(type) { + case "adc" : + var text = container.find("input[type='text'][name='" + number + "']"); + var check = container.find("input[type='checkbox'][name='unexport']"); + text.empty(); + check.attr("checked", true); + break; + case "gpi": case "gpo" : + container.remove(); + menu.append($("