element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Enchanted Objects
  • Challenges & Projects
  • Design Challenges
  • Enchanted Objects
  • More
  • Cancel
Enchanted Objects
Blog Swapping out the bridge
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 19 Jun 2015 7:30 PM Date Created
  • Views 756 views
  • Likes 4 likes
  • Comments 0 comments
  • enchanted_cottage
  • enchanted_objects
  • arduino_yun
  • bridge
Related
Recommended

Swapping out the bridge

Workshopshed
Workshopshed
19 Jun 2015

Disable the bridge

As mentioned in previous episodes the plan was to remove the bridge as that provided much more functionality than it needed to and it also provided root access to the Linino side from the Arduino code. Hans thought would replace it with direct serial communications between the two CPUs.

 

To stop the bridge /etc/inittab is edited to disable the connection of the console to the serial port ttyATH0, the Yún needs to be rebooted after this change.

 

::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
#Disable Bridge
#ttyATH0::askfirst:/bin/ash --login

 

Checking we can communicate

To test the solution Hans produced a simple loopback example

image

 

Python

To get Python to listen to the serial port the PySerial module needs to be installed. That's simply a case of using the package manager.

image

 

opkg update
opkg install pyserial

 

The port is configured as /dev/ttyATH0 and when we open the port we can specify the speed and any timeouts. For testing purposes the timeouts were set to 60s each and the test programme simply echoed the inbound stream back down the line.

 

import serial

try:
  ser = serial.Serial('/dev/ttyATH0', 115200, timeout=60, writeTimeout=60) # Baudrate needs to be mirrored on ATMega side
except:
        exit(1)          # quit as we can't start the serial port

line = ser.readline()  # read a '\n' terminated line

while line != "":
    print(line);            # Display on console
    ser.write(line)        # Echo it back
    line = ser.readline()  # read next line

print("timeout")
ser.close()

 

Arduino

On the Arduino side the serial port is configured as Serial1 and the code to communicate over serial is very straight forward we can echo the message to and from the PC across to the Linino.

 

void setup() {
  Serial.begin(115200);  //To PC
  Serial1.begin(115200);  //To Linino
}

void loop() {
  //From PC to Linino
  int c = Serial.read();              // read from USB-CDC
  if (c != -1) {            
    Serial1.write(c);            //        write char to UART
  }

  //From Linino to PC
  c = Serial1.read();                // read from UART
  if (c != -1) {                      // got anything?
    Serial.write(c);                  //    write to USB-CDC
  }
}

 

Test results

The Python script was started up manually using SSH so that the output could be monitored. A sequence of messages were sent from the PC down the USB, over the bridge and then bounced back again.

image

Give that the test was successful the next step is to add this functionality into our existing scripts and configure the inittab to run our weather script.

 

Code at: https://github.com/Workshopshed/EnchantedObjects/tree/master/Code/Examples/SerialEcho

 

Next: A bit of 3D Printing

 

Reference

Arduino - Serial

Welcome to pySerial’s documentation — pySerial 2.7 documentation

Startup and Run Levels

UNIX man pages : inittab (5)

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube