Sysprogs forums › Forums › VisualGDB › raspberry pi questions
- This topic has 2 replies, 2 voices, and was last updated 11 years, 6 months ago by support.
-
AuthorPosts
-
May 25, 2013 at 13:32 #573revenueParticipant
Hello, I am new to this so please be gentle. 😯
I have a raspberry pi and also visual studio. I have it setup to work with visualGDB, i can run the “blinking LED” project on my pi but the led does not change state.
However, the led does blink on gpio27 when i do this on the pi command line:
sudo su
cd /sys/class/gpio
echo 27 > export
cd gpio27
echo out > direction
echo 1 > value
echo 0 > valueI have used the program as listed in the tutorial (listed below). What am i missing?
also is it posible to use visualGDB to make a GUI on the pi? Is it posilbe to use visual basic?thanks for any help.
steve#include
#include
#include
#includeclass LinuxFile
{
private:
int m_Handle;public:
LinuxFile(const char *pFile, int flags = O_RDWR)
{
m_Handle = open(pFile, flags);
}~LinuxFile()
{
if (m_Handle != -1)
close(m_Handle);
}size_t Write(const void *pBuffer, size_t size)
{
return write(m_Handle, pBuffer, size);
}size_t Read(void *pBuffer, size_t size)
{
return read(m_Handle, pBuffer, size);
}size_t Write(const char *pText)
{
return Write(pText, strlen(pText));
}size_t Write(int number)
{
char szNum[32];
snprintf(szNum, sizeof(szNum), “%d”, number);
return Write(szNum);
}
};class LinuxGPIOExporter
{
protected:
int m_Number;public:
LinuxGPIOExporter(int number)
: m_Number(number)
{
LinuxFile(“/sys/class/gpio/export”, O_WRONLY).Write(number);
}~LinuxGPIOExporter()
{
LinuxFile(“/sys/class/gpio/unexport”,
O_WRONLY).Write(m_Number);
}
};class LinuxGPIO : public LinuxGPIOExporter
{
public:
LinuxGPIO(int number)
: LinuxGPIOExporter(number)
{
}void SetValue(bool value)
{
char szFN[128];
snprintf(szFN, sizeof(szFN),
“/sys/class/gpio/gpio%d/value”, m_Number);
LinuxFile(szFN).Write(value ? “1” : “0”);
}void SetDirection(bool isOutput)
{
char szFN[128];
snprintf(szFN, sizeof(szFN),
“/sys/class/gpio/gpio%d/direction”, m_Number);
LinuxFile(szFN).Write(isOutput ? “out” : “in”);
}
};int main(int argc, char *argv[])
{
LinuxGPIO gpio27(27);
gpio27.SetDirection(true);
bool on = true;
for (;;)
{
printf(“Switching %s the LED…n”, on ? “on” : “off”);
gpio27.SetValue(on);
on = !on;
sleep(1);
}
}May 25, 2013 at 14:07 #2429revenueParticipantOK, I figured it out… have to set it up as the root user. 🙄
still have these questions:
also is it posible to use visualGDB to make a GUI on the pi?
Is it posilbe to use visual basic?May 25, 2013 at 23:47 #2430supportKeymasterHi,
Yes, running as root is required to access low-level hardware functionality. This is by design.
The easiest way to develop GUI for Raspberry PI with VisualGDB would be with QT. Please follow this tutorial: http://visualgdb.com/tutorials/linux/qt/Unfortunately VisualGDB does not support Visual Basic, as the main focus of our product is to provide Windows-style experience with native Linux tools and Linux has no native support for Visual Basic.
-
AuthorPosts
- You must be logged in to reply to this topic.