]> us-delaporte.pagekite.me Git - dotfiles.git/blob - invoke/esptool/tasks.py
Add check for device connected
[dotfiles.git] / invoke / esptool / tasks.py
1 from invoke import task
2
3 from datetime import datetime as dt
4 import os
5
6 HOME = os.path.expanduser('~')
7 TODAY = dt.now().strftime('%Y.%m.%d')
8
9 @task
10 def help(c):
11 '''
12 On using this tasks file
13
14 - Set the Cardputer Adv power to 'off' state
15 - Plugging in to USB will cause it to boot
16 - Hold 'Go' while booting
17 - Hold 'Go' and press 'Reset' to try again.
18 - On success, the usual screen content still shows up
19 > Tip: Be sure to use a cable that can carry data, not just power.
20
21 Consider burnin
22 https://github.com/echo-lalia/MicroHydra
23
24 '''
25 print(help.__doc__)
26
27 @task
28 def groups(c):
29 '''Check that the current user is a member of dialout'''
30 result = c.run(f'groups {os.getlogin()}')
31 assert 'dialout' in result.stdout
32 print('ok')
33
34 @task
35 def usbdiff(c):
36 '''Use lsusb to try to find the new device.'''
37 input('Un-plug in the device...')
38 c.run('lsusb > /tmp/before.txt')
39 input('Plug in the device...')
40 c.run('lsusb > /tmp/after.txt')
41 result = c.run('diff /tmp/before.txt /tmp/after.txt')
42 print(result.stdout)
43 # breakpoint()
44
45 # Maybe https://thelastoutpostworkshop.github.io/ESPConnect/ in Chromium?
46
47 DEV='/dev/ttyACM0'
48
49 @task
50 def check_connected(c):
51 dev = 'Espressif'
52 result = c.run(f'lsusb | grep {dev}')
53 assert dev in result.stdout
54 print('[ok]')
55
56 @task
57 def listusb(c):
58 c.run('ls /dev/ttyACM*')
59 # c.run('ls /dev/ttyUSB*')
60
61 @task()
62 def chip_id(c):
63 c.run(f'esptool --port {DEV} chip-id')
64