53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
# boot.py -- run on boot to configure USB and filesystem
|
|
# Put app code in main.py
|
|
print('boot.py start')
|
|
from math import e
|
|
import machine
|
|
import pyb
|
|
|
|
pyb.Pin(pyb.Pin.cpu.E4, pyb.Pin.OUT_PP).value(0) # 看门狗
|
|
|
|
import time
|
|
try:
|
|
#复位网上芯片
|
|
a8 = machine.Pin(pyb.Pin.cpu.A8, machine.Pin.OUT)
|
|
a8.value(0)
|
|
time.sleep_ms(10)
|
|
a8.value(1)
|
|
except Exception as e:
|
|
print('boot.py error:', e)
|
|
|
|
pyb.Pin(pyb.Pin.cpu.E4, pyb.Pin.OUT_PP).value(1) # 看门狗
|
|
|
|
pyb.main('main.py') # main script to run after this one
|
|
#pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
|
|
#pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
|
|
import network
|
|
network.country('CN') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU or XX for worldwide
|
|
network.hostname('CPY_SCANNER') # DHCP/mDNS hostname
|
|
|
|
|
|
from json_config import read_config
|
|
|
|
conf = read_config()
|
|
|
|
pyb.Pin(pyb.Pin.cpu.E4, pyb.Pin.OUT_PP).value(0) # 看门狗
|
|
|
|
time.sleep(0.2)
|
|
lan = network.LAN(phy_addr=1)
|
|
lan.active(True)
|
|
|
|
if conf['daq_test']:
|
|
lan.ifconfig(('192.168.100.200', '255.255.255.0', '192.168.100.1', '8.8.8.8'))
|
|
else:
|
|
lan.ifconfig((conf['ip'], '255.255.255.0', '192.168.100.1', '8.8.8.8'))
|
|
|
|
print(lan.ifconfig())
|
|
|
|
#import webserver
|
|
#webserver.main()
|
|
|
|
print('boot.py end')
|
|
|
|
|
|
pyb.Pin(pyb.Pin.cpu.E4, pyb.Pin.OUT_PP).value(1) # 看门狗 |