I’ve been busy working on getting serial communication up and running for my arduino. I’ve had to learn about the termios C library with allmost all Unix C and C++ programs have to use when they communicate over a serial port. I was able to to find a lot of example codes online to help me.  What termios really does is define a structure of variables that define how the serial comunication  works. once this is defined you use the C library unistd witch has the functions open, read and write.  They are fairly self explanatory but they do almost all of the work.

When sending the data you can only send bytes and strings of bytes.  While this may make it seem like you have to send character  stings but you can just use bitwise operatoes to break your vareables into bytes and patch them back to gether when you on the other end.  This both reduces the computation needed on both ends but also reduces the amount of information being sent trough the serial connection.

I am currently running a test to see if any information is lost over a long period of time sending this information I have the baud rate set at 38400 and have the information being sent at 100Hz. So far it seems that this is working quite well and I will have nothing to worry about.

Jarek

Advertisements