We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Making Omega2 talks with SAMD21 (Arduino Zero)



  • Yes i am testing Arduino bridge software (Console Read) with yunbridge linux package

    and i using Omega2 with Arduino Dock 2 and software (Arduino IDE and Putty) running on windows 10 home

    I have seen documentation for Arduino dock 2, hardware serial is connected with omega Uart1 (/dev/ttyS1) . So i planned to understand first what dock is sending message to omega during YUN bridge Init.

    Testing procedure

    1. UART communication test at High baudrate.
    • checked sent data from dock using FTDI RX connected to TX pin of dock

    • checked received data on linux by using screen /dev/ttyS1 250000

    One more strange thing i found, at High baud-rate (250000, which is the default baudrate of YUN bridge) omega 2 not able receive data. Dock is sending properly. Why?
    Please check below snapshot. Where left side is COM93 FTDI UART listener and right is Omega2 SSH0_1564827361299_UartFailatHighBaud.PNG

    1. UART communication test at LOW baudrate (57600)
      Please check below image, you can see its working good at 57600 baudrate.

    0_1564827552355_UartGoodAtLOWBaud-57600.PNG

    1. Then i had set yun bridge baudrate at 57600 by calling
    • uci set yunbridge.config.baudrate='57600'
      uci commit yunbridge
      reboot

    • After that i had done Simple Yun Bridge test at 57600 baud.
      In this test arduino dock geting stuck on bridge begin itself Dock is sending bridge start command continuously at regular interval and omega2 is not responding. As if its not listening. Even i saw some garbage on screen. I feel garbage was produce by dock itself
      Please check image below

    0_1564828185751_Bridge_test.PNG

    What should i do, please response soon
    Thanks



  • @Suman-kumar-Jha
    Arduino Dock 2 is not the best test bed for you due to lack of the Serial Monitor on Arduino IDE.

    On Arduino Dock 2 the serial connection between the on board Omega2(+) and the on board ATmega328P is hard- wired
    (Omega2's UART1/ttyS1 : TX1, RX1, GND to MCU's Rx (D0), Tx (D1), GND respectively via a TXS0108E bidirectional level shifter).

    On the serial line the "run-bridge XX100 XX100 ... " (XX100 max 50 times) is not some garbage it's some command - sent by an MCU (Arduino) to an MPU (now it's an Omega2).

    uci set yunbridge.config.baudrate='57600' does not change the baudrate of the serial port of the '/sbin/yunbridge' script.


    BTW what are the outputs of these commands on your test environment (ie. on Omega2):
    stty -F /dev/ttyS0 -a
    stty -F /dev/ttyS1 -a



  • Thanks György Farkas for explaining.

    Arduino Dock 2 is not the best test bed for you due to lack of the Serial Monitor on Arduino IDE.
    Did you mean arduino IDE, where arduino IDE has serial monitor. But actually atmega328p comes with only one hardware serial.
    For the above i can use another arduino board multiple hardware serial. So i can assign one of the hardware serial (Serial1) to the Omega UART. What you suggest?

    On the serial line the "run-bridge XX100 XX100 ... " (XX100 max 50 times) is not some garbage it's some command

    • But on putty screen you can see, there are some unknown symbols also apart from above command. Are these unknows symbols (¢qÿ) are part of commands ?

    • By seeing the putty screen and the commands, can i say arduino dock is sending right message for YUN bridge initialization ?

    uci set yunbridge.config.baudrate='57600' does not change the baudrate of the serial port of the '/sbin/yunbridge' script
    How to set YUN bridge serial port baudrate ? Please explain

    BTW what are the outputs of these commands on your test environment (ie. on Omega2):

    0_1564860840623_a7dd6039-6eb4-425d-9125-b156eb492fc5-image.png

    Which package do i need to install ?



  • I got it stty package name from another omega community
    0_1564862016318_b3e068d7-8995-4aaa-952a-e4755ab30274-image.png

    I had installed stty package, and here is the result

    0_1564862083578_76629337-cca4-400d-802c-de5a1d567184-image.png

    Please guide me what next i should do ?



  • @Suman-kumar-Jha OK 🙂 Now - after more than 30 posts - we know if you want to test Arduino Bridge between an Arduino and an Omega2(+) then you must install these packages:
    python, coreutils-stty and yunbridge.


    The next step:

    I think first of all you should modify the '/sbin/yunbridge' shell script.

    #!/bin/sh
    stty -F /dev/ttyS0 2500000 clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS0
    exec > /dev/ttyS0
    exec 2> /dev/ttyS0
    askfirst bin/ash --login

    There are at least two problems here:

    • On Omega2 the Serial Console uses ttyS0 (UART0) - so it's not free.
      On Omega2 ttyS0 (UART0) is occupied by the Serial Console - so it's not free.
      One of the possibilities: use ttyS1 (UART1) instead.

    • 2500000 Baud (2,500,000 Baud ie. 2.5 MBaud) is too high for Omega2
      and stty - without some hack - can set only regular Baud rates (eg. ..., 115200, 230400, ...).
      I think 115200 is a good choice for the first test.

    So this could be the modified script:

    #!/bin/sh
    stty -F /dev/ttyS1 115200 clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS1
    exec > /dev/ttyS1
    exec 2> /dev/ttyS1
    askfirst bin/ash --login

    or if you want to set the communication speed in the yunbridge config file
    with uci set yunbridge.config.baudrate='<BAUDRATE>' then it could be

    #!/bin/sh
    BAUDRATE=`uci get yunbridge.config.baudrate`
    stty -F /dev/ttyS1 ${BAUDRATE} clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS1
    exec > /dev/ttyS1
    exec 2> /dev/ttyS1
    askfirst bin/ash --login


    Here you are some quick and dirty tests wit the modified '/sbin/yunbridge' script
    test bed [Arduino UNO -- level shifters -- Omega2+ on Expansion Dock, FW b299] :

     *** The first "test" ***
    
    # Without Arduino UNO
    # Omega2+ on Expansion Dock, FW b299
    # FTD232 on Omega2's UART1 lines -- Ubuntu 18.04.2 LTS, picocom
    
    Please press Enter to activate this console.
    
    # Enter pressed manually
    
    BusyBox v1.28.3 () built-in shell (ash)
    
    /bin/ash: can't access tty; job control turned off
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ?  /___/
     -----------------------------------------------------
       Ω-ware: 0.3.2 b229
     -----------------------------------------------------
    root@Omega-5BE1:/#
    
    # So the shell started "well"
    # although the *'can't access tty; job control turned off~'* is not a too good message 
     
    
    # *** The second "test" ***
    
    # With Arduino - the *'Console Pixel'* example sketch is running on it
    # I watched only Omega2's TX1 line 
    
    Please press Enter to activate this console.
    ��^C  # this was Omega's reply: 0xEF 0xBF 0xBD 0xEF 0xBF 0xBD 5E 43 0A 0A 0A  . . . . . . ^ C LF LF LF
    
    
     
    BusyBox v1.28.3 () built-in shell (ash)
    
    bin/ash: can't access tty; job control turned off
       ____       _             ____
      / __ \___  (_)__  ___    / __ \__ _  ___ ___ ____ _
     / /_/ / _ \/ / _ \/ _ \  / /_/ /  ' \/ -_) _ `/ _ `/
     \____/_//_/_/\___/_//_/  \____/_/_/_/\__/\_, /\_,_/
     W H A T  W I L L  Y O U  I N V E N T ?  /___/
     -----------------------------------------------------
       Ω-ware: 0.3.2 b229
     -----------------------------------------------------
    root@Omega-5BE1:/# 
    root@Omega-5BE1:/# �V�  # Omega's reply: 0xEF 0xBF 0xBD 56 0xEF 0xBF 0xBD 0A 0A 0A  . . . V . . . LF LF LF
    
    
    
    

    It seems the two devices can communicate with each other via the Arduino Bridge
    but something is not perfect yet because the LED is not blinking.
    See also the Console Pixel example sketch.

    You could repeat these tests also on your Arduino Dock 2.



  • @György-Farkas said in Making Omega2 talks with SAMD21 (Arduino Zero):

    dirty tests wit the modified '/sbin/yunbridge' script

    Thanks, i had done everything as you said. Now can you please send yunbridge script. So i can also perform bridge test on my test bed



  • @Suman-kumar-Jha said in Making Omega2 talks with SAMD21 (Arduino Zero):

    Now can you please send yunbridge script.

    What are you talking about please?



  • 0_1565069526378_66582d7d-c241-4b55-aff6-1f1be0103541-image.png

    I requested you for sending me script file what you used to test yunbridge on your test bed.
    I also had setup same test bed, but i don't have script to test.

    In /sbin/yunbridge i found only yun bridge settings.
    So kindly send your Yun bridge test script.



  • @Suman-kumar-Jha There is no more file - only the modified '/sbin/yunbridge'. It's a shell script that starts a serial console during Omega's init - independently from the Arduino.



  • Ok i got it, what modification required can you tell in yunbridge script file.

    This is the script i am having now, what modification needed

    *#!/bin/sh

    BAUDRATE=uci get yunbridge.config.baudrate
    [ -n "${BAUDRATE}" ] || BAUDRATE=250000

    [ -e /lib/ramips.sh -a ${BAUDRATE} = 250000 ] && BAUDRATE=2500000

    stty -F /dev/ttyS1 ${BAUDRATE} clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS1
    exec > /dev/ttyS1
    exec 2> /dev/ttyS1
    askfirst bin/ash --login*



  • @Suman-kumar-Jha One more time 😉

    This was the originally installed '/sbin/yunbridge' file on Omega2(+) :

    root@Omega-5BE1:/# cat /sbin/yunbridge
    #!/bin/sh
    stty -F /dev/ttyS0 2500000 clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS0
    exec > /dev/ttyS0
    exec 2> /dev/ttyS0
    askfirst bin/ash --login
    

    I've modified it because

    • we can't set either 250000 (ie. 250,000 250 kBaud) or 2500000 (ie 2,500,000 2.5 MBaud) with the stty command
    • and ttyS0 (UART0) is occupied by the Serial Console on Omega2(+) - so I tried to use ttyS1 (UART1) instead

    This is the modified '/sbin/yunbridge' file:

    root@Omega-5BE1:/# cat /sbin/yunbridge
    #!/bin/sh
    stty -F /dev/ttyS1 115200 clocal cread cs8 -cstopb -parenb
    exec < /dev/ttyS1
    exec > /dev/ttyS1
    exec 2> /dev/ttyS1
    askfirst bin/ash --login
    

    That's it!

    I think 115200 Baud is a good choice. It's good for all - for Omega2, Arduino, Arduino Bridge, Arduino IDE, ...
    IMO the serial line speed is not the most important problem in this five-liner script now.


    BTW please try it what you want:

    root@Omega-5BE1:~# stty -F /dev/ttyS1 250000
    stty: invalid argument ‘250000’
    Try 'stty --help' for more information.
    
    root@Omega-5BE1:~# stty -F /dev/ttyS1 2500000
    stty: /dev/ttyS1: unable to perform all requested operations
    
    
    root@Omega-5BE1:~# stty -F /dev/ttyS1 115200
    root@Omega-5BE1:~# stty -F /dev/ttyS1
    speed 115200 baud; line = 0;
    -brkint -imaxbel
    
    
    


Looks like your connection to Community was lost, please wait while we try to reconnect.