Unable to use roboIO library in linux

Based on DMP's Vortex processor / SoC this board is a full computer capable of running a standard Windows and Linux installation on the backpack of your robot.
8 postsPage 1 of 1
8 postsPage 1 of 1

Unable to use roboIO library in linux

Post by soroush » Sun Dec 04, 2011 7:22 pm

Post by soroush
Sun Dec 04, 2011 7:22 pm

Hello Everyone,

This is my first post on this forum :roll: I'm trying to send / receive data on COM1 (RS232) port of rb-110 board. have tried QSerialDevice and ROBO-IO library, ports are always closed or unable to open them... This is a simple c++ code to write some data on com1:

Code: Select all
#include <com>
#include <iostream>

int main(int argc, char *argv[])
{
    if(com1_Init(COM_HDUPLEX))
    {
        int i=0;
        while(i<1000)
        {
            com1_Write(0x55);
            ++i;
        }
        std::cout << "100 000 bytes has been written to port COM1" << std::endl;
        com1_Close();
    }
    else
    {
       std::cout << "Unable to open port" << std::endl;
    }
    return 0;
}


Output is always "Unable to open port"

What I'm missing?
Hello Everyone,

This is my first post on this forum :roll: I'm trying to send / receive data on COM1 (RS232) port of rb-110 board. have tried QSerialDevice and ROBO-IO library, ports are always closed or unable to open them... This is a simple c++ code to write some data on com1:

Code: Select all
#include <com>
#include <iostream>

int main(int argc, char *argv[])
{
    if(com1_Init(COM_HDUPLEX))
    {
        int i=0;
        while(i<1000)
        {
            com1_Write(0x55);
            ++i;
        }
        std::cout << "100 000 bytes has been written to port COM1" << std::endl;
        com1_Close();
    }
    else
    {
       std::cout << "Unable to open port" << std::endl;
    }
    return 0;
}


Output is always "Unable to open port"

What I'm missing?
soroush offline
Newbie
Newbie
Posts: 5
Joined: Sun Dec 04, 2011 7:11 pm

Post by gdo » Mon Dec 19, 2011 1:12 pm

Post by gdo
Mon Dec 19, 2011 1:12 pm

Hello,

I do not exactly know how does the RoboIO works but do you have permissions to access to /dev/ttyS* on your roboard ?
Did you tried to run your code as root ?

gdo
Hello,

I do not exactly know how does the RoboIO works but do you have permissions to access to /dev/ttyS* on your roboard ?
Did you tried to run your code as root ?

gdo
gdo offline
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Fri Dec 17, 2010 5:47 pm

Post by soroush » Mon Dec 19, 2011 3:08 pm

Post by soroush
Mon Dec 19, 2011 3:08 pm

gdo wrote:I do not exactly know how does the RoboIO works but do you have permissions to access to /dev/ttyS* on your roboard ?
Did you tried to run your code as root ?
gdo


Yes.

I changed inittab content to directly login into debian with root user and no password. (don't want to connect a keyboard !!) and after logging with ssh I always do
Code: Select all
sudo -i

and then execute the above code.

Note 1: Console redirection is off.
Note 2: I also tried COM 4 and COM 3 ... no hope :-|
gdo wrote:I do not exactly know how does the RoboIO works but do you have permissions to access to /dev/ttyS* on your roboard ?
Did you tried to run your code as root ?
gdo


Yes.

I changed inittab content to directly login into debian with root user and no password. (don't want to connect a keyboard !!) and after logging with ssh I always do
Code: Select all
sudo -i

and then execute the above code.

Note 1: Console redirection is off.
Note 2: I also tried COM 4 and COM 3 ... no hope :-|
soroush offline
Newbie
Newbie
Posts: 5
Joined: Sun Dec 04, 2011 7:11 pm

Post by gdo » Mon Dec 19, 2011 3:57 pm

Post by gdo
Mon Dec 19, 2011 3:57 pm

Following the doc, you should add :

Code: Select all
std::cout << roboio_GetErrMsg() << std:endl;


like that :

Code: Select all
#include <com>
#include <iostream>

int main(int argc, char *argv[])
{
    if(com1_Init(COM_HDUPLEX))
    {
        int i=0;
        while(i<1000)
        {
            com1_Write(0x55);
            ++i;
        }
        std::cout << "100 000 bytes has been written to port COM1" << std::endl;
        com1_Close();
    }
    else
    {
       std::cout << "Unable to open port" << std::endl;
       std::cout << roboio_GetErrMsg() << std:endl;
    }
    return 0;
}


And tell me what it gives.

gdo
Following the doc, you should add :

Code: Select all
std::cout << roboio_GetErrMsg() << std:endl;


like that :

Code: Select all
#include <com>
#include <iostream>

int main(int argc, char *argv[])
{
    if(com1_Init(COM_HDUPLEX))
    {
        int i=0;
        while(i<1000)
        {
            com1_Write(0x55);
            ++i;
        }
        std::cout << "100 000 bytes has been written to port COM1" << std::endl;
        com1_Close();
    }
    else
    {
       std::cout << "Unable to open port" << std::endl;
       std::cout << roboio_GetErrMsg() << std:endl;
    }
    return 0;
}


And tell me what it gives.

gdo
gdo offline
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Fri Dec 17, 2010 5:47 pm

Post by soroush » Tue Dec 20, 2011 12:17 pm

Post by soroush
Tue Dec 20, 2011 12:17 pm

gdo wrote:Following the doc, you should add :
....
And tell me what it gives.
gdo


It says:

Code: Select all
Unable to open port
unmatched RoBoard version


I've downloaded the roboIO code for gcc... There was no option for switch between rb110 and rb100 or something else during compilation... is there?
gdo wrote:Following the doc, you should add :
....
And tell me what it gives.
gdo


It says:

Code: Select all
Unable to open port
unmatched RoBoard version


I've downloaded the roboIO code for gcc... There was no option for switch between rb110 and rb100 or something else during compilation... is there?
soroush offline
Newbie
Newbie
Posts: 5
Joined: Sun Dec 04, 2011 7:11 pm

Post by gdo » Tue Dec 20, 2011 1:31 pm

Post by gdo
Tue Dec 20, 2011 1:31 pm

No I do not think there is specific build flags according to roboard version you use.

I think it is related to cpu id.

In libsrc/common.cpp file from robio sources, can you modify roboio_CheckRBVer function as follow, just to display cpuid in the error message :
Code: Select all
RBAPI(bool) roboio_CheckRBVer(void) {  // called only by io_Init(); the caller must ensure that I/O ports can be accessed by this function
        int  cpuid = io_CpuID();

        switch (roboio_GetRBVer())
        {
            case RB_100b1:
            case RB_100b2:
            case RB_100b3:
            case RB_100:
                if (cpuid == CPU_VORTEX86DX_1) return true;
                break;
            case RB_100RD:
            case RB_110:
            case RB_050:
                if (cpuid == CPU_VORTEX86DX_3) return true;
                break;
            default:
                   err_SetMsg(ERROR_RBVER_UNKNOWN, "unknown RoBoard version");
                   return false;
        } //end switch (ver)

           err_SetMsg(ERROR_RBVER_UNMATCH, "unmatched RoBoard version, cpuid=%i",cpuid);
           return false;
    }


I think you are in the RB_110 case but that cpuid does not match CPU_VORTEX86DX_3.

gdo
No I do not think there is specific build flags according to roboard version you use.

I think it is related to cpu id.

In libsrc/common.cpp file from robio sources, can you modify roboio_CheckRBVer function as follow, just to display cpuid in the error message :
Code: Select all
RBAPI(bool) roboio_CheckRBVer(void) {  // called only by io_Init(); the caller must ensure that I/O ports can be accessed by this function
        int  cpuid = io_CpuID();

        switch (roboio_GetRBVer())
        {
            case RB_100b1:
            case RB_100b2:
            case RB_100b3:
            case RB_100:
                if (cpuid == CPU_VORTEX86DX_1) return true;
                break;
            case RB_100RD:
            case RB_110:
            case RB_050:
                if (cpuid == CPU_VORTEX86DX_3) return true;
                break;
            default:
                   err_SetMsg(ERROR_RBVER_UNKNOWN, "unknown RoBoard version");
                   return false;
        } //end switch (ver)

           err_SetMsg(ERROR_RBVER_UNMATCH, "unmatched RoBoard version, cpuid=%i",cpuid);
           return false;
    }


I think you are in the RB_110 case but that cpuid does not match CPU_VORTEX86DX_3.

gdo
gdo offline
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Fri Dec 17, 2010 5:47 pm

Post by soroush » Tue Dec 20, 2011 7:07 pm

Post by soroush
Tue Dec 20, 2011 7:07 pm

Thank you gdo
I searched source code of rbio, the problem is solved by setting version of board. Just including roboard.h and adding this line:
Code: Select all
roboio_SetRBVer(RB_110);

I don't know if this is the correct way or not :/
Thank you gdo
I searched source code of rbio, the problem is solved by setting version of board. Just including roboard.h and adding this line:
Code: Select all
roboio_SetRBVer(RB_110);

I don't know if this is the correct way or not :/
soroush offline
Newbie
Newbie
Posts: 5
Joined: Sun Dec 04, 2011 7:11 pm

Post by gdo » Tue Dec 20, 2011 7:27 pm

Post by gdo
Tue Dec 20, 2011 7:27 pm

I think you are right, yes. ;)

I missed this function earlier.

Well done !
I think you are right, yes. ;)

I missed this function earlier.

Well done !
gdo offline
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Fri Dec 17, 2010 5:47 pm


8 postsPage 1 of 1
8 postsPage 1 of 1
cron