Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No success with WiPy and new build #11

Open
peterhinch opened this issue Nov 21, 2015 · 7 comments
Open

No success with WiPy and new build #11

peterhinch opened this issue Nov 21, 2015 · 7 comments

Comments

@peterhinch
Copy link

It works well with the Pyboard but I can't connect to the WiPy either wirelessly or via the expansion board USB. My main.py is just a single line comment. boot.py is

# boot.py -- run on boot-up

from machine import UART, idle, reset_cause, SOFT_RESET
from network import WLAN
from os import dupterm
from time import sleep_ms

SSID = 'misspiggy'
AUTH = (WLAN.WPA2, 'redacted')

# enable the UART on the USB-to-serial port
uart = UART(0, baudrate=115200)
# duplicate the terminal on the UART
dupterm(uart)
print('UART initialised')

# login to the local network
print('Initialising WLAN in station mode...', end=' ')

wlan = WLAN()

if reset_cause() != SOFT_RESET:
    wlan.init(WLAN.STA)
    nets = wlan.scan()
    try:
        net = [n for n in nets if n.ssid == SSID][0]
        # configuration below MUST match your home router settings!!
        wlan.ifconfig(config=('192.168.0.100', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
    except IndexError:
        print('ssid "',SSID, '" not found')

if not wlan.isconnected():
    wlan.connect(ssid=SSID, auth=AUTH, timeout=5000)
    while not wlan.isconnected():
        idle() # save power while waiting

ip, mask, gateway, dns = wlan.ifconfig()
print('IP address: ', ip)
print('Netmask:    ', mask)
print('Gateway:    ', gateway)
print('DNS:        ', dns)

Firstly, wired connection. Demo that hardware is OK - successive connections using Miniterm:

[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy
$ mtwipy
--- Miniterm on /dev/wipy: 115200,8,N,1 ---
--- Quit: Ctrl+]  |  Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
UART initialised
Initialising WLAN in station mode... IP address:  192.168.0.100
Netmask:     255.255.255.0
Gateway:     192.168.0.1
DNS:         8.8.8.8
MicroPython v1.5-1-ge954604 on 2015-10-21; WiPy with CC3200
Type "help()" for more information.
>>> 
--- exit ---
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy
$ mtwipy
--- Miniterm on /dev/wipy: 115200,8,N,1 ---
--- Quit: Ctrl+]  |  Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

>>> 
>>> 
--- exit ---
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy

Now trying using rshell: evidently some connectivity is occurring, then it falls over.
alias wipy='/mnt/qnap2/python/rshell/rshell.py -p /dev/wipy'

$ wipy
connecting to serial /dev/wipy
Connecting to /dev/wipy ...
b'OK\r\nPYB: soft reboot\r\nUART initialised\r\nInitialising WLAN in station mode... IP address:  192.168.0.100\r\nNetmask:     255.255.255.0\r\nGateway:     192.168.0.1\r\nDNS:         8.8.8.8\r\nraw REPL; CTRL-B to exit\r\n>'
Traceback (most recent call last):
  File "/mnt/qnap2/python/rshell/rshell.py", line 851, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/qnap2/python/rshell/rshell.py", line 1837, in <module>
    main()
  File "/mnt/qnap2/python/rshell/rshell.py", line 1820, in main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "/mnt/qnap2/python/rshell/rshell.py", line 857, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "/mnt/qnap2/python/rshell/rshell.py", line 874, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/mnt/qnap2/python/rshell/rshell.py", line 1066, in __init__
    Device.__init__(self, pyb)
  File "/mnt/qnap2/python/rshell/rshell.py", line 908, in __init__
    self.has_buffer = self.remote_eval(test_buffer)
  File "/mnt/qnap2/python/rshell/rshell.py", line 989, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "/mnt/qnap2/python/rshell/rshell.py", line 970, in remote
    self.pyb.enter_raw_repl()
  File "/mnt/qnap2/python/rshell/pyboard.py", line 171, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
pyboard.PyboardError: could not enter raw repl
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy
$ 

Wireless connectivity: successive telnet sessions

[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy
$ telnet 192.168.0.100
Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.
MicroPython v1.5-1-ge954604 on 2015-10-21; WiPy with CC3200
Login as: micro                        
Password: 
Login succeeded!
Type "help()" for more information.

>>> 
>>> 
telnet> q
Connection closed.
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy
$ telnet 192.168.0.100
Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.
MicroPython v1.5-1-ge954604 on 2015-10-21; WiPy with CC3200
Login as: micro
Password: 
Login succeeded!
Type "help()" for more information.

>>> 
>>> 
telnet> q
Connection closed.
[adminpete@axolotl]: /mnt/qnap2/data/Projects/MicroPython/wipy

Now trying rshell

$ /mnt/qnap2/python/rshell/rshell.py
Welcome to rshell. Use Control-D to exit.
/mnt/qnap2/data/Projects/MicroPython/wipy> repl
Unable to find board ''
/mnt/qnap2/data/Projects/MicroPython/wipy> 
@dhylands
Copy link
Owner

I believe that pyboard.py has an issue trying to enter the raw-repl if your boot.py script prints anything.
micropython/micropython#1491

So I guess the first thing to do would be to verify that you can use pyboard.py with your WiPy. If pyboard.py doesn't work, then rshell won't work. I should mention that in the docs.

I should probably see if pyboard.py can be fixed properly.

Hmm. I added support in rshell for connecting to multiple pyboards. As a consequence if you run rshell with no arguments, it will autoconnect to pyboards. I think I may have forgotten to add a connect command for telnet (should be easy to fix though).

Can you try pass -p IP-address when you invoke rshell?

I'll see about printing a better error message if no boards are connected. There is a boards command which lists all of the connected boards.

@peterhinch
Copy link
Author

I'm short of time until tomorrow when I'll test the USB and pyboard.py. This was the outcome of a brief test using telnet. I modified boot.py by commenting out all the print statements and did a reset via telnet.

[adminpete@axolotl]: ~/qnap/python/rshell
$ telnet 192.168.0.100
Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.
MicroPython v1.5-1-ge954604 on 2015-10-21; WiPy with CC3200
Login as: micro
Password: 
Login succeeded!
Type "help()" for more information.

>>> import machine
>>> machine.reset()
Connection closed by foreign host.
[adminpete@axolotl]: ~/qnap/python/rshell
$ ./rshell.py -p 192.168.0.100
Connecting to ip 192.168.0.100
Connecting to (192.168.0.100) ...
Welcome to rshell. Use Control-D to exit.
/mnt/qnap2/python/rshell> boards
pyboard @ 192.168.0.100 connected
/mnt/qnap2/python/rshell> repl
Exception in thread Thread-1:
                             Traceback (most recent call last):
                                                                 File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
                                                                                                                                          self.run()
                                                                                                                                                      File "/usr/lib/python3.4/threading.py", line 868, in run
                                                                                                                                                                                                                  self._target(*self._args, **self._kwargs)
                        File "./rshell.py", line 1533, in repl_serial_to_stdout
                                                                                   save_timeout = dev.timeout()
                                                                                                                 File "./rshell.py", line 1009, in timeout
                                                                                                                                                              return self.pyb.serial.timeout
                                                                                                                                                                                            AttributeError: 'TelnetToSerial' object has no attribute 'timeout'

So it connects if I specify the IP, but I can't get a working REPL.

@dhylands
Copy link
Owner

Bah - figures - I tested lots of other things and forgot repl!

I also just pushed a bunch of other changes. I'll fix the repl issue today.

@dhylands
Copy link
Owner

ok - the repl on the wipy should work properly now. You can also connect over telnet after starting rshell by using 'connect telnet hostname' or 'connect telnet ip-address'.

The boards command will show whatever boards are currently connected. If you're connected to multiple boards you can copy files from one board to the other.

@dhylands
Copy link
Owner

USB serial to the wipy still doesn't work (at least copying files to the wipy doesn't work). i think I have an idea how to fix it, but it will need some more investigation.

@peterhinch
Copy link
Author

REPL on the wipy is now fine, and file copy works in both directions. I got no joy from 'connect telnet ip-address' but I'm unclear why you'd want to do this, given the options of running the REPL or running a Telnet session direct from the terminal. For the sake of completeness this is the outcome when I try it

[adminpete@axolotl]: ~/qnap/python/rshell
$ ./rshell.py -p 192.168.0.100
Connecting to (192.168.0.100) ...
Welcome to rshell. Use Control-D to exit.
/mnt/qnap2/python/rshell> connect telnet 192.168.0.100
Connecting to (192.168.0.100) ...
No response from 192.168.0.100
/mnt/qnap2/python/rshell> 

@dhylands
Copy link
Owner

You can use the connect command to connect to multiple wipy's or pyboards at the same time.

For the following example, I'll start rshell which will auto-connect to the pyboard. Then I'll use the connect telnet command to connect to the wipy, and finally copy a file from the pyboard to the wipy.

2881 >rshell.py 
Connecting to /dev/ttyACM0 ...
Welcome to rshell. Use Control-D to exit.
/home/dhylands> boards
pyboard @ /dev/ttyACM0 connected
/home/dhylands> connect telnet wipy
Connecting to wipy (192.168.0.63) ...
/home/dhylands> boards
pyboard @ /dev/ttyACM0        connected
wipy    @ wipy (192.168.0.63) connected
/home/dhylands> ls /pyboard/flash
atomic.py   bioloid.py  boot.py     chess.py    main.py     receiver.py README.txt  pybcdc.inf 
/home/dhylands> ls /wipy/flash
cert/          lib/           sys/           boot.py        main.py        wlan.py        wlan_dhcp.py   wlan_static.py test.txt       upy-cdc.txt   
/home/dhylands> cp /pyboard/flash/atomic.py /wipy/flash
/home/dhylands> ls /wipy/flash
cert/          lib/           sys/           atomic.py      boot.py        main.py        wlan.py        wlan_dhcp.py   wlan_static.py test.txt       upy-cdc.txt   
/home/dhylands> repl pyboard
Entering REPL. Use Control-X to exit.
>
MicroPython v1.5-164-gb030871-dirty on 2015-11-20; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> 
>>> 
/home/dhylands> repl wipy
Entering REPL. Use Control-X to exit.
>
MicroPython v1.5-2-g126373a on 2015-11-16; WiPy with CC3200
Type "help()" for more information.
>>> 
>>>  
/home/dhylands> 

You can put a board.py file in the boards filesystem and put a line like this in it:

name = 'foo'

and then when you use the boards command it will show as that name instead of wipy or pyboard. rshell just does an import board, so board.py can be anywhere in the seach path.

When you use /flash or /sd it refers to the filesystem on the first board. You can use /board-name/flash or /board-name/sd to get to an arbitrary board.

repl with no arguments connects to the first board. repl board-name connects to the indicated board.

Trying to connect to a Wipy while you're already connected will fail (since the wipy only supports one connection) which is what you were seeing above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants