Develop on your PC, Deploy on your Yun


introduction
=================
it easier develop program using python rather c/c++
it easier develop program on pc rather on linux side of yun.
it easier "heavy lifting" using python , on linux side of yun rather c/c++ on arduino side.

when first heard of yun assumed raspberry pi wifi , arduino without sound , graphics. , is. way presented yun developers forgiven thinking linux attachment arduno rather arduino attachment linux.

it easy write combination of python , arduino code works on pc connected uno , run little or no change on yun.

the change neeeded arduino code change serial serial1
and on yun python code connects arduino side via /dev/ttyath0 rather /dev/ttyacm0 (or comxxx on windows)


simple demonstration
=================
the attached zip file includes python , arduino code containing minimal example.

when extract zip file on pc create directory called simpledemo.
it contains file called simpledemo.ino should uploaded arduino side of yun
the complete directory should uploaded linux side of yun. file simpledemo.ino not needed on linux side, won't harm.

with few changes (all noted in comments) code work on pc connected uno, mega or leonardo


python
=================
in note using python because familiar it. python because code runs unchanged on linux, mac or windows. can use other programming languages on yun , of applies them all.


root user on yun
=================
in linux systems user not have full root privileges obvious security reasons, although s/he can temporarily acquire privilieges when required.

because yun intended single user system normal user called root , has of privileges destroy on system :)


preparing yun
=================
out-of-the-box yun uses /dev/ttyath0 communication using bridge library , needs disabled allow python use serial connection.

the file /etc/inittab contains line
ttyath0::askfirst:/bin/ash --login

which needs commented out (so looks this)
# ttyath0::askfirst:/bin/ash --login

and the yun needs restarted.

i have attached 2 short python programs make change (and undo it) if don't want edit /etc/inittab yourself. these programs in pythonbridgedisable.zip.


viewing file contents
=================
if want check contents of text file on linux system simple as
cat filename
for example
cat /etc/inittab


uploading python programs yun
=================
in spite of fact yun comes python installed developers did not provide convenient way upload python programs yun. process not @ complicated. python program text file, or collection of text files.


uploading files yun using scp (also downloading yun)
=================
when connect yun using ssh terminal has access yun. copying files yun must have access both yun , pc contains files. program scp (secure copy) for. (i believe there winscp windows users).

to use scp need open terminal on pc (not terminal may using ssh) , call scp - example
scp myfile.txt root@192....:/mnt/sdxxxxxx
will copy file "myfile.txt" directory /mnt/xxxxxxxx

you notice when run scp ask password yun.

if want copy directory , of files command different
scp -r mydirectory root@192....:/mnt/sdxxxxxx
the "-r" tells copy recursively

for simpledemo program command be
scp -r ./simpledemo root@192.168.x.x:/root
assuming terminal open @ directory contains directory called simpledemo
and, of course, need use correct ip address


uploading arduino sketches yun
=================
i assuming create , upload arduino sketches using pc connected yun via small usb connector.


running python programs using ssh terminal connection yun
=================
ssh (standing secure shell) standard way securely controlling linux pc via command line on internet connection. ssh installed on yun , installed on linux pcs. putty terminal program can used make ssh connection windows (and linux).

to connect yun ssh command is
ssh root@192xxxxxxxxxx
it ask yun password

when have connected using ssh can run programs , usual things if screen directly connected yun.

cd simpledemo          # change project directory
python simpledemo.py   # run program

=================

as usual, comments , corrections welcome.
and helpful if kind windows user try , add necessary additional info.

...r

nice writeup!  8)

when chance, i'll try out under windows, , give info on running winscp copy files.


Arduino Forum > Products > Arduino Yún (Moderator: fabioc84) > Develop on your PC, Deploy on your Yun


arduino

Comments