NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Serial port config (unix)
April 05, 2010 by Hexorg |
Hello. I'm trying to write a program in c++ that would send some data (a bmp image) to the microcontroller. Should I worry about stuff like baud rate? Or do I just open /dev/ttyUSB0 and put chars in it? |
---|---|
April 05, 2010 by mrobbins (NerdKits Staff) |
Hi Hexorg, You definitely need to make sure the baud rate is correct before opening /dev/ttyUSB0. Check out these posts for use of the "stty" command (at least for Linux / OS X), and also some C code to set baud rates. Hopefully that will get you going in the right direction for C++. Three earlier forum threads: Please post back with results! Mike |
April 06, 2010 by Hexorg |
I've found this little function from here:
You'd have to #include <termios.h> B9600, according to the termios.h file however equals to 9600, not 19200. And it is of a type speed_t, so I think I should be able to set it to 112500 without too much hassle. |
Please log in to post a reply.
Did you know that microcontrollers have two different kinds of memory, program space (flash) and SRAM? Learn more...
|