PDA

View Full Version : [Question(s)] problems initializing RoBoard ports (linux)



marsman
09-04-2009, 06:04 AM
Hi,

thanks to kboyd's fabulous tutorials I was finally able to get my RoBoard started with an Ubutu 9.04 Linux system. The graphic card and LAN network adapter work well. I can't really complain about the boot time (like discussed in another thread), this is ok.

Now, I wanted to toggle some PWM lines. Using the 1.5b RoBoIO library that should be easy but I seem not to be able to get past the initialization of the board. Below is my simple code. Can someone help if I am doing anything wrong?

Note: this code comiles & links with no errors. It can be executed under linux with no errors but it terminates with TF= false which means the rcservo_Initialization() failed. Any thoughts?

#include <iostream>
#include "roboard.h"

int main(void)
{
unsigned long PWM_period = 10000; // 10000us
unsigned long PWM_duty = 1500; // 1500us
unsigned long count = 100;
int channel=0;
bool TF;

std::cout << "get ready:" << std::endl;
TF=rcservo_Initialize(RCSERVO_USECHANNEL0);
if (TF)
{
std::cout << "init done: " << TF << std::endl;
rcservo_EnterPWMMode();
rcservo_SendPWMPulses(channel, PWM_period, PWM_duty, count);
while (!rcservo_IsPWMCompleted(channel))
{
std::cout << "waiting ...." << std::endl;
}
}
else
{
std::cout << "init failed: " << TF << std::endl;
}
rcservo_Close();
std::cout << "Done" << std::endl;
}

marsman
09-04-2009, 09:54 PM
Hi,

you may disregard my post above here. Actually, the mistake I made is probably as stupid as replying to my own post. However, I did not know that I have to login as 'root' in my Linux in order to communicate with the hardware. Now things work like they should.

Sorry to bother.

LinuxGuy
09-04-2009, 10:19 PM
you may disregard my post above here. Actually, the mistake I made is probably as stupid as replying to my own post. However, I did not know that I have to login as 'root' in my Linux in order to communicate with the hardware. Now things work like they should.
It's a BAD idea to be logged in as root for normal operations of your system, regardless of what you are doing. Your problem indicates at least one of several possibilities.

1) Your regular user account is not in the proper group to do the required operation.
2) The permissions and/or group settings on a resource you are trying to access legitimately is wrong.
3) A combination of the first two items.

It's not unusual to find a problem in these areas due to the distribution authors often making things too secure, such as access to sound devices, serial ports, etc. I almost always have to change permissions on a few things after installing Linux fresh. This is often true with Ubuntu or Kubuntu. This is just a required part of customizing a Linux installation and will be true to some degree for most, if not all, distributions.

Common groups a regular user account may need to be in are audio, cdrom, and uucp or tty (often the group for serial ports and similar devices). Your account may need to be in other groups also, depending on what you need to do. You should take some time to figure out what devices and other resources you need to access and change things accordingly to suit your regular user account. Do not login as root unless you REALLY need to.

About the only times I need to login as root on my system is to do final installation of software I build or to install new packages from binaries. I may also do a little development and testing to see what resources are required to do something, and then change the permissions accordingly to allow it from a regular non-root account.

8-Dale