if (strcmp(type, "gpo") == 0 || strcmp(type, "gpi") == 0)
{
- if (pin_export < 0)
- GPIO_Unexport(num);
- else
+ //Don't allow unexport of gpio
+ if (pin_export > 0)
ret = GPIO_Export(num);
}
else if (strcmp(type, "pwm") == 0)
}
else if (strcmp(type, "adc") == 0)
{
- if (pin_export < 0)
- ADC_Unexport(num);
- else
+ //Don't allow unexport of adc
+ if (pin_export > 0)
ret = ADC_Export(num);
}
return ret;
if (strcmp(type, "gpo") == 0)
{
- if (num <= 0 || num > GPIO_NUM_PINS)
+ if (num <= 0 || num > GPIO_MAX_NUMBER)
{
FCGI_RejectJSON(context, "Invalid GPIO pin");
return;
}
else if (strcmp(type, "gpi") == 0)
{
- if (num < 0 || num >= GPIO_NUM_PINS)
+ if (num < 0 || num > GPIO_MAX_NUMBER)
{
FCGI_RejectJSON(context, "Invalid GPIO pin");
return;
else
{
FCGI_PrintRaw("Content-type: text/plain\r\n\r\n");
- FCGI_PrintRaw("ADC%d reads %d\n", num, raw_adc);
+ FCGI_PrintRaw("%d\n", raw_adc);
}
}
else if (strcmp(type, "pwm") == 0)
{
- if (num < 0 || num >= PWM_NUM_SAFE_PINS)
+ if (num < 0 || num >= PWM_NUM_PINS)
{
FCGI_RejectJSON(context, "Invalid PWM pin");
return;
else
{
Log(LOGDEBUG, "Stopping PWM%d",num);
- PWM_Stop(g_pin_safe_pwm[num]);
+ PWM_Stop(num);
FCGI_PrintRaw("Content-type: text/plain\r\n\r\n");
FCGI_PrintRaw("PWM%d stopped",num);
}