I am trying to turn an LED on and off when a signal is received within Me-TV
Can anyone help me? I think I am now getting on the right track.
I know the commands to enable GPIO and turn ON and OFF
gpio mode 0 out # enable
gpio 0 1 #turn LED ON
gpio 0 0 #turn LED OFF
I need to integrate them within the app
Within the file "dvb_frontend.cc" from Me-TV there is the following code for signal
if (!ioctl(fd, FE_READ_STATUS, &status))
{
if (status & FE_HAS_LOCK)
{
break;
}
}
usleep(100000);
count += 100;
}
if (!(status & FE_HAS_LOCK))
{
g_debug("Status: %d", status);
throw Exception(_("Failed to lock to channel"));
}
}
guint Frontend::get_signal_strength()
{
guint result = 0;
if (ioctl(fd, FE_READ_SIGNAL_STRENGTH, &result) == -1)
{
throw SystemException(_("Failed to get signal strength"));
}
return result;
}
guint Frontend::get_snr()
{
guint result = 0;
if (ioctl(fd, FE_READ_SNR, &result) == -1)
{
throw SystemException(_("Failed to get signal to noise ratio"));
}
return result;
}
const struct dvb_frontend_parameters& Frontend::get_frontend_parameters() const
{
return frontend_parameters;
}
Quote:
Quote:
I know the commands for turning the gpio pins on and off are
gpio mode 0 out # enable
gpio 0 1 #turn LED ON
gpio 0 0 #turn LED OFF
|
|
Would I merge in the commands somewhere here ?
if (!ioctl(fd, FE_READ_STATUS, &status))
{
if (status & FE_HAS_LOCK)
{
break;##
gpio mode 0 out: # enable
gpio 0 1 #turn LED ON
}
}
usleep(100000);
if (ioctl(fd, FE_READ_SIGNAL_STRENGTH, &result) == -1)
{
throw SystemException(_("Failed to get signal strength"));
}
return result;
gpio mode 0 out # enable
gpio 0 0 #turn LED OFF
Quote:
I know this is not the exact way to perform the action, so if any of you expert programmers out there would kindly compose the lines in the correct format, that would be fantastic.
|