LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-12-2016, 04:44 AM   #1
andi968
LQ Newbie
 
Registered: Apr 2016
Posts: 1

Rep: Reputation: Disabled
GPIO output Raspberry pi3


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);
Quote:
And
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.
 
Old 04-12-2016, 03:23 PM   #2
penguinbody
LQ Newbie
 
Registered: Jan 2016
Posts: 10

Rep: Reputation: Disabled
You might get a better response on the official Raspberry Pi forums.

Last edited by penguinbody; 04-12-2016 at 04:27 PM.
 
Old 04-13-2016, 01:38 PM   #3
skoona
Member
 
Registered: Mar 2004
Location: Indiana, USA
Distribution: Fedora, CentOS, Ubuntu, OS/X, Raspbian
Posts: 90

Rep: Reputation: 18
andi968,

There are a wide range of methods available to solve the question you asked. Your question requires more background info than I have time to type, so here are a few links that will answer all your questions.

http://hertaville.com/introduction-t...gpio-in-c.html
http://www.pieter-jan.com/node/15
https://www.raspberrypi.org/forums/v...p?f=33&t=82752
http://elinux.org/RPi_GPIO_Code_Samp...egister_access

hope this helps
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: GPIO Zero and Raspberry Pi programming starter projects LXer Syndicated Linux News 0 02-01-2016 10:40 AM
LXer: Raspberry Pi GPIO pins the Python column LXer Syndicated Linux News 0 06-03-2014 11:16 PM
LXer: New GPIO board for Raspberry Pi LXer Syndicated Linux News 0 03-24-2014 09:53 PM
[SOLVED] How to set GPIO output in/during AT91bootstrap? embLinux Linux - Embedded & Single-board computer 1 01-31-2014 02:35 AM
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration