raspberry pi questions

Sysprogs forums Forums VisualGDB raspberry pi questions

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #573
    revenue
    Participant

    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 > value

    I 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
    #include

    class 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);
    }
    }

    #2429
    revenue
    Participant

    OK, 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?

    #2430
    support
    Keymaster

    Hi,

    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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.