Modify OpenWrt (via Stty)

Source: Internet
Author: User
OpenWrt the baud rate used by default is 115200,arduino serial port baud rate can set itself. Of course, it is generally set to 9600, or it can be set to 115200. Suppose now OpenWrt baud rate is 115200,arduino the serial port baud rate is 9600. How do I set up a communication?
First we need to use stty this software to change the baud rate on openwrt. Install Stty is very simple, opkg update software list, then opkg install Stty OK. After installation, use the command to change the baud rate: stty-f/dev/ttyath0 raw Speed 9600, so that the OpenWrt serial port baud rate to 9600.
Note that OpenWrt reboot after the serial port baud rate will be restored to 115200, we can write the above command into a shell script, add to the startup item, each boot automatically set serial port baud rate.
Here we look at how to send the data. OpenWrt sends a character ' a ' to the serial port, directly using echo ' a ' >/dev/ttyath0. Arduino over there using 1602 LCD display to receive the data. This shows the ASCII code of the character ' a ', not the real character ' a ', which needs to be converted to display as a. The Arduino code is:
Set serial port: Serial.begin (9600);
Setting 1602 LCD: lcd.setcursor (0, 0);
Monitor serial port and operate LCD:
if (serial.available ()) {Lcd.print (Serial.read ());}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.