Eddie Control Board with Linux
kbedolla
Posts: 12
Hi guys,
I have a Eddie Control board which I am trying to communicate with using Linux. I am trying to communicate with the control board but have not succeeded. I am using Ubuntu 11.04 LTS and my code is in C++.
The code that I am using is the following:
My parameter I am using is:
"/dev/ttyUSB0"
and
tio is a termios, the declaration is:
struct termios tio;
here is the actual code:
void Robot::initialize(std::string port)
{
ROS_INFO("Initializing Parallax board serial port connection");
memset(&tio, 0, sizeof (tio));
tio.c_iflag = 0;
tio.c_oflag = 0;
tio.c_cflag = CS8 | CREAD | CLOCAL; // 8n1, see termios.h for more information
tio.c_lflag = 0;
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 5;
tty_fd = open(port.data(), O_RDWR | O_NONBLOCK);
cfsetospeed(&tio, B115200); // 115200 baud
cfsetispeed(&tio, B115200); // 115200 baud
tcsetattr(tty_fd, TCSANOW, &tio);
usleep(100000);
}
I have a seperate function that sends and receives to the board but it seems like I am not establishing an inital connection.
The board is brand new and the only thing I have done is connect it to a windows machine and
ran the "Propeller Tool" software with the file "Eddie- ignore encoders errors.spin".
I did RUN->Compile Current->Load EEPROM. It seemed to have worked fine and ran "view info" and it gave me the com number.
Do I have to do something similar to this when I connect it to my linux machine?
The only thing I did on my linux machine was connect it and ran my program. I am pretty sure I need to do something with the firmware (like i did with windows) but I am not sure what exactly I need to do.
Any help will be greatly appreciate.
Thanks
I have a Eddie Control board which I am trying to communicate with using Linux. I am trying to communicate with the control board but have not succeeded. I am using Ubuntu 11.04 LTS and my code is in C++.
The code that I am using is the following:
My parameter I am using is:
"/dev/ttyUSB0"
and
tio is a termios, the declaration is:
struct termios tio;
here is the actual code:
void Robot::initialize(std::string port)
{
ROS_INFO("Initializing Parallax board serial port connection");
memset(&tio, 0, sizeof (tio));
tio.c_iflag = 0;
tio.c_oflag = 0;
tio.c_cflag = CS8 | CREAD | CLOCAL; // 8n1, see termios.h for more information
tio.c_lflag = 0;
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 5;
tty_fd = open(port.data(), O_RDWR | O_NONBLOCK);
cfsetospeed(&tio, B115200); // 115200 baud
cfsetispeed(&tio, B115200); // 115200 baud
tcsetattr(tty_fd, TCSANOW, &tio);
usleep(100000);
}
I have a seperate function that sends and receives to the board but it seems like I am not establishing an inital connection.
The board is brand new and the only thing I have done is connect it to a windows machine and
ran the "Propeller Tool" software with the file "Eddie- ignore encoders errors.spin".
I did RUN->Compile Current->Load EEPROM. It seemed to have worked fine and ran "view info" and it gave me the com number.
Do I have to do something similar to this when I connect it to my linux machine?
The only thing I did on my linux machine was connect it and ran my program. I am pretty sure I need to do something with the firmware (like i did with windows) but I am not sure what exactly I need to do.
Any help will be greatly appreciate.
Thanks
Comments
Anybody know?
I was really hoping that somebody more knowledgeable on this subject would have spoken up by now. But, I guess it's my ball now so here goes.
First, make sure that you're able to communicate at all with the Propeller. You can use one of two methods:
1. Use BST to try and download a program (http://www.fnarfbargle.com/bst.html)
2. Use PropGCC "propeller-load" to try and download a program (https://code.google.com/p/propgcc/)
This step is important just to make sure that you can communicate with the Propeller. If you can download a program than you're set, and can skip the next section.
Usually, when there's a problem with the connection it's one of a few things:
1. The Propeller isn't connected or powered (unfortunately frequently...)
2. On my Ubuntu system (11.10), I have to type "sudo chmod 666 /dev/ttyUSB0" whenever I connect the Propeller USB (change ttyUSB port number to suit). Otherwise, userspace programs can't access it. This is a bug with my system, and I didn't have this problem in 11.04.
From here, I assume that you have successfully programmed your Propeller. Next, I would load in a little Propeller program that simply echos everything it receives on the USB serial line. Something like this (in Spin) should work: Change the baud (57600) to suit. You also need to get a copy of FullDuplexSerialPlus (link, folder 6). Load this program into EEPROM: most programs (under linux, at least), seem to toggle the DTR line when you connect a serial port. This resets the Propeller, and so whatever is in RAM is lost and the EEPROM is loaded. So, it's important: Load the echo program into EEPROM.
You can (and should!) test this out with a serial terminal. I use "picocom" (which runs in gnome-terminal), but you can also use Cutecom (GUI). Both are available in the repos. Make sure that the characters are being properly echoed.
Now, on to the specific question, and here is where my answer becomes more guess work. I've never used termios. I suppose that you have seen this post? http://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c
I'd try to make a program that simply sends some characters, and then reads the serial port and prints it to cout. If it's successful, you should get the same characters that you sent (via the echo program above).
If all this still doesn't help, then can you post compilable code zip that I can try out?