]> apps.delaporte.us Git - dotfiles.git/blob - invoke/esptool/tasks.py
Stronger status checks
[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 # Examples for CardputerAdv
10 DEVICE = 'Espressif'
11 PORT='/dev/ttyACM0' # Linux
12 # PORT='COM0' # Windows
13
14 @task
15 def help(c):
16 '''
17 On using this tasks file
18
19 - Set the Cardputer Adv power to 'off' state
20 - Plugging in to USB will cause it to boot
21 - Hold 'Go' while booting
22 - Hold 'Go' and press 'Reset' to try again.
23 - On success, the usual screen content still shows up
24 > Tip: Be sure to use a cable that can carry data, not just power.
25
26 Consider burnin
27 https://github.com/echo-lalia/MicroHydra
28
29 '''
30 print(help.__doc__)
31
32 @task
33 def groups(c):
34 '''Check that the current user is a member of dialout'''
35 result = c.run(f'groups {os.getlogin()}')
36 assert 'dialout' in result.stdout
37 print('ok')
38
39 @task
40 def usbdiff(c):
41 '''Use lsusb to try to find the new device.'''
42 input('Un-plug in the device...')
43 c.run('lsusb > /tmp/before.txt')
44 input('Plug in the device...')
45 c.run('lsusb > /tmp/after.txt')
46 result = c.run('diff /tmp/before.txt /tmp/after.txt')
47 print(result.stdout)
48 # breakpoint()
49
50 # Maybe https://thelastoutpostworkshop.github.io/ESPConnect/ in Chromium?
51
52
53 @task
54 def check_conn(c):
55 result = c.run(f'lsusb | grep {DEVICE}')
56 assert DEVICE in result.stdout
57 print('[ok]')
58
59 @task
60 def listusb(c):
61 # result = c.run('ls /dev/ttyACM*')
62 result = c.run(f'ls {PORT}')
63 assert result.ok
64 print('[ok]')
65 # c.run('ls /dev/ttyUSB*')
66
67 @task
68 def chip_id(c):
69 c.run(f'esptool --port {PORT} chip-id')
70 print('[ok]')
71
72 @task
73 def check_all(c):
74 listusb(c)
75 check_conn(c)
76 chip_id(c)
77