ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
431 stars 145 forks source link

SOLVED How do I run the sample program on the Lego EV3 with Brickman without a computer? #289

Closed clplaneguy closed 7 years ago

clplaneguy commented 7 years ago

Python 3.6.0 Idle 3.6.0 Eclipse Version: Neon2 Release(4.6.2) Brickmen v0.8.0 2014-2015 Kernal 4.4.32-17-ev3dev-ev3 Lego MindstormSEV3 Programable Brick Revision 0006 MobaXterm Pesonal Edition V9.4 ev3dev Python3.4.2((defalt,oct 8 2014:47:30

#!/usr/bin/env python3
# Above line is needed so program can be run from Brickman

# Plug a touch sensor into any sensor port
from ev3dev.ev3 import *
ts = TouchSensor()

while True:
    if ts.value()==1:   #touch sensor pressed
        Leds.set_color(Leds.LEFT, Leds.RED)
    else:
        Leds.set_color(Leds.LEFT, Leds.GREEN)  

I am new to Lego EV3, EV3dev. MobaXterm, MobaTextEditor, SD card, Etcher and Python. After reading lots of websites everthing seems to work fine. Except for one thing. I need to be able to run programs from the brick(Brickman) stand alone away from the computer. The first example at EV3 Python is for the LEDs, as included here. The shebang is in place in the first line as stated in the text. The program runs fine from the computer. It also seems to run on Brickman, but it does not do anything. My reading makes me feel that I know everything I need to get started. But I cannot find what I have missed. Can someone tell me what else I need to do to run the program on the brick.

I have done: MobaXterm 'Create File' MobaTextEditor edit chmod +x example.py python3 example.py

  THANK YOU
WasabiFan commented 7 years ago

It's likely that the script is throwing an error immediately, and the error message is just flashing on the screen before Brickman comes back. My best guess on the problem is that your file includes Windows-style line endings, which Linux doesn't respond well to. I'm not sure exactly how MobaXTerm works, but somewhere there should be a "line endings" option; choose "linux-style" or \n.

dwalton76 commented 7 years ago

Take a video of the screen with your phone and see if you can catch the error?

clplaneguy commented 7 years ago

The options in MobaTextEditor are Dos,Unix and Mac. I thought that the closest thing to Windows was Dos. I changed the option to Unix and it works fine now. I never thought about checking the documentation for the editor. THANKS GUYS

On Mon, Jan 30, 2017 at 4:09 PM, Wasabi Fan notifications@github.com wrote:

It's likely that the script is throwing an error immediately, and the error message is just flashing on the screen before Brickman comes back. My best guess on the problem is that your file includes Windows-style line endings, which Linux doesn't respond well to. I'm not sure exactly how MobaXTerm works, but somewhere there should be a "line endings" option; choose "linux-style" or \n.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rhempel/ev3dev-lang-python/issues/289#issuecomment-276207675, or mute the thread https://github.com/notifications/unsubscribe-auth/AV8Div_XJSDNTvvT_VhyO0nqAy0vWx6tks5rXl99gaJpZM4Lx5Dx .

WasabiFan commented 7 years ago

Yeah, DOS is equivalent to Windows in this case; you are looking for Linux/Unix. Glad it works!

FWIW, we have info on this (admittedly it's a bit buried): http://python-ev3dev.readthedocs.io/en/latest/faq.html