From: Jeremy Tan Date: Fri, 27 Sep 2013 13:52:04 +0000 (+0800) Subject: crappy hacks to disable pin code on x86 platforms while silencing gcc X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=692d8040dfafca96cd68b4de09e66114aadce7b8;p=matches%2FMCTX3420.git crappy hacks to disable pin code on x86 platforms while silencing gcc --- 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